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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user