Skip to content

Commit

Permalink
test(beforeunload): add failing beforeunload test (#4188)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored Oct 20, 2020
1 parent 7433ae2 commit 3cceb14
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions test/page-close.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
2 changes: 1 addition & 1 deletion test/playwright.fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3cceb14

Please sign in to comment.