diff --git a/test/page-close.spec.ts b/test/page-close.spec.ts index fc946230ce..f7cae6af29 100644 --- a/test/page-close.spec.ts +++ b/test/page-close.spec.ts @@ -26,3 +26,20 @@ it('should close page with active dialog', (test, { browserName, platform }) => await page.waitForEvent('dialog'); await page.close(); }); + +it('should access page after beforeunload', (test, { browserName }) => { + test.fixme(browserName === 'firefox', 'Only works on WebKit atm'); + test.fixme(browserName === 'chromium'); +}, async ({context}) => { + const page = await context.newPage(); + await page.evaluate(() => { + window.addEventListener('beforeunload', event => { + event.preventDefault(); + event.returnValue = 'Do you want to close page?'; + }); + }); + await page.close({ runBeforeUnload: true }); + const dialog = await page.waitForEvent('dialog'); + await dialog.dismiss(); + await page.evaluate(() => document.title); +}); diff --git a/test/playwright.fixtures.ts b/test/playwright.fixtures.ts index 1138e226b6..7ff01a63c0 100644 --- a/test/playwright.fixtures.ts +++ b/test/playwright.fixtures.ts @@ -26,7 +26,7 @@ import type { Browser, BrowserContext, BrowserContextOptions, BrowserType, Launc export { expect, config } from 'folio'; // Test timeout for e2e tests is 30 seconds. -config.timeout = 30000; +config.timeout = Math.max(config.timeout, 30000); // Parameters ------------------------------------------------------------------ // ... these can be used to run tests in different modes.