Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(webkit): emit close on pages before clearing them (#1386)

Dmitry Gozmana96dec58c830
diff --git a/src/webkit/wkBrowser.ts b/src/webkit/wkBrowser.ts
index 8569066570..59a700a4ca 100644
--- a/src/webkit/wkBrowser.ts
+++ b/src/webkit/wkBrowser.ts
@@ -68,9 +68,10 @@ export class WKBrowser extends platform.EventEmitter implements Browser {
_onDisconnect() {
for (const wkPage of this._wkPages.values())
wkPage.dispose();
- this._wkPages.clear();
for (const context of this._contexts.values())
context._browserClosed();
+ // Note: previous method uses pages to issue 'close' event on them, so we clear them after.
+ this._wkPages.clear();
this.emit(Events.Browser.Disconnected);
}