Bug 1337510 - Remove dead code related to gcli command buttons. r=jryans
MozReview-Commit-ID: 8mF3u2hvjnu
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -29,18 +29,16 @@ var { DOMHelpers } = require("resource:/
const { KeyCodes } = require("devtools/client/shared/keycodes");
const { BrowserLoader } =
Cu.import("resource://devtools/client/shared/browser-loader.js", {});
const {LocalizationHelper} = require("devtools/shared/l10n");
const L10N = new LocalizationHelper("devtools/client/locales/toolbox.properties");
-loader.lazyRequireGetter(this, "CommandUtils",
- "devtools/client/shared/developer-toolbar", true);
loader.lazyRequireGetter(this, "getHighlighterUtils",
"devtools/client/framework/toolbox-highlighter-utils", true);
loader.lazyRequireGetter(this, "Selection",
"devtools/client/framework/selection", true);
loader.lazyRequireGetter(this, "InspectorFront",
"devtools/shared/fronts/inspector", true);
loader.lazyRequireGetter(this, "flags",
"devtools/shared/flags");
@@ -1200,25 +1198,16 @@ Toolbox.prototype = {
if (this.target.activeTab) {
this.target.activeTab.reconfigure({
"serviceWorkersTestingEnabled": serviceWorkersTestingEnabled
});
}
},
/**
- * Get the toolbar spec for toolbox
- */
- getToolbarSpec: function () {
- let spec = CommandUtils.getCommandbarSpec("devtools.toolbox.toolbarSpec");
-
- return spec;
- },
-
- /**
* Return all toolbox buttons (command buttons, plus any others that were
* added manually).
/**
* Update the visibility of the buttons.
*/
updateToolboxButtonsVisibility() {
this.toolbarButtons.forEach(button => {
--- a/devtools/client/shared/developer-toolbar.js
+++ b/devtools/client/shared/developer-toolbar.js
@@ -74,109 +74,16 @@ var CommandUtils = {
* Destroy the remote side of the requisition as well as the local side
*/
destroyRequisition: function (requisition, target) {
requisition.destroy();
gcliInit.releaseSystem(target);
},
/**
- * Read a toolbarSpec from preferences
- * @param pref The name of the preference to read
- */
- getCommandbarSpec: function (pref) {
- let value = prefBranch.getComplexValue(pref, Ci.nsISupportsString).data;
- return JSON.parse(value);
- },
-
- /**
- * Create a list of props for React components that manage the state of the buttons.
- *
- * @param {Array} toolbarSpec - An array of strings each of which is a GCLI command.
- * @param {Object} target
- * @param {Object} document - Used to listen to unload event of the window.
- * @param {Requisition} requisition
- * @param {Function} createButtonState - A function that provides a common interface
- * to create a button for the toolbox.
- *
- * @return {Array} List of ToolboxButton objects..
- *
- * Warning: this method uses the unload event of the window that owns the
- * buttons that are of type checkbox. this means that we don't properly
- * unregister event handlers until the window is destroyed.
- */
- createCommandButtons: function (toolbarSpec, target, document, requisition,
- createButtonState) {
- return util.promiseEach(toolbarSpec, typed => {
- // Ask GCLI to parse the typed string (doesn't execute it)
- return requisition.update(typed).then(() => {
- // Ignore invalid commands
- let command = requisition.commandAssignment.value;
- if (command == null) {
- throw new Error("No command '" + typed + "'");
- }
- if (!command.buttonId) {
- throw new Error("Attempting to add a button to the toolbar, and the command " +
- "did not have an id.");
- }
- // Create the ToolboxButton.
- let button = createButtonState({
- id: command.buttonId,
- className: command.buttonClass,
- description: command.tooltipText || command.description,
- onClick: requisition.updateExec.bind(requisition, typed)
- });
-
- // Allow the command button to be toggleable.
- if (command.state) {
- /**
- * The onChange event should be called with an event object that
- * contains a target property which specifies which target the event
- * applies to. For legacy reasons the event object can also contain
- * a tab property.
- */
- const onChange = (eventName, ev) => {
- if (ev.target == target || ev.tab == target.tab) {
- let updateChecked = (checked) => {
- // This will emit a ToolboxButton update event.
- button.isChecked = checked;
- };
-
- // isChecked would normally be synchronous. An annoying quirk
- // of the 'csscoverage toggle' command forces us to accept a
- // promise here, but doing Promise.resolve(reply).then(...) here
- // makes this async for everyone, which breaks some tests so we
- // treat non-promise replies separately to keep then synchronous.
- let reply = command.state.isChecked(target);
- if (typeof reply.then == "function") {
- reply.then(updateChecked, console.error);
- } else {
- updateChecked(reply);
- }
- }
- };
-
- command.state.onChange(target, onChange);
- onChange("", { target: target });
-
- document.defaultView.addEventListener("unload", function (event) {
- if (command.state.offChange) {
- command.state.offChange(target, onChange);
- }
- }, { once: true });
- }
-
- requisition.clear();
-
- return button;
- });
- });
- },
-
- /**
* A helper function to create the environment object that is passed to
* GCLI commands.
* @param targetContainer An object containing a 'target' property which
* reflects the current debug target
*/
createEnvironment: function (container, targetProperty = "target") {
if (!container[targetProperty].toString ||
!/TabTarget/.test(container[targetProperty].toString())) {