From 4a3bd6008be9ea401fe226a84f488dcf0f143c00 Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Tue, 28 Jan 2020 17:25:07 -0800 Subject: [PATCH] fix(test): fix race in confusing `confuse with previous navigation` test (#730) --- test/page.spec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/page.spec.js b/test/page.spec.js index 3672e78c23..4d96665332 100644 --- a/test/page.spec.js +++ b/test/page.spec.js @@ -539,8 +539,10 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF let imgResponse = null; server.setRoute(imgPath, (req, res) => imgResponse = res); let loaded = false; + // get the global object to make sure that the main execution context is alive and well. + await page.evaluate(() => this); // Trigger navigation which might resolve next setContent call. - page.evaluate(url => window.location.href = url, server.EMPTY_PAGE); + const evalPromise = page.evaluate(url => window.location.href = url, server.EMPTY_PAGE); const contentPromise = page.setContent(``).then(() => loaded = true); await server.waitForRequest(imgPath); @@ -551,6 +553,7 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF imgResponse.end(); await contentPromise; + await evalPromise; }); it('should work with doctype', async({page, server}) => { const doctype = '';