From dd9028cfe24a45de47ab1dfd5aa212537c2629e7 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Fri, 8 Dec 2023 15:26:24 -0800 Subject: [PATCH] test: fix browsercontext-basic offline test (#28558) Since the last firefox roll, firefox now does internal redirect to the error page when it's been forced into offline mode. --- tests/library/browsercontext-basic.spec.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/library/browsercontext-basic.spec.ts b/tests/library/browsercontext-basic.spec.ts index 21ea63f860..0fd1f98390 100644 --- a/tests/library/browsercontext-basic.spec.ts +++ b/tests/library/browsercontext-basic.spec.ts @@ -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);