chore(bidi): Do not wait for browsingContext.close if runBeforeUnload is true

This commit is contained in:
Julian Descottes 2025-01-10 19:15:10 +01:00
Родитель ac116248f9
Коммит 8778e02217
2 изменённых файлов: 8 добавлений и 3 удалений

Просмотреть файл

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

Просмотреть файл

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