Bug 1198339 - Bind F1 key to open the settings when the toolbox is focused;r=jryans
authorBrian Grinstead <bgrinstead@mozilla.com>
Tue, 01 Sep 2015 09:34:41 -0700
changeset 260378 20da43d2f599275b816181d7723f599b2af562fe
parent 260377 995d539b9a2db8c195b31de5e513e84e21116939
child 260379 375ec989b33a7858dd5f271a28ee98baa54e528e
push id29308
push userryanvm@gmail.com
push dateWed, 02 Sep 2015 01:15:13 +0000
treeherdermozilla-central@fb720c90eb49 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1198339
milestone43.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 1198339 - Bind F1 key to open the settings when the toolbox is focused;r=jryans
browser/devtools/framework/test/browser_toolbox_options.js
browser/devtools/framework/toolbox.js
browser/devtools/framework/toolbox.xul
browser/devtools/styleinspector/computed-view.js
--- a/browser/devtools/framework/test/browser_toolbox_options.js
+++ b/browser/devtools/framework/test/browser_toolbox_options.js
@@ -45,21 +45,25 @@ function* testSelectTool() {
   toolbox.selectTool("options");
   yield onceSelected;
   ok(true, "Toolbox selected via selectTool method");
 }
 
 function* testOptionsShortcut() {
   info ("Selecting another tool, then reselecting options panel with keyboard.");
 
-  yield toolbox.selectTool("webconsole")
-         .then(() => synthesizeKeyFromKeyTag("toolbox-options-key", doc))
-         .then(() => {
-           ok(true, "Toolbox selected via shortcut key");
-         });
+  yield toolbox.selectTool("webconsole");
+  is(toolbox.currentToolId, "webconsole", "webconsole is selected");
+  synthesizeKeyFromKeyTag("toolbox-options-key", doc);
+  is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (1)");
+
+  yield toolbox.selectTool("webconsole");
+  is(toolbox.currentToolId, "webconsole", "webconsole is selected");
+  synthesizeKeyFromKeyTag("toolbox-options-key2", doc);
+  is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (2)");
 }
 
 function* testOptions() {
   let tool = toolbox.getPanel("options");
   panelWin = tool.panelWin;
   let prefNodes = tool.panelDoc.querySelectorAll("checkbox[data-pref]");
 
   // Store modified pref names so that they can be cleared on error.
--- a/browser/devtools/framework/toolbox.js
+++ b/browser/devtools/framework/toolbox.js
@@ -452,20 +452,21 @@ Toolbox.prototype = {
         break;
       case "devtools.serviceWorkers.testing.enabled":
         this._applyServiceWorkersTestingSettings();
         break;
     }
   },
 
   _buildOptions: function() {
+    let selectOptions = () => { this.selectTool("options"); };
     let key = this.doc.getElementById("toolbox-options-key");
-    key.addEventListener("command", () => {
-      this.selectTool("options");
-    }, true);
+    key.addEventListener("command", selectOptions, true);
+    let key2 = this.doc.getElementById("toolbox-options-key2");
+    key2.addEventListener("command", selectOptions, true);
   },
 
   _splitConsoleOnKeypress: function(e) {
     if (e.keyCode === e.DOM_VK_ESCAPE) {
       this.toggleSplitConsole();
       // If the debugger is paused, don't let the ESC key stop any pending
       // navigation.
       let jsdebugger = this.getPanel("jsdebugger");
--- a/browser/devtools/framework/toolbox.xul
+++ b/browser/devtools/framework/toolbox.xul
@@ -4,19 +4,21 @@
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 <?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
 <?xml-stylesheet href="chrome://browser/skin/devtools/common.css" type="text/css"?>
 
 <?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
 
 <!DOCTYPE window [
 <!ENTITY % toolboxDTD SYSTEM "chrome://browser/locale/devtools/toolbox.dtd" >
- %toolboxDTD;
+%toolboxDTD;
 <!ENTITY % editMenuStrings SYSTEM "chrome://global/locale/editMenuOverlay.dtd">
 %editMenuStrings;
+<!ENTITY % globalKeysDTD SYSTEM "chrome://global/locale/globalKeys.dtd">
+%globalKeysDTD;
 ]>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script type="application/javascript;version=1.8"
           src="chrome://browser/content/devtools/theme-switching.js"/>
   <script type="application/javascript"
           src="chrome://global/content/viewSourceUtils.js"/>
@@ -25,16 +27,19 @@
 
   <commandset id="editMenuCommands"/>
   <keyset id="editMenuKeys"/>
   <keyset id="toolbox-keyset">
     <key id="toolbox-options-key"
          key="&toolboxOptionsButton.key;"
          oncommand="void(0);"
          modifiers="shift, accel"/>
+    <key id="toolbox-options-key2"
+         keycode="&openHelp.commandkey;"
+         oncommand="void(0);"/>
     <key id="toolbox-next-tool-key"
          key="&toolboxNextTool.key;"
          oncommand="void(0);"
          modifiers="accel"/>
     <key id="toolbox-previous-tool-key"
          key="&toolboxPreviousTool.key;"
          oncommand="void(0);"
          modifiers="accel"/>
--- a/browser/devtools/styleinspector/computed-view.js
+++ b/browser/devtools/styleinspector/computed-view.js
@@ -950,16 +950,17 @@ PropertyView.prototype = {
     this.element.addEventListener("dblclick", this.onMatchedToggle, false);
 
     // Make it keyboard navigable
     this.element.setAttribute("tabindex", "0");
     this.onKeyDown = (event) => {
       let keyEvent = Ci.nsIDOMKeyEvent;
       if (event.keyCode === keyEvent.DOM_VK_F1) {
         this.mdnLinkClick();
+        event.preventDefault();
       }
       if (event.keyCode === keyEvent.DOM_VK_RETURN ||
         event.keyCode === keyEvent.DOM_VK_SPACE) {
         this.onMatchedToggle(event);
       }
     };
     this.element.addEventListener("keydown", this.onKeyDown, false);