Skip to content

Commit

Permalink
test(bidi): Update beforeunload tests to avoid hangs with bidi browsi…
Browse files Browse the repository at this point in the history
…ngContext.close
  • Loading branch information
juliandescottes committed Jan 10, 2025
1 parent 13bdd3c commit 9917afd
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/library/beforeunload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ it('should run beforeunload if asked for @smoke', async ({ context, server, brow
// We have to interact with a page so that 'beforeunload' handlers
// fire.
await newPage.click('body');
const [dialog] = await Promise.all([
newPage.waitForEvent('dialog'),
newPage.close({ runBeforeUnload: true })
]);
const onDialog = newPage.waitForEvent('dialog');
const onClose = newPage.close({ runBeforeUnload: true });

const dialog = await onDialog;
expect(dialog.type()).toBe('beforeunload');
expect(dialog.defaultValue()).toBe('');
if (browserName === 'chromium')
Expand All @@ -73,6 +73,7 @@ it('should run beforeunload if asked for @smoke', async ({ context, server, brow
await Promise.all([
dialog.accept(),
newPage.waitForEvent('close'),
onClose,
]);
});

Expand All @@ -81,11 +82,11 @@ it('should access page after beforeunload', async ({ page, server }) => {
// We have to interact with a page so that 'beforeunload' handlers
// fire.
await page.click('body');
const [dialog] = await Promise.all([
page.waitForEvent('dialog'),
page.close({ runBeforeUnload: true }),
]);
const onDialog = page.waitForEvent('dialog');
const onClose = page.close({ runBeforeUnload: true });
const dialog = await onDialog;
await dialog.dismiss();
await onClose;
await page.evaluate(() => document.title);
});

Expand Down

0 comments on commit 9917afd

Please sign in to comment.