Bug 1553031 - Hide Remote Debugging menu item when new aboutdebugging is disabled r=daisuke a=jcristau
authorJulian Descottes <jdescottes@mozilla.com>
Tue, 21 May 2019 08:52:18 +0000
changeset 536390 ee3d86beb6c83b5b20e87e4107d949fe579503c3
parent 536389 03dd32c084c52952cad9c96c7f92e45f2ab079a5
child 536391 b0ba67e4a8a6a6ee657c65ef1be719167d3de19f
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)
reviewersdaisuke, jcristau
bugs1553031
milestone68.0
Bug 1553031 - Hide Remote Debugging menu item when new aboutdebugging is disabled r=daisuke a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D31966
devtools/client/menus.js
--- a/devtools/client/menus.js
+++ b/devtools/client/menus.js
@@ -24,49 +24,55 @@
  *   If true, the menuitem and key shortcut are going to be hidden and disabled
  *   on startup, until some runtime code eventually enable them.
  * - checkbox:
  *   If true, the menuitem is prefixed by a checkbox and runtime code can
  *   toggle it.
  */
 
 const { Cu } = require("chrome");
+const Services = require("Services");
 
 loader.lazyRequireGetter(this, "gDevToolsBrowser", "devtools/client/framework/devtools-browser", true);
 loader.lazyRequireGetter(this, "TargetFactory", "devtools/client/framework/target", true);
 loader.lazyRequireGetter(this, "ResponsiveUIManager", "devtools/client/responsive.html/manager", true);
 loader.lazyRequireGetter(this, "openDocLink", "devtools/client/shared/link", true);
 
 loader.lazyImporter(this, "BrowserToolboxProcess", "resource://devtools/client/framework/ToolboxProcess.jsm");
 loader.lazyImporter(this, "ScratchpadManager", "resource://devtools/client/scratchpad/scratchpad-manager.jsm");
 
+const isAboutDebuggingEnabled =
+  Services.prefs.getBoolPref("devtools.aboutdebugging.new-enabled", false);
+const aboutDebuggingItem = {
+  id: "menu_devtools_remotedebugging",
+  l10nKey: "devtoolsRemoteDebugging",
+  disabled: true,
+  oncommand(event) {
+    const window = event.target.ownerDocument.defaultView;
+    gDevToolsBrowser.openAboutDebugging(window.gBrowser);
+  },
+};
+
 exports.menuitems = [
   { id: "menu_devToolbox",
     l10nKey: "devToolboxMenuItem",
     async oncommand(event) {
       try {
         const window = event.target.ownerDocument.defaultView;
         await gDevToolsBrowser.toggleToolboxCommand(window.gBrowser, Cu.now());
       } catch (e) {
         console.error(`Exception while opening the toolbox: ${e}\n${e.stack}`);
       }
     },
     keyId: "toggleToolbox",
     checkbox: true,
   },
   { id: "menu_devtools_separator",
     separator: true },
-  { id: "menu_devtools_remotedebugging",
-    l10nKey: "devtoolsRemoteDebugging",
-    disabled: true,
-    oncommand(event) {
-      const window = event.target.ownerDocument.defaultView;
-      gDevToolsBrowser.openAboutDebugging(window.gBrowser);
-    },
-  },
+  ...(isAboutDebuggingEnabled ? [aboutDebuggingItem] : []),
   { id: "menu_webide",
     l10nKey: "webide",
     disabled: true,
     oncommand() {
       gDevToolsBrowser.openWebIDE();
     },
     keyId: "webide",
   },