Bug 924614 - Fix duplicate Scratchpad menu items in Web Developer menu. r=mratcliffe
authorBrandon Benvie <bbenvie@mozilla.com>
Wed, 09 Oct 2013 11:47:00 -0700
changeset 164123 7bae66ad4253aefac5ce9d70684aa165bbf0423c
parent 164122 c96a2d66725c2395e18a8b149de57f0593668480
child 164124 61f2d082139d6f21bcea3558fffc6909b7d154f6
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmratcliffe
bugs924614
milestone27.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 924614 - Fix duplicate Scratchpad menu items in Web Developer menu. r=mratcliffe
browser/devtools/framework/gDevTools.jsm
browser/devtools/framework/test/browser_toolbox_dynamic_registration.js
browser/devtools/main.js
--- a/browser/devtools/framework/gDevTools.jsm
+++ b/browser/devtools/framework/gDevTools.jsm
@@ -540,33 +540,33 @@ let gDevToolsBrowser = {
   /**
    * Add the menuitem for a tool to all open browser windows.
    *
    * @param {object} toolDefinition
    *        properties of the tool to add
    */
   _addToolToWindows: function DT_addToolToWindows(toolDefinition) {
     // No menu item or global shortcut is required for options panel.
-    if (toolDefinition.id == "options") {
+    if (!toolDefinition.inMenu) {
       return;
     }
 
     // Skip if the tool is disabled.
     try {
       if (!Services.prefs.getBoolPref(toolDefinition.visibilityswitch)) {
         return;
       }
     } catch(e) {}
 
     // We need to insert the new tool in the right place, which means knowing
     // the tool that comes before the tool that we're trying to add
     let allDefs = gDevTools.getToolDefinitionArray();
     let prevDef;
     for (let def of allDefs) {
-      if (def.id == "options") {
+      if (!def.inMenu) {
         continue;
       }
       if (def === toolDefinition) {
         break;
       }
       prevDef = def;
     }
 
@@ -625,17 +625,17 @@ let gDevToolsBrowser = {
   _addAllToolsToMenu: function DT_addAllToolsToMenu(doc) {
     let fragCommands = doc.createDocumentFragment();
     let fragKeys = doc.createDocumentFragment();
     let fragBroadcasters = doc.createDocumentFragment();
     let fragAppMenuItems = doc.createDocumentFragment();
     let fragMenuItems = doc.createDocumentFragment();
 
     for (let toolDefinition of gDevTools.getToolDefinitionArray()) {
-      if (toolDefinition.id == "options") {
+      if (!toolDefinition.inMenu) {
         continue;
       }
 
       let elements = gDevToolsBrowser._createToolMenuElements(toolDefinition, doc);
 
       if (!elements) {
         return;
       }
--- a/browser/devtools/framework/test/browser_toolbox_dynamic_registration.js
+++ b/browser/devtools/framework/test/browser_toolbox_dynamic_registration.js
@@ -22,16 +22,17 @@ function test()
 function testRegister(aToolbox)
 {
   toolbox = aToolbox
   gDevTools.once("tool-registered", toolRegistered);
 
   gDevTools.registerTool({
     id: "test-tool",
     label: "Test Tool",
+    inMenu: true,
     isTargetSupported: function() true,
     build: function() {}
   });
 }
 
 function toolRegistered(event, toolId)
 {
   is(toolId, "test-tool", "tool-registered event handler sent tool id");
--- a/browser/devtools/main.js
+++ b/browser/devtools/main.js
@@ -54,16 +54,17 @@ exports.Tools = Tools;
 
 // Definitions
 Tools.options = {
   id: "options",
   ordinal: 0,
   url: "chrome://browser/content/devtools/framework/toolbox-options.xul",
   icon: "chrome://browser/skin/devtools/tool-options.png",
   tooltip: l10n("optionsButton.tooltip", toolboxStrings),
+  inMenu: false,
   isTargetSupported: function(target) {
     return true;
   },
   build: function(iframeWindow, toolbox) {
     let panel = new OptionsPanel(iframeWindow, toolbox);
     return panel.open();
   }
 }
@@ -74,16 +75,17 @@ Tools.webConsole = {
   accesskey: l10n("webConsoleCmd.accesskey", webConsoleStrings),
   modifiers: Services.appinfo.OS == "Darwin" ? "accel,alt" : "accel,shift",
   ordinal: 1,
   icon: "chrome://browser/skin/devtools/tool-webconsole.png",
   url: "chrome://browser/content/devtools/webconsole.xul",
   label: l10n("ToolboxTabWebconsole.label", webConsoleStrings),
   menuLabel: l10n("MenuWebconsole.label", webConsoleStrings),
   tooltip: l10n("ToolboxWebconsole.tooltip", webConsoleStrings),
+  inMenu: true,
 
   isTargetSupported: function(target) {
     return true;
   },
   build: function(iframeWindow, toolbox) {
     let panel = new WebConsolePanel(iframeWindow, toolbox);
     return panel.open();
   }
@@ -94,16 +96,17 @@ Tools.inspector = {
   accesskey: l10n("inspector.accesskey", inspectorStrings),
   key: l10n("inspector.commandkey", inspectorStrings),
   ordinal: 2,
   modifiers: osString == "Darwin" ? "accel,alt" : "accel,shift",
   icon: "chrome://browser/skin/devtools/tool-inspector.png",
   url: "chrome://browser/content/devtools/inspector/inspector.xul",
   label: l10n("inspector.label", inspectorStrings),
   tooltip: l10n("inspector.tooltip", inspectorStrings),
+  inMenu: true,
 
   preventClosingOnKey: true,
   onkey: function(panel) {
     if (panel.highlighter) {
       panel.highlighter.toggleLockState();
     }
   },
 
@@ -124,16 +127,17 @@ Tools.jsdebugger = {
   modifiers: osString == "Darwin" ? "accel,alt" : "accel,shift",
   ordinal: 3,
   visibilityswitch: "devtools.debugger.enabled",
   icon: "chrome://browser/skin/devtools/tool-debugger.png",
   highlightedicon: "chrome://browser/skin/devtools/tool-debugger-paused.png",
   url: "chrome://browser/content/devtools/debugger.xul",
   label: l10n("ToolboxDebugger.label", debuggerStrings),
   tooltip: l10n("ToolboxDebugger.tooltip", debuggerStrings),
+  inMenu: true,
 
   isTargetSupported: function(target) {
     return true;
   },
 
   build: function(iframeWindow, toolbox) {
     let panel = new DebuggerPanel(iframeWindow, toolbox);
     return panel.open();
@@ -145,16 +149,17 @@ Tools.styleEditor = {
   key: l10n("open.commandkey", styleEditorStrings),
   ordinal: 4,
   accesskey: l10n("open.accesskey", styleEditorStrings),
   modifiers: "shift",
   icon: "chrome://browser/skin/devtools/tool-styleeditor.png",
   url: "chrome://browser/content/devtools/styleeditor.xul",
   label: l10n("ToolboxStyleEditor.label", styleEditorStrings),
   tooltip: l10n("ToolboxStyleEditor.tooltip2", styleEditorStrings),
+  inMenu: true,
 
   isTargetSupported: function(target) {
     return true;
   },
 
   build: function(iframeWindow, toolbox) {
     let panel = new StyleEditorPanel(iframeWindow, toolbox);
     return panel.open();
@@ -167,16 +172,17 @@ Tools.jsprofiler = {
   key: l10n("profiler2.commandkey", profilerStrings),
   ordinal: 5,
   modifiers: "shift",
   visibilityswitch: "devtools.profiler.enabled",
   icon: "chrome://browser/skin/devtools/tool-profiler.png",
   url: "chrome://browser/content/devtools/profiler.xul",
   label: l10n("profiler.label", profilerStrings),
   tooltip: l10n("profiler.tooltip2", profilerStrings),
+  inMenu: true,
 
   isTargetSupported: function (target) {
     return true;
   },
 
   build: function (frame, target) {
     let panel = new ProfilerPanel(frame, target);
     return panel.open();
@@ -189,16 +195,17 @@ Tools.netMonitor = {
   key: l10n("netmonitor.commandkey", netMonitorStrings),
   ordinal: 6,
   modifiers: osString == "Darwin" ? "accel,alt" : "accel,shift",
   visibilityswitch: "devtools.netmonitor.enabled",
   icon: "chrome://browser/skin/devtools/tool-network.png",
   url: "chrome://browser/content/devtools/netmonitor.xul",
   label: l10n("netmonitor.label", netMonitorStrings),
   tooltip: l10n("netmonitor.tooltip", netMonitorStrings),
+  inMenu: true,
 
   isTargetSupported: function(target) {
     return !target.isApp;
   },
 
   build: function(iframeWindow, toolbox) {
     let panel = new NetMonitorPanel(iframeWindow, toolbox);
     return panel.open();
@@ -208,16 +215,17 @@ Tools.netMonitor = {
 Tools.scratchpad = {
   id: "scratchpad",
   ordinal: 7,
   visibilityswitch: "devtools.scratchpad.enabled",
   icon: "chrome://browser/skin/devtools/tool-scratchpad.png",
   url: "chrome://browser/content/devtools/scratchpad.xul",
   label: l10n("scratchpad.label", scratchpadStrings),
   tooltip: l10n("scratchpad.tooltip", scratchpadStrings),
+  inMenu: false,
 
   isTargetSupported: function(target) {
     return target.isRemote;
   },
 
   build: function(iframeWindow, toolbox) {
     let panel = new ScratchpadPanel(iframeWindow, toolbox);
     return panel.open();