Bug 1544813: Add a test for extension debugger. r=jdescottes
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Thu, 16 May 2019 06:10:48 +0000
changeset 474280 5745d2f2bf46a0962ba405ab1d2b705630376d7f
parent 474279 edd9b8f1a0badea3cd7216b6f4db7a44bd77106c
child 474281 45d495a1a3a97f659451ce077d17d8e23fba7fb4
push id36027
push usershindli@mozilla.com
push dateFri, 17 May 2019 16:24:38 +0000
treeherdermozilla-central@c94c54aff466 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1544813
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1544813: Add a test for extension debugger. r=jdescottes Depends on D31224 Differential Revision: https://phabricator.services.mozilla.com/D31225
devtools/client/aboutdebugging-new/test/browser/browser.ini
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_debug_debugger.js
--- a/devtools/client/aboutdebugging-new/test/browser/browser.ini
+++ b/devtools/client/aboutdebugging-new/test/browser/browser.ini
@@ -22,16 +22,18 @@ support-files =
   resources/test-temporary-extension/*
   test-tab-favicons.html
   !/devtools/client/shared/test/shared-head.js
   !/devtools/client/shared/test/shared-redux-head.js
   !/devtools/client/shared/test/telemetry-test-helpers.js
 
 [browser_aboutdebugging_addons_debug_console.js]
 tags = webextensions
+[browser_aboutdebugging_addons_debug_debugger.js]
+tags = webextensions
 [browser_aboutdebugging_addons_debug_inspector.js]
 tags = webextensions
 [browser_aboutdebugging_addons_debug_nobg.js]
 tags = webextensions
 [browser_aboutdebugging_addons_debug_popup.js]
 skip-if = (verify && debug) || (debug && os == "linux" && bits == 64) # verify: crashes on shutdown, timeouts linux debug Bug 1299001
 tags = webextensions
 [browser_aboutdebugging_addons_manifest_url.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_debug_debugger.js
@@ -0,0 +1,52 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
+/* import-globals-from helper-addons.js */
+Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-addons.js", this);
+
+add_task(async () => {
+  const EXTENSION_NAME = "temporary-web-extension";
+  const EXTENSION_ID = "test-devtools@mozilla.org";
+
+  await enableExtensionDebugging();
+
+  info("The debugger should show the source codes of extension even if " +
+       "devtools.chrome.enabled and devtools.debugger.remote-enabled are off");
+  await pushPref("devtools.chrome.enabled", false);
+  await pushPref("devtools.debugger.remote-enabled", false);
+
+  const { document, tab, window } = await openAboutDebugging();
+  await selectThisFirefoxPage(document, window.AboutDebugging.store);
+
+  await installTemporaryExtensionFromXPI({
+    background: function() {
+      window.someRandomMethodName = () => {
+        // This will not be referred from anywhere.
+        // However this is necessary to show as the source code in the debugger.
+      };
+    },
+    id: EXTENSION_ID,
+    name: EXTENSION_NAME,
+  }, document);
+
+  const { devtoolsTab, devtoolsWindow } =
+    await openAboutDevtoolsToolbox(document, tab, window, EXTENSION_NAME);
+  const toolbox = getToolbox(devtoolsWindow);
+  await toolbox.selectTool("jsdebugger");
+  const { panelWin } = toolbox.getCurrentPanel();
+
+  info("Check the state of redux");
+  ok(panelWin.dbg.store.getState().debuggee.isWebExtension,
+     "isWebExtension flag in debuggee is true");
+
+  info("Check whether the element displays correctly");
+  const sourceList = panelWin.document.querySelector(".sources-list");
+  ok(sourceList, "Source list element displays correctly");
+  ok(sourceList.textContent.includes("moz-extension"),
+     "moz-extension displays correctly");
+
+  await closeAboutDevtoolsToolbox(document, devtoolsTab, window);
+  await removeTemporaryExtension(EXTENSION_NAME, document);
+  await removeTab(tab);
+});