Bug 1245654 - Make the inspector shortcut start the pick mode again; r=bgrins draft
authorPatrick Brosset <pbrosset@mozilla.com>
Thu, 18 Feb 2016 11:51:12 +0100
changeset 331848 c65c314c0195205a062c6d7260a6e001044eea0b
parent 331847 d9445561d245533d4165c9f32d971ab0361cfcb9
child 514472 ebc4c3b8aa1acb139162b9d4e0348a469276a50b
push id11085
push userpbrosset@mozilla.com
push dateThu, 18 Feb 2016 10:54:08 +0000
reviewersbgrins
bugs1245654
milestone47.0a1
Bug 1245654 - Make the inspector shortcut start the pick mode again; r=bgrins MozReview-Commit-ID: 9qImivhKhKf
devtools/client/definitions.js
devtools/client/framework/test/browser_keybindings_01.js
devtools/server/actors/highlighters.js
--- a/devtools/client/definitions.js
+++ b/devtools/client/definitions.js
@@ -98,16 +98,19 @@ Tools.inspector = {
   inMenu: true,
   commands: [
     "devtools/client/responsivedesign/resize-commands",
     "devtools/client/inspector/inspector-commands",
     "devtools/client/eyedropper/commands.js"
   ],
 
   preventClosingOnKey: true,
+  onkey: function(panel, toolbox) {
+    toolbox.highlighterUtils.togglePicker();
+  },
 
   isTargetSupported: function(target) {
     return target.hasActor("inspector");
   },
 
   build: function(iframeWindow, toolbox) {
     return new InspectorPanel(iframeWindow, toolbox);
   }
--- a/devtools/client/framework/test/browser_keybindings_01.js
+++ b/devtools/client/framework/test/browser_keybindings_01.js
@@ -55,35 +55,38 @@ function test()
 
   function setupKeyBindingsTest()
   {
     for (let win of gDevToolsBrowser._trackedBrowserWindows) {
       buildDevtoolsKeysetMap(win.document.getElementById("devtoolsKeyset"));
     }
 
     gDevTools.once("toolbox-ready", (e, toolbox) => {
-      // The inspector is already selected at this point, but we wait
-      // for the signal here to avoid confusing ourselves when we wait
-      // for the next select-tool-command signal.
-      gDevTools.once("select-tool-command", () => {
-        inspectorShouldBeSelected(toolbox.getCurrentPanel(), toolbox);
-      });
+      inspectorShouldBeOpenAndHighlighting(toolbox.getCurrentPanel(), toolbox);
     });
 
     keysetMap.inspector.synthesizeKey();
   }
 
-  function inspectorShouldBeSelected(aInspector, aToolbox)
+  function inspectorShouldBeOpenAndHighlighting(aInspector, aToolbox)
   {
     is (aToolbox.currentToolId, "inspector", "Correct tool has been loaded");
 
-    gDevTools.once("select-tool-command", (x, toolId) => {
-      webconsoleShouldBeSelected(aToolbox);
+    aToolbox.once("picker-started", () => {
+      ok(true, "picker-started event received, highlighter started");
+      keysetMap.inspector.synthesizeKey();
+
+      aToolbox.once("picker-stopped", () => {
+        ok(true, "picker-stopped event received, highlighter stopped");
+        gDevTools.once("select-tool-command", () => {
+          webconsoleShouldBeSelected(aToolbox);
+        });
+        keysetMap.webconsole.synthesizeKey();
+      });
     });
-    keysetMap.webconsole.synthesizeKey();
   }
 
   function webconsoleShouldBeSelected(aToolbox)
   {
       is (aToolbox.currentToolId, "webconsole", "webconsole should be selected.");
 
       gDevTools.once("select-tool-command", () => {
         jsdebuggerShouldBeSelected(aToolbox);
--- a/devtools/server/actors/highlighters.js
+++ b/devtools/server/actors/highlighters.js
@@ -349,17 +349,16 @@ var HighlighterActor = exports.Highlight
       }
 
       // Store currently attached element
       this._currentNode = this._walker.attachElement(currentNode);
       this._highlighter.show(this._currentNode.node.rawNode);
       events.emit(this._walker, "picker-node-hovered", this._currentNode);
     };
 
-    this._tabActor.window.focus();
     this._startPickerListeners();
 
     return null;
   }),
 
   _findAndAttachElement: function(event) {
     // originalTarget allows access to the "real" element before any retargeting
     // is applied, such as in the case of XBL anonymous elements.  See also