diff --git a/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js b/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js index 1f96d8f0919f..f9a61ecb3098 100644 --- a/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js +++ b/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js @@ -2,13 +2,20 @@ /* vim: set sts=2 sw=2 et tw=80: */ "use strict"; +const {GlobalManager} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null); + function getBrowserAction(extension) { - const {GlobalManager, Management: {global: {browserActionFor}}} = ChromeUtils.import("resource://gre/modules/Extension.jsm", {}); + const {global: {browserActionFor}} = Management; let ext = GlobalManager.extensionMap.get(extension.id); return browserActionFor(ext); } +function assertViewCount(extension, count) { + let ext = GlobalManager.extensionMap.get(extension.id); + is(ext.views.size, count, "Should have the expected number of extension views"); +} + let scriptPage = url => `
${url}`; async function testInArea(area) { @@ -204,6 +211,8 @@ async function testInArea(area) { info("Popup is open. Waiting for close"); await promisePopupHidden(panel); } + + assertViewCount(extension, 1); } else if (expecting.closePopupUsingWindow) { let panel = getBrowserActionPopup(extension); ok(panel, "Expect panel to exist"); @@ -213,6 +222,8 @@ async function testInArea(area) { await promisePopupHidden(panel); ok(true, "Panel is closed"); + + assertViewCount(extension, 1); } else if (expecting.closePopup) { if (!getBrowserActionPopup(extension)) { info("Waiting for panel"); @@ -221,6 +232,7 @@ async function testInArea(area) { info("Closing for panel"); await closeBrowserAction(extension); + assertViewCount(extension, 1); } if (area == getCustomizableUIPanelID() && expecting.containingPopupShouldClose) { diff --git a/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js b/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js index 4d6e0e7a2a3d..654167b5d7a1 100644 --- a/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js +++ b/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js @@ -2,6 +2,13 @@ /* vim: set sts=2 sw=2 et tw=80: */ "use strict"; +const {GlobalManager} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null); + +function assertViewCount(extension, count) { + let ext = GlobalManager.extensionMap.get(extension.id); + is(ext.views.size, count, "Should have the expected number of extension views"); +} + add_task(async function testPageActionPopup() { let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/"); @@ -178,6 +185,8 @@ add_task(async function testPageActionPopup() { panel.hidePopup(); } + assertViewCount(extension, 1); + if (panel) { panel = document.getElementById(panelId); is(panel, null, "panel successfully removed from document after hiding"); diff --git a/toolkit/components/extensions/ExtensionParent.jsm b/toolkit/components/extensions/ExtensionParent.jsm index d0f4307fabd3..13f76340b56f 100644 --- a/toolkit/components/extensions/ExtensionParent.jsm +++ b/toolkit/components/extensions/ExtensionParent.jsm @@ -587,9 +587,13 @@ class ExtensionPageContextParent extends ProxyContextParent { this.xulBrowser = browser; } + unload() { + super.unload(); + this.extension.views.delete(this); + } + shutdown() { apiManager.emit("page-shutdown", this); - this.extension.views.delete(this); super.shutdown(); } }