Skip to content

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

fix(chromium): handle backgroundPages() onClose (#6541)

Max Schmittdc7f7f9a8c86
diff --git a/src/client/page.ts b/src/client/page.ts
index e7511318ad..f6e308ddc1 100644
--- a/src/client/page.ts
+++ b/src/client/page.ts
@@ -209,6 +209,7 @@ export class Page extends ChannelOwner<channels.PageChannel, channels.PageInitia
_onClose() {
this._closed = true;
this._browserContext._pages.delete(this);
+ this._browserContext._backgroundPages.delete(this);
this.emit(Events.Page.Close, this);
}
diff --git a/tests/chromium/launcher.spec.ts b/tests/chromium/launcher.spec.ts
index 612eb8429d..3107eef509 100644
--- a/tests/chromium/launcher.spec.ts
+++ b/tests/chromium/launcher.spec.ts
@@ -52,7 +52,8 @@ it('should open devtools when "devtools: true" option is given', async ({browser
await browser.close();
});
-it('should return background pages', async ({browserType, browserOptions, createUserDataDir, asset}) => {
+it('should return background pages', async ({browserType, browserOptions, createUserDataDir, asset, browserChannel}) => {
+ it.fixme(browserChannel);
const userDataDir = await createUserDataDir();
const extensionPath = asset('simple-extension');
const extensionOptions = {...browserOptions,
@@ -71,6 +72,8 @@ it('should return background pages', async ({browserType, browserOptions, create
expect(context.backgroundPages()).toContain(backgroundPage);
expect(context.pages()).not.toContain(backgroundPage);
await context.close();
+ expect(context.backgroundPages().length).toBe(0);
+ expect(context.pages().length).toBe(0);
});
it('should return background pages when recording video', async ({browserType, browserOptions, createUserDataDir, asset}, testInfo) => {