Skip to content

Commit 4a3bd60

Browse files
fix(test): fix race in confusing confuse with previous navigation test (#730)
1 parent 89a9311 commit 4a3bd60

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

test/page.spec.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,10 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF
539539
let imgResponse = null;
540540
server.setRoute(imgPath, (req, res) => imgResponse = res);
541541
let loaded = false;
542+
// get the global object to make sure that the main execution context is alive and well.
543+
await page.evaluate(() => this);
542544
// Trigger navigation which might resolve next setContent call.
543-
page.evaluate(url => window.location.href = url, server.EMPTY_PAGE);
545+
const evalPromise = page.evaluate(url => window.location.href = url, server.EMPTY_PAGE);
544546
const contentPromise = page.setContent(`<img src="${server.PREFIX + imgPath}"></img>`).then(() => loaded = true);
545547
await server.waitForRequest(imgPath);
546548

@@ -551,6 +553,7 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF
551553

552554
imgResponse.end();
553555
await contentPromise;
556+
await evalPromise;
554557
});
555558
it('should work with doctype', async({page, server}) => {
556559
const doctype = '<!DOCTYPE html>';

0 commit comments

Comments
 (0)