Bug 1212689 - Extract ToolboxButtons to save GCLI from loading toolbox.js. r=ochameau
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 12 Oct 2016 16:22:57 -0500
changeset 317881 8f08d2842a623d28aedc098f808793643d32cccd
parent 317880 0d4f60fa9597d39c291b9dcd6004c6ecb7b08657
child 317882 aa490cced7ba5e346a3f7144957dec2313af9ac6
push id33170
push usercbook@mozilla.com
push dateFri, 14 Oct 2016 10:37:07 +0000
treeherderautoland@0d101ebfd95c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1212689
milestone52.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 1212689 - Extract ToolboxButtons to save GCLI from loading toolbox.js. r=ochameau MozReview-Commit-ID: DZcvEa9v0vS
devtools/client/definitions.js
devtools/client/framework/toolbox.js
devtools/shared/gcli/commands/index.js
--- a/devtools/client/definitions.js
+++ b/devtools/client/definitions.js
@@ -462,16 +462,37 @@ Tools.firebugTheme = {
 };
 
 exports.defaultThemes = [
   Tools.darkTheme,
   Tools.lightTheme,
   Tools.firebugTheme,
 ];
 
+// White-list buttons that can be toggled to prevent adding prefs for
+// addons that have manually inserted toolbarbuttons into DOM.
+// (By default, supported target is only local tab)
+exports.ToolboxButtons = [
+  { id: "command-button-frames",
+    isTargetSupported: target => {
+      return target.activeTab && target.activeTab.traits.frames;
+    }
+  },
+  { id: "command-button-splitconsole",
+    isTargetSupported: target => !target.isAddon },
+  { id: "command-button-responsive" },
+  { id: "command-button-paintflashing" },
+  { id: "command-button-scratchpad" },
+  { id: "command-button-screenshot" },
+  { id: "command-button-rulers" },
+  { id: "command-button-measure" },
+  { id: "command-button-noautohide",
+    isTargetSupported: target => target.chrome },
+];
+
 /**
  * Lookup l10n string from a string bundle.
  *
  * @param {string} name
  *        The key to lookup.
  * @param {string} arg
  *        Optional format argument.
  * @returns A localized version of the given key.
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -56,43 +56,24 @@ loader.lazyRequireGetter(this, "system",
   "devtools/shared/system");
 loader.lazyRequireGetter(this, "getPreferenceFront",
   "devtools/shared/fronts/preference", true);
 loader.lazyRequireGetter(this, "KeyShortcuts",
   "devtools/client/shared/key-shortcuts", true);
 loader.lazyRequireGetter(this, "ZoomKeys",
   "devtools/client/shared/zoom-keys");
 loader.lazyRequireGetter(this, "settleAll",
-  "devtools/shared/ThreadSafeDevToolsUtils", "settleAll");
+  "devtools/shared/ThreadSafeDevToolsUtils", true);
+loader.lazyRequireGetter(this, "ToolboxButtons",
+  "devtools/client/definitions", true);
 
 loader.lazyGetter(this, "registerHarOverlay", () => {
   return require("devtools/client/netmonitor/har/toolbox-overlay").register;
 });
 
-// White-list buttons that can be toggled to prevent adding prefs for
-// addons that have manually inserted toolbarbuttons into DOM.
-// (By default, supported target is only local tab)
-const ToolboxButtons = exports.ToolboxButtons = [
-  { id: "command-button-frames",
-    isTargetSupported: target => {
-      return target.activeTab && target.activeTab.traits.frames;
-    }
-  },
-  { id: "command-button-splitconsole",
-    isTargetSupported: target => !target.isAddon },
-  { id: "command-button-responsive" },
-  { id: "command-button-paintflashing" },
-  { id: "command-button-scratchpad" },
-  { id: "command-button-screenshot" },
-  { id: "command-button-rulers" },
-  { id: "command-button-measure" },
-  { id: "command-button-noautohide",
-    isTargetSupported: target => target.chrome },
-];
-
 /**
  * A "Toolbox" is the component that holds all the tools for one specific
  * target. Visually, it's a document that includes the tools tabs and all
  * the iframes where the tool panels will be living in.
  *
  * @param {object} target
  *        The object the toolbox is debugging.
  * @param {string} selectedTool
--- a/devtools/shared/gcli/commands/index.js
+++ b/devtools/shared/gcli/commands/index.js
@@ -77,35 +77,35 @@ exports.devtoolsModules = [
   "devtools/shared/gcli/commands/security",
 ];
 
 /**
  * Register commands from tools with 'command: [ "some/module" ]' definitions.
  * The map/reduce incantation squashes the array of arrays to a single array.
  */
 try {
-  const defaultTools = require("devtools/client/definitions").defaultTools;
+  const { defaultTools } = require("devtools/client/definitions");
   exports.devtoolsToolModules = defaultTools.map(def => def.commands || [])
                                    .reduce((prev, curr) => prev.concat(curr), []);
-} catch(e) {
-  // "definitions" is only accessible from Firefox
+} catch (e) {
+  // "devtools/client/definitions" is only accessible from Firefox
   exports.devtoolsToolModules = [];
 }
 
 /**
  * Register commands from toolbox buttons with 'command: [ "some/module" ]'
  * definitions.  The map/reduce incantation squashes the array of arrays to a
  * single array.
  */
 try {
-  const { ToolboxButtons } = require("devtools/client/framework/toolbox");
+  const { ToolboxButtons } = require("devtools/client/definitions");
   exports.devtoolsButtonModules = ToolboxButtons.map(def => def.commands || [])
                                      .reduce((prev, curr) => prev.concat(curr), []);
-} catch(e) {
-  // "devtools/framework/toolbox" is only accessible from Firefox
+} catch (e) {
+  // "devtools/client/definitions" is only accessible from Firefox
   exports.devtoolsButtonModules = [];
 }
 
 /**
  * Add modules to a system for use in a content process (but don't call load)
  */
 exports.addAllItemsByModule = function(system) {
   system.addItemsByModule(exports.baseModules, { delayedLoad: true });