Skip to content

Commit

Permalink
test: fix race in 'should respect routes from browser context' test (#…
Browse files Browse the repository at this point in the history
…1559)

We should await the popup, otherwise there is no guarantee that
request has already happened.
  • Loading branch information
dgozman committed Mar 26, 2020
1 parent 9d0f465 commit f420cbb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/popup.spec.js
Expand Up @@ -141,7 +141,7 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, WE
await context.close();
expect(size).toEqual({width: 400, height: 500});
});
it.fail(FFOX)('should respect routes from browser context', async function({browser, server}) {
it('should respect routes from browser context', async function({browser, server}) {
const context = await browser.newContext();
const page = await context.newPage();
await page.goto(server.EMPTY_PAGE);
Expand All @@ -150,9 +150,12 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, WE
route.continue();
intercepted = true;
});
await page.evaluate(url => window.__popup = window.open(url), server.EMPTY_PAGE);
await context.close();
await Promise.all([
page.waitForEvent('popup'),
page.evaluate(url => window.__popup = window.open(url), server.EMPTY_PAGE),
]);
expect(intercepted).toBe(true);
await context.close();
});
it('should apply addInitScript from browser context', async function({browser, server}) {
const context = await browser.newContext();
Expand Down

0 comments on commit f420cbb

Please sign in to comment.