Bug 1508656 - migrate startPicker and stopPicker to nodePicker; r=ochameau
authoryulia <ystartsev@mozilla.com>
Tue, 18 Dec 2018 08:46:14 +0000
changeset 509354 cb8e0fb71422c6f670ce8ae756bf276b5e22a6a7
parent 509353 c1ec7884d2cc37f42f38776526c5828147505bae
child 509355 a20625c5026f87156401153a08a285f4d4ea31ae
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1508656
milestone66.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 1508656 - migrate startPicker and stopPicker to nodePicker; r=ochameau Depends on D12122 Differential Revision: https://phabricator.services.mozilla.com/D12126
devtools/client/framework/test/browser_keybindings_01.js
devtools/client/inspector/animation/animation.js
devtools/client/inspector/boxmodel/box-model.js
devtools/client/inspector/rules/test/browser_rules_colorpicker-hides-element-picker.js
devtools/client/inspector/test/browser_inspector_highlighter-03.js
devtools/client/inspector/test/browser_inspector_highlighter-iframes_01.js
devtools/client/inspector/test/browser_inspector_highlighter-keybinding_01.js
devtools/client/inspector/test/browser_inspector_highlighter-keybinding_02.js
devtools/client/inspector/test/browser_inspector_highlighter-keybinding_03.js
devtools/client/inspector/test/browser_inspector_highlighter-keybinding_04.js
devtools/client/inspector/test/browser_inspector_iframe-navigation.js
devtools/client/inspector/test/browser_inspector_picker-stop-on-tool-change.js
devtools/client/inspector/test/browser_inspector_switch-to-inspector-on-pick.js
devtools/client/inspector/test/head.js
devtools/client/webconsole/test/mochitest/head.js
--- a/devtools/client/framework/test/browser_keybindings_01.js
+++ b/devtools/client/framework/test/browser_keybindings_01.js
@@ -93,22 +93,22 @@ add_task(async function() {
     await inspectorShouldBeOpenAndHighlighting(inspectorKeys[1]);
   }
 
   gBrowser.removeCurrentTab();
 
   async function inspectorShouldBeOpenAndHighlighting(inspector) {
     is(toolbox.currentToolId, "inspector", "Correct tool has been loaded");
 
-    await toolbox.once("picker-started");
+    await toolbox.inspector.nodePicker.once("picker-started");
 
     ok(true, "picker-started event received, highlighter started");
     inspector.synthesizeKey();
 
-    await toolbox.once("picker-stopped");
+    await toolbox.inspector.nodePicker.once("picker-stopped");
     ok(true, "picker-stopped event received, highlighter stopped");
   }
 
   function webconsoleShouldBeSelected() {
     is(toolbox.currentToolId, "webconsole", "webconsole should be selected.");
   }
 
   function netmonitorShouldBeSelected() {
--- a/devtools/client/inspector/animation/animation.js
+++ b/devtools/client/inspector/animation/animation.js
@@ -136,18 +136,18 @@ class AnimationInspector {
           simulateAnimationForKeyframesProgressBar,
           toggleElementPicker,
         }
       )
     );
     this.provider = provider;
 
     this.inspector.sidebar.on("select", this.onSidebarSelectionChanged);
-    this.inspector.toolbox.on("picker-started", this.onElementPickerStarted);
-    this.inspector.toolbox.on("picker-stopped", this.onElementPickerStopped);
+    this.inspector.inspector.nodePicker.on("picker-started", this.onElementPickerStarted);
+    this.inspector.inspector.nodePicker.on("picker-stopped", this.onElementPickerStopped);
     this.inspector.toolbox.on("select", this.onSidebarSelectionChanged);
   }
 
   _getAnimationsFront() {
     if (this.animationsFrontPromise) {
       return this.animationsFrontPromise;
     }
     this.animationsFrontPromise = new Promise(async resolve => {
@@ -160,18 +160,22 @@ class AnimationInspector {
   }
 
   destroy() {
     this.setAnimationStateChangedListenerEnabled(false);
     this.inspector.off("new-root", this.onNavigate);
     this.inspector.selection.off("new-node-front", this.update);
     this.inspector.sidebar.off("select", this.onSidebarSelectionChanged);
     this.inspector.toolbox.off("inspector-sidebar-resized", this.onSidebarResized);
-    this.inspector.toolbox.off("picker-started", this.onElementPickerStarted);
-    this.inspector.toolbox.off("picker-stopped", this.onElementPickerStopped);
+    this.inspector.inspector.nodePicker.off(
+      "picker-started", this.onElementPickerStarted
+    );
+    this.inspector.inspector.nodePicker.off(
+      "picker-stopped", this.onElementPickerStopped
+    );
     this.inspector.toolbox.off("select", this.onSidebarSelectionChanged);
 
     this.animationsFrontPromise.then(front => {
       front.off("mutations", this.onAnimationsMutation);
     });
 
     if (this.simulatedAnimation) {
       this.simulatedAnimation.cancel();
--- a/devtools/client/inspector/boxmodel/box-model.js
+++ b/devtools/client/inspector/boxmodel/box-model.js
@@ -202,22 +202,22 @@ BoxModel.prototype = {
     this.inspector.highlighter.unhighlight();
   },
 
   /**
    * Hides the geometry editor and updates the box moodel store with the new
    * geometry editor enabled state.
    */
   onHideGeometryEditor() {
-    const { markup, selection, toolbox } = this.inspector;
+    const { markup, selection, inspector } = this.inspector;
 
     this.highlighters.hideGeometryEditor();
     this.store.dispatch(updateGeometryEditorEnabled(false));
 
-    toolbox.off("picker-started", this.onHideGeometryEditor);
+    inspector.nodePicker.off("picker-started", this.onHideGeometryEditor);
     selection.off("new-node-front", this.onHideGeometryEditor);
     markup.off("leave", this.onMarkupViewLeave);
     markup.off("node-hover", this.onMarkupViewNodeHover);
   },
 
   /**
    * Handler function that re-shows the geometry editor for an element that already
    * had the geometry editor enabled. This handler function is called on a "leave" event
@@ -360,33 +360,33 @@ BoxModel.prototype = {
     this.updateBoxModel();
   },
 
   /**
    * Toggles on/off the geometry editor for the current element when the geometry editor
    * toggle button is clicked.
    */
   onToggleGeometryEditor() {
-    const { markup, selection, toolbox } = this.inspector;
+    const { markup, selection, inspector } = this.inspector;
     const nodeFront = this.inspector.selection.nodeFront;
     const state = this.store.getState();
     const enabled = !state.boxModel.geometryEditorEnabled;
 
     this.highlighters.toggleGeometryHighlighter(nodeFront);
     this.store.dispatch(updateGeometryEditorEnabled(enabled));
 
     if (enabled) {
       // Hide completely the geometry editor if the picker is clicked or a new node front
-      toolbox.on("picker-started", this.onHideGeometryEditor);
+      inspector.nodePicker.on("picker-started", this.onHideGeometryEditor);
       selection.on("new-node-front", this.onHideGeometryEditor);
       // Temporary hide the geometry editor
       markup.on("leave", this.onMarkupViewLeave);
       markup.on("node-hover", this.onMarkupViewNodeHover);
     } else {
-      toolbox.off("picker-started", this.onHideGeometryEditor);
+      inspector.nodePicker.off("picker-started", this.onHideGeometryEditor);
       selection.off("new-node-front", this.onHideGeometryEditor);
       markup.off("leave", this.onMarkupViewLeave);
       markup.off("node-hover", this.onMarkupViewNodeHover);
     }
   },
 
 };
 
--- a/devtools/client/inspector/rules/test/browser_rules_colorpicker-hides-element-picker.js
+++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-hides-element-picker.js
@@ -7,17 +7,17 @@
 // if the picker is already selected.
 
 const TEST_URI = `<style>body{background:red}</style>`;
 
 add_task(async function() {
   await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
 
   const {view, toolbox} = await openRuleView();
-  const pickerStopped = toolbox.once("picker-stopped");
+  const pickerStopped = toolbox.inspector.nodePicker.once("picker-stopped");
 
   await startPicker(toolbox);
 
   info("Get the background property from the rule-view");
   const property = getRuleViewProperty(view, "body", "background");
   const swatch = property.valueSpan.querySelector(".ruleview-colorswatch");
   ok(swatch, "Color swatch is displayed for the background property");
 
--- a/devtools/client/inspector/test/browser_inspector_highlighter-03.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-03.js
@@ -55,16 +55,16 @@ add_task(async function() {
   info("Moving mouse over iframe body");
   await moveMouseOver("iframe", 40, 40);
 
   ok((await testActor.assertHighlightedNode(iframeBodySelector)),
      "highlighter shows the right node");
   await testActor.isNodeCorrectlyHighlighted(iframeBodySelector, is);
 
   info("Waiting for the element picker to deactivate.");
-  await inspector.toolbox.highlighterUtils.stopPicker();
+  await inspector.inspector.nodePicker.stop();
 
   function moveMouseOver(selector, x, y) {
     info("Waiting for element " + selector + " to be highlighted");
     testActor.synthesizeMouse({selector, x, y, options: {type: "mousemove"}});
     return inspector.toolbox.once("picker-node-hovered");
   }
 });
--- a/devtools/client/inspector/test/browser_inspector_highlighter-iframes_01.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-iframes_01.js
@@ -46,17 +46,17 @@ add_task(async function() {
   const innerFrameDivFront = await getNodeFrontInFrame("div", innerFrameFront,
                                                      inspector);
   await selectNode(innerFrameDivFront, inspector);
 
   is(inspector.breadcrumbs.nodeHierarchy.length, 9,
      "Breadcrumbs have 9 items.");
 
   info("Waiting for element picker to deactivate.");
-  await inspector.toolbox.highlighterUtils.stopPicker();
+  await inspector.inspector.nodePicker.stop();
 
   function moveMouseOver(selector) {
     info("Waiting for element " + selector + " to be highlighted");
     testActor.synthesizeMouse({
       selector: selector,
       options: {type: "mousemove"},
       center: true,
     }).then(() => inspector.toolbox.once("picker-node-hovered"));
--- a/devtools/client/inspector/test/browser_inspector_highlighter-keybinding_01.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-keybinding_01.js
@@ -39,17 +39,17 @@ add_task(async function() {
   await doKeyHover({key: "VK_LEFT", options: {}});
   await doKeyHover({key: "VK_LEFT", options: {}});
   ok((await testActor.assertHighlightedNode("#simple-div1")),
      "The highlighter shows #simple-div1. OK.");
 
   info("First child selection test Passed.");
 
   info("Stopping the picker");
-  await toolbox.highlighterUtils.stopPicker();
+  await toolbox.inspector.nodePicker.stop();
 
   function doKeyHover(args) {
     info("Key pressed. Waiting for element to be highlighted/hovered");
     testActor.synthesizeKey(args);
     return inspector.toolbox.once("picker-node-hovered");
   }
 
   function moveMouseOver(selector) {
--- a/devtools/client/inspector/test/browser_inspector_highlighter-keybinding_02.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-keybinding_02.js
@@ -35,17 +35,17 @@ add_task(async function() {
 
   await doKeyHover({key: "VK_RIGHT", options: {}});
   ok((await testActor.assertHighlightedNode("#simple-div2")),
      "The highlighter shows #simple-div2. OK.");
 
   info("Previously chosen child is remembered. Passed.");
 
   info("Stopping the picker");
-  await toolbox.highlighterUtils.stopPicker();
+  await toolbox.inspector.nodePicker.stop();
 
   function doKeyHover(args) {
     info("Key pressed. Waiting for element to be highlighted/hovered");
     const onHighlighterReady = toolbox.once("highlighter-ready");
     const onPickerNodeHovered = inspector.toolbox.once("picker-node-hovered");
     testActor.synthesizeKey(args);
     return promise.all([onHighlighterReady, onPickerNodeHovered]);
   }
--- a/devtools/client/inspector/test/browser_inspector_highlighter-keybinding_03.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-keybinding_03.js
@@ -43,24 +43,24 @@ add_task(async function() {
      "The #another DIV is still selected. Passed.");
 
   function doKeyPick(args) {
     info("Key pressed. Waiting for element to be picked");
     testActor.synthesizeKey(args);
     return promise.all([
       inspector.selection.once("new-node-front"),
       inspector.once("inspector-updated"),
-      inspector.toolbox.once("picker-stopped"),
+      inspector.inspector.nodePicker.once("picker-stopped"),
     ]);
   }
 
   function doKeyStop(args) {
     info("Key pressed. Waiting for picker to be canceled");
     testActor.synthesizeKey(args);
-    return inspector.toolbox.once("picker-stopped");
+    return inspector.inspector.nodePicker.once("picker-stopped");
   }
 
   function moveMouseOver(selector) {
     info("Waiting for element " + selector + " to be highlighted");
     const onHighlighterReady = toolbox.once("highlighter-ready");
     const onPickerNodeHovered = inspector.toolbox.once("picker-node-hovered");
     testActor.synthesizeMouse({
       options: {type: "mousemove"},
--- a/devtools/client/inspector/test/browser_inspector_highlighter-keybinding_04.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-keybinding_04.js
@@ -19,17 +19,17 @@ add_task(async function() {
   testActor.synthesizeMouse({
     options: {type: "mousemove"},
     center: true,
     selector: "div",
   });
   await onHover;
 
   info("Press escape and wait for the picker to stop");
-  const onPickerStopped = toolbox.once("picker-stopped");
+  const onPickerStopped = toolbox.inspector.nodePicker.once("picker-stopped");
   testActor.synthesizeKey({
     key: "VK_ESCAPE",
     options: {},
   });
   await onPickerStopped;
 
   info("Press escape again and wait for the split console to open");
   const onSplitConsole = toolbox.once("split-console");
--- a/devtools/client/inspector/test/browser_inspector_iframe-navigation.js
+++ b/devtools/client/inspector/test/browser_inspector_iframe-navigation.js
@@ -34,10 +34,10 @@ add_task(async function() {
 
   await testActor.reloadFrame("iframe");
   info("Frame reloaded twice.");
 
   isVisible = await testActor.isHighlighting();
   ok(isVisible, "Inspector is highlighting after iframe nav.");
 
   info("Stopping element picker.");
-  await toolbox.highlighterUtils.stopPicker();
+  await toolbox.inspector.nodePicker.stop();
 });
--- a/devtools/client/inspector/test/browser_inspector_picker-stop-on-tool-change.js
+++ b/devtools/client/inspector/test/browser_inspector_picker-stop-on-tool-change.js
@@ -7,17 +7,17 @@
 // Test that the highlighter's picker is stopped when a different tool is
 // selected
 
 const TEST_URI = "data:text/html;charset=UTF-8," +
   "testing the highlighter goes away on tool selection";
 
 add_task(async function() {
   const { toolbox } = await openInspectorForURL(TEST_URI);
-  const pickerStopped = toolbox.once("picker-stopped");
+  const pickerStopped = toolbox.inspector.nodePicker.once("picker-stopped");
 
   info("Starting the inspector picker");
   await startPicker(toolbox);
 
   info("Selecting another tool than the inspector in the toolbox");
   await toolbox.selectNextTool();
 
   info("Waiting for the picker-stopped event to be fired");
--- a/devtools/client/inspector/test/browser_inspector_switch-to-inspector-on-pick.js
+++ b/devtools/client/inspector/test/browser_inspector_switch-to-inspector-on-pick.js
@@ -62,17 +62,17 @@ add_task(async function() {
   ok(!snapshot.parent, "No events have been logged for the main process");
 
   const tab = await addTab(TEST_URI);
   const toolbox = await openToolbox(tab);
 
   await startPickerAndAssertSwitchToInspector(toolbox);
 
   info("Stoppping element picker.");
-  await toolbox.highlighterUtils.stopPicker();
+  await toolbox.inspector.nodePicker.stop();
 
   checkResults();
 });
 
 async function openToolbox(tab) {
   info("Opening webconsole.");
   const target = await TargetFactory.forTab(tab);
   return gDevTools.showToolbox(target, "webconsole");
--- a/devtools/client/inspector/test/head.js
+++ b/devtools/client/inspector/test/head.js
@@ -63,17 +63,17 @@ var navigateTo = async function(inspecto
 /**
  * Start the element picker and focus the content window.
  * @param {Toolbox} toolbox
  * @param {Boolean} skipFocus - Allow tests to bypass the focus event.
  */
 var startPicker = async function(toolbox, skipFocus) {
   info("Start the element picker");
   toolbox.win.focus();
-  await toolbox.highlighterUtils.startPicker();
+  await toolbox.inspector.nodePicker.start();
   if (!skipFocus) {
     // By default make sure the content window is focused since the picker may not focus
     // the content window by default.
     await ContentTask.spawn(gBrowser.selectedBrowser, null, async function() {
       content.focus();
     });
   }
 };
--- a/devtools/client/webconsole/test/mochitest/head.js
+++ b/devtools/client/webconsole/test/mochitest/head.js
@@ -958,23 +958,24 @@ function isReverseSearchInputFocused(hud
  *
  * @param {Object} toolbox
  * @param {Object} testActor: A test actor registered on the target. Needed to click on
  *                            the content element.
  * @param {String} selector: The selector for the node we want to select.
  */
 async function selectNodeWithPicker(toolbox, testActor, selector) {
   const inspector = toolbox.getPanel("inspector");
+  const inspectorFront = inspector.inspector;
 
-  const onPickerStarted = inspector.toolbox.once("picker-started");
-  inspector.toolbox.highlighterUtils.startPicker();
+  const onPickerStarted = inspectorFront.nodePicker.once("picker-started");
+  inspectorFront.nodePicker.start();
   await onPickerStarted;
 
   info(`Picker mode started, now clicking on "${selector}" to select that node`);
-  const onPickerStopped = toolbox.once("picker-stopped");
+  const onPickerStopped = inspectorFront.nodePicker.once("picker-stopped");
   const onInspectorUpdated = inspector.once("inspector-updated");
 
   testActor.synthesizeMouse({
     selector,
     center: true,
     options: {},
   });