Bug 1550563 - Use new about:debugging URL in about:addons r=rpl,jdescottes
authorMark Striemer <mstriemer@mozilla.com>
Fri, 10 May 2019 20:46:55 +0000
changeset 535540 aca591c75b072b5737b372a4aa226a5aba502b1d
parent 535539 e2bf0e06cb7564341039fe37a03a0dbe70b0a543
child 535541 f8d305fa503b24a1a965a6dd02c6ee2a3cdfd258
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)
reviewersrpl, jdescottes
bugs1550563
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 1550563 - Use new about:debugging URL in about:addons r=rpl,jdescottes Differential Revision: https://phabricator.services.mozilla.com/D30275
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/test/browser/browser.ini
toolkit/mozapps/extensions/test/browser/browser_about_debugging_link.js
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -39,16 +39,18 @@ XPCOMUtils.defineLazyPreferenceGetter(th
                                       "extensions.allowPrivateBrowsingByDefault", true);
 
 XPCOMUtils.defineLazyPreferenceGetter(this, "SUPPORT_URL", "app.support.baseURL",
                                       "", null, val => Services.urlFormatter.formatURL(val));
 XPCOMUtils.defineLazyPreferenceGetter(this, "useHtmlViews",
                                       "extensions.htmlaboutaddons.enabled");
 XPCOMUtils.defineLazyPreferenceGetter(this, "useHtmlDiscover",
                                       "extensions.htmlaboutaddons.discover.enabled");
+XPCOMUtils.defineLazyPreferenceGetter(this, "useNewAboutDebugging",
+                                      "devtools.aboutdebugging.new-enabled");
 
 const PREF_DISCOVERURL = "extensions.webservice.discoverURL";
 const PREF_DISCOVER_ENABLED = "extensions.getAddons.showPane";
 const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
 const PREF_GETADDONS_CACHE_ID_ENABLED = "extensions.%ID%.getAddons.cache.enabled";
 const PREF_UI_TYPE_HIDDEN = "extensions.ui.%TYPE%.hidden";
 const PREF_UI_LASTCATEGORY = "extensions.ui.lastCategory";
 const PREF_LEGACY_EXCEPTIONS = "extensions.legacy.exceptions";
@@ -1385,17 +1387,18 @@ var gViewController = {
     cmd_debugAddons: {
       isEnabled() {
         return true;
       },
       doCommand() {
         let mainWindow = window.windowRoot.ownerGlobal;
         recordLinkTelemetry("about:debugging");
         if ("switchToTabHavingURI" in mainWindow) {
-          mainWindow.switchToTabHavingURI("about:debugging#addons", true, {
+          let path = useNewAboutDebugging ? "/runtime/this-firefox" : "addons";
+          mainWindow.switchToTabHavingURI(`about:debugging#${path}`, true, {
             triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
           });
         }
       },
     },
 
     cmd_cancelOperation: {
       isEnabled(aAddon) {
--- a/toolkit/mozapps/extensions/test/browser/browser.ini
+++ b/toolkit/mozapps/extensions/test/browser/browser.ini
@@ -38,16 +38,17 @@ generated-files =
   addons/browser_dragdrop2.xpi
   addons/browser_dragdrop_incompat.xpi
   addons/browser_installssl.xpi
   addons/browser_theme.xpi
   addons/options_signed.xpi
 
 [browser_CTP_plugins.js]
 tags = blocklist
+[browser_about_debugging_link.js]
 [browser_bug523784.js]
 [browser_bug562797.js]
 [browser_bug562890.js]
 skip-if = os == 'win' && !debug # Disabled on Windows opt/PGO builds due to intermittent failures (bug 1135866)
 [browser_bug562899.js]
 [browser_bug562992.js]
 [browser_bug567127.js]
 skip-if = (!debug && os == 'win') #Bug 1489496
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/browser/browser_about_debugging_link.js
@@ -0,0 +1,81 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const {PromiseTestUtils} = ChromeUtils.import("resource://testing-common/PromiseTestUtils.jsm");
+// Whitelist rejections related to closing an about:debugging too soon after it has been
+// just opened in a new tab and loaded.
+PromiseTestUtils.whitelistRejectionsGlobally(/Connection closed/);
+
+function waitForDispatch(store, type) {
+  return new Promise(resolve => {
+    store.dispatch({
+      type: "@@service/waitUntil",
+      predicate: action => action.type === type,
+      run: (dispatch, getState, action) => {
+        resolve(action);
+      },
+    });
+  });
+}
+
+function waitForRequestsSuccess(store) {
+  return Promise.all([
+    waitForDispatch(store, "REQUEST_EXTENSIONS_SUCCESS"),
+    waitForDispatch(store, "REQUEST_TABS_SUCCESS"),
+    waitForDispatch(store, "REQUEST_WORKERS_SUCCESS"),
+  ]);
+}
+
+add_task(async function testAboutDebugging() {
+  let win = await open_manager(null);
+  let categoryUtilities = new CategoryUtilities(win);
+  await categoryUtilities.openType("extension");
+
+  let aboutAddonsTab = gBrowser.selectedTab;
+  let debugAddonsBtn = win.document.getElementById("utils-debugAddons");
+
+  async function checkUrl(expected, newAboutAddons) {
+    // Set the new about:debugging pref.
+    await SpecialPowers.pushPrefEnv({
+      set: [["devtools.aboutdebugging.new-enabled", newAboutAddons]],
+    });
+
+    // Verify the right URL is loaded.
+    info(`Check about:debugging URL with new: ${newAboutAddons}`);
+    let loaded = BrowserTestUtils.waitForNewTab(gBrowser, expected, true);
+    debugAddonsBtn.doCommand();
+    await loaded;
+    let aboutDebuggingTab = gBrowser.selectedTab;
+
+    if (newAboutAddons) {
+      const {AboutDebugging} = aboutDebuggingTab.linkedBrowser.contentWindow;
+      // Avoid test failures due to closing the about:debugging tab
+      // while it is still initializing.
+      info("Wait until about:debugging actions are finished");
+      await waitForRequestsSuccess(AboutDebugging.store);
+    }
+
+    info("Switch back to about:addons");
+    await BrowserTestUtils.switchTab(gBrowser, aboutAddonsTab);
+    is(gBrowser.selectedTab, aboutAddonsTab, "Back to about:addons");
+
+    info("Re-open about:debugging");
+    let switched = TestUtils.waitForCondition(
+      () => gBrowser.selectedTab == aboutDebuggingTab);
+    debugAddonsBtn.doCommand();
+    await switched;
+
+    info("Remove the about:debugging tab");
+    BrowserTestUtils.removeTab(aboutDebuggingTab);
+
+    // Reset prefs.
+    await SpecialPowers.popPrefEnv();
+  }
+
+  await checkUrl("about:debugging#/runtime/this-firefox", true);
+  await checkUrl("about:debugging#addons", false);
+
+  await close_manager(win);
+});