Skip to content

Commit

Permalink
fix(test): fix race in confusing confuse with previous navigation t…
Browse files Browse the repository at this point in the history
…est (#730)
  • Loading branch information
JoelEinbinder authored Jan 29, 2020
1 parent 89a9311 commit 4a3bd60
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/page.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(`<img src="${server.PREFIX + imgPath}"></img>`).then(() => loaded = true);
await server.waitForRequest(imgPath);

Expand All @@ -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 = '<!DOCTYPE html>';
Expand Down

0 comments on commit 4a3bd60

Please sign in to comment.