fix(browser): capture selected events in popup pages (#600)

Selected page events from popups are retained even when popup lifecycle events are unselected; popup opened/closed events remain selection-controlled.
This commit is contained in:
Rudy Mizrahi Celekli
2026-10-06 01:51:10 +08:00
committed by GitHub
parent 2919def828
commit a3bf4a0944
2 changed files with 50 additions and 10 deletions
+14 -10
View File
@@ -116,8 +116,10 @@ export class PlaywrightScenarioEvents {
}
if (this.enabled.has("workers"))
page.on("worker", (worker) => this.worker(worker));
if (this.enabled.has("popups"))
page.on("popup", (popup) => this.popup(popup));
// Every selectable event can also be emitted by a child popup page, and a
// popup is only reachable through this one subscription, so any selection at
// all must observe popups. Lifecycle events stay gated on `popups` below.
if (this.enabled.size > 0) page.on("popup", (popup) => this.popup(popup));
if (this.enabled.has("downloads"))
page.on("download", (download) => this.download(download));
}
@@ -243,14 +245,16 @@ export class PlaywrightScenarioEvents {
url: page.url() === "" ? null : this.safeUrl(page.url()),
name: null,
};
this.push({ kind: "popup-opened", ...opened });
page.on("close", () =>
this.push({
kind: "popup-closed",
url: page.url() === "" ? null : this.safeUrl(page.url()),
name: null,
}),
);
if (this.enabled.has("popups")) {
this.push({ kind: "popup-opened", ...opened });
page.on("close", () =>
this.push({
kind: "popup-closed",
url: page.url() === "" ? null : this.safeUrl(page.url()),
name: null,
}),
);
}
this.observePage(page);
}