Skip to content

Commit

Permalink
fix(core): improve profile restore time
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed May 14, 2022
1 parent 3637084 commit 9f69eb2
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions core/lib/UserProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,28 +150,31 @@ ${origins.map(x => `<iframe src="${x}"></iframe>`).join('\n')}
</html>`,
});

for (const frame of page.frames) {
if (frame === page.mainFrame) {
// no loader is set, so need to have special handling
if (!frame.activeLoader.lifecycle.load) {
await frame.waitOn('frame-lifecycle', x => x.name === 'load');
await Promise.all(
page.frames.map(async frame => {
if (frame === page.mainFrame) {
// no loader is set, so need to have special handling
if (!frame.activeLoader.lifecycle.load) {
await frame.waitOn('frame-lifecycle', x => x.name === 'load');
}
return;
}
continue;
}
await frame.waitForLifecycleEvent('DOMContentLoaded');
await frame.waitForLifecycleEvent('DOMContentLoaded');

await frame.evaluate(
`(async function() {
await frame.evaluate(
`(async function() {
while (!document.querySelector("body.ready")) {
await new Promise(resolve => setTimeout(resolve, 20));
}
})()`,
true,
{
shouldAwaitExpression: true,
},
);
}
false,
{
shouldAwaitExpression: true,
returnByValue: true
},
);
}),
);

// clear out frame state
await page.navigate('about:blank');
Expand Down

0 comments on commit 9f69eb2

Please sign in to comment.