fix: split report handler from other page preps

This commit is contained in:
yanlong.wang 2024-04-29 15:19:05 +08:00
parent 036f6dc776
commit bfc6d678d8
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37

View File

@ -193,7 +193,9 @@ function giveSnapshot() {
return r;
}
`));
preparations.push(page.evaluateOnNewDocument(`
await Promise.all(preparations);
await page.evaluateOnNewDocument(`
let aftershot = undefined;
const handlePageLoad = () => {
if (document.readyState !== 'complete') {
@ -215,8 +217,7 @@ const handlePageLoad = () => {
};
document.addEventListener('readystatechange', handlePageLoad);
document.addEventListener('load', handlePageLoad);
`));
await Promise.all(preparations);
`);
// TODO: further setup the page;