test(beforeunload): add failing beforeunload test (#4188)

This commit is contained in:
Pavel Feldman 2020-10-20 08:55:01 -07:00 committed by GitHub
parent 7433ae2798
commit 3cceb14e29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View file

@ -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);
});

View file

@ -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.