Skip to content

Commit

Permalink
test: fix browsercontext-basic offline test (microsoft#28558)
Browse files Browse the repository at this point in the history
Since the last firefox roll, firefox now does internal redirect to the
error page when it's been forced into offline mode.
  • Loading branch information
aslushnikov authored Dec 8, 2023
1 parent 7827838 commit dd9028c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/library/browsercontext-basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,21 @@ it('setContent should work after disabling javascript', async ({ contextFactory
await expect(page.locator('h1')).toHaveText('Hello');
});

it('should work with offline option', async ({ browser, server }) => {
it('should work with offline option', async ({ browser, server, browserName }) => {
const context = await browser.newContext({ offline: true });
const page = await context.newPage();
let error = null;
await page.goto(server.EMPTY_PAGE).catch(e => error = e);
if (browserName === 'firefox') {
// Firefox navigates to an error page, and this navigation might conflict with the
// next navigation we do in test.
// So we need to wait for the navigation explicitly.
await Promise.all([
page.goto(server.EMPTY_PAGE).catch(e => error = e),
page.waitForEvent('framenavigated'),
]);
} else {
await page.goto(server.EMPTY_PAGE).catch(e => error = e);
}
expect(error).toBeTruthy();
await context.setOffline(false);
const response = await page.goto(server.EMPTY_PAGE);
Expand Down

0 comments on commit dd9028c

Please sign in to comment.