Skip to content

Commit

Permalink
chore(bidi): Do not wait for browsingContext.close if runBeforeUnload…
Browse files Browse the repository at this point in the history
… is true
  • Loading branch information
juliandescottes committed Jan 10, 2025
1 parent ac11624 commit 8778e02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 8 additions & 1 deletion packages/playwright-core/src/server/bidi/bidiPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,17 @@ export class BidiPage implements PageDelegate {
}

async closePage(runBeforeUnload: boolean): Promise<void> {
await this._session.send('browsingContext.close', {
const onClose = this._session.send('browsingContext.close', {
context: this._session.sessionId,
promptUnload: runBeforeUnload,
});

// Only wait for the browsingContext to close if runBeforeUnload is false.
// Otherwise a before unload prompt might be displayed and should be handled
// by the caller.
// See NOTE on https://playwright.dev/docs/api/class-page#page-close
if (!runBeforeUnload)
await onClose;
}

async setBackgroundColor(color?: { r: number; g: number; b: number; a: number; }): Promise<void> {
Expand Down
2 changes: 0 additions & 2 deletions tests/bidi/expectations/bidi-chromium-library.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
library/beforeunload.spec.ts › should access page after beforeunload [timeout]
library/beforeunload.spec.ts › should run beforeunload if asked for @smoke [timeout]
library/browsercontext-events.spec.ts › console event should work in immediately closed popup [timeout]
library/browsercontext-events.spec.ts › console event should work in popup 2 [timeout]
library/browsercontext-events.spec.ts › dialog event should work in immediately closed popup [timeout]
Expand Down

0 comments on commit 8778e02

Please sign in to comment.