Bug 1544813: Add a test for extension debugger. r=jdescottes
☠☠ backed out by 2a832d03ebcc ☠ ☠
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Thu, 16 May 2019 03:20:18 +0000
changeset 535943 67e719e02573ca3325763b9c1778ccf33a1738e1
parent 535942 6a315be5f16ff419f73e35c65d2eb9259e5ebb21
child 535944 d15e60f91051c45b51a5c8cf130eaa03ef24ce62
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [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);
+});