Bug 1302702 - Add tests to check that ExtensionParent DebugUtils are cleaned up when the addon debugger is closed. draft
authorLuca Greco <lgreco@mozilla.com>
Tue, 21 Mar 2017 15:59:54 +0100
changeset 567099 da918b34d3d85cdf03e2677080cef7325d876523
parent 567088 5ac51f311264a77ead98d1c7e57640b1e4a572b8
child 567100 7df2249e576aa30e76a3e25db325d3e116878b00
push id55439
push userluca.greco@alcacoop.it
push dateMon, 24 Apr 2017 11:58:41 +0000
bugs1302702
milestone55.0a1
Bug 1302702 - Add tests to check that ExtensionParent DebugUtils are cleaned up when the addon debugger is closed. MozReview-Commit-ID: GZT0U1kNwr3
devtools/client/aboutdebugging/test/browser_addons_debug_webextension.js
--- a/devtools/client/aboutdebugging/test/browser_addons_debug_webextension.js
+++ b/devtools/client/aboutdebugging/test/browser_addons_debug_webextension.js
@@ -5,19 +5,21 @@
 // Avoid test timeouts that can occur while waiting for the "addon-console-works" message.
 requestLongerTimeout(2);
 
 const ADDON_ID = "test-devtools-webextension@mozilla.org";
 const ADDON_NAME = "test-devtools-webextension";
 const ADDON_MANIFEST_PATH = "addons/test-devtools-webextension/manifest.json";
 
 const {
-  BrowserToolboxProcess
+  BrowserToolboxProcess,
 } = Cu.import("resource://devtools/client/framework/ToolboxProcess.jsm", {});
 
+loader.lazyImporter(this, "ExtensionParent", "resource://gre/modules/ExtensionParent.jsm");
+
 /**
  * This test file ensures that the webextension addon developer toolbox:
  * - when the debug button is clicked on a webextension, the opened toolbox
  *   has a working webconsole with the background page as default target;
  */
 add_task(function* testWebExtensionsToolboxWebConsole() {
   let {
     tab, document, debugBtn,
@@ -52,22 +54,35 @@ add_task(function* testWebExtensionsTool
   };
   env.set("MOZ_TOOLBOX_TEST_SCRIPT", "new " + testScript);
   registerCleanupFunction(() => {
     env.set("MOZ_TOOLBOX_TEST_SCRIPT", "");
   });
 
   let onToolboxClose = BrowserToolboxProcess.once("close");
 
+  // Check that no ExtensionDebuggingUtils resources has been created when the
+  // addon are listed in the "about:debugging#addons" page.
+  is(ExtensionParent.DebugUtils.hiddenXULWindow, null,
+     "ExtensionDebuggingUtils's hiddenXULWindow has been destroyed");
+  is(ExtensionParent.DebugUtils.debugBrowserPromises.size, 0,
+     "The map of the retrieved addon debugging browsers should be empty");
+
   debugBtn.click();
 
   let args = yield onCustomMessage;
   ok(true, "Received console message from the background page function as expected");
   is(args[0], "Background page function called", "Got the expected console message");
   is(args[1] && args[1].name, ADDON_NAME,
      "Got the expected manifest from WebExtension API");
 
   yield onToolboxClose;
   ok(true, "Addon toolbox closed");
 
   yield uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
   yield closeAboutDebugging(tab);
+
+  // Check that the ExtensionDebuggingUtils resources has been cleaned up.
+  is(ExtensionParent.DebugUtils.hiddenXULWindow, null,
+     "ExtensionDebuggingUtils's hiddenXULWindow has been destroyed");
+  is(ExtensionParent.DebugUtils.debugBrowserPromises.size, 0,
+     "The map of the retrieved addon debugging browsers should be empty");
 });