Bug 1212689 - Extract ToolboxButtons to save GCLI from loading toolbox.js. r=ochameau
MozReview-Commit-ID: DZcvEa9v0vS
--- 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,31 +77,31 @@ 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
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
exports.devtoolsButtonModules = [];
}
/**