Bug 1512086 - fix console highlighting and update test to fail if it doesnt; r=nchevobbe
authoryulia <ystartsev@mozilla.com>
Wed, 05 Dec 2018 22:02:36 +0000
changeset 505936 5ca5e911d32f
parent 505935 d932537fec3b
child 505945 f7895b06b742
child 505950 ddd8bdd2f05e
push id10301
push userarchaeopteryx@coole-files.de
push dateThu, 06 Dec 2018 16:36:14 +0000
treeherdermozilla-beta@7d2f3c71997c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnchevobbe
bugs1512086
milestone65.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 1512086 - fix console highlighting and update test to fail if it doesnt; r=nchevobbe Differential Revision: https://phabricator.services.mozilla.com/D13826
devtools/client/framework/target.js
devtools/client/webconsole/test/mochitest/browser_webconsole_nodes_highlight.js
devtools/client/webconsole/webconsole-output-wrapper.js
--- a/devtools/client/framework/target.js
+++ b/devtools/client/framework/target.js
@@ -370,16 +370,17 @@ Target.prototype = {
   // than most other fronts because it is closely related to the toolbox.
   // TODO: remove once inspector is separated from the toolbox
   async getInspector(typeName) {
     // the front might have been destroyed and no longer have an actor ID
     if (this._inspector && this._inspector.actorID) {
       return this._inspector;
     }
     this._inspector = await getFront(this.client, "inspector", this.form);
+    this.emit("inspector", this._inspector);
     return this._inspector;
   },
 
   // Run callback on every front of this type that currently exists, and on every
   // instantiation of front type in the future.
   onFront(typeName, callback) {
     const front = this.fronts.get(typeName);
     if (front) {
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_nodes_highlight.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_nodes_highlight.js
@@ -19,29 +19,33 @@ const HTML = `
     </script>
   </html>
 `;
 const TEST_URI = "data:text/html;charset=utf-8," + encodeURI(HTML);
 
 add_task(async function() {
   const hud = await openNewTabAndConsole(TEST_URI);
   const toolbox = gDevTools.getToolbox(hud.target);
-  await toolbox.initInspector();
 
   await ContentTask.spawn(gBrowser.selectedBrowser, null, () => {
     content.wrappedJSObject.logNode("h1");
   });
 
   const msg = await waitFor(() => findMessage(hud, "<h1>"));
   const node = msg.querySelector(".objectBox-node");
   ok(node !== null, "Node was logged as expected");
   const view = node.ownerDocument.defaultView;
 
   info("Highlight the node by moving the cursor on it");
-  const onNodeHighlight = toolbox.highlighter.once("node-highlight");
+
+  // the inspector should be initialized first and then the node should
+  // highlight after the hover effect.
+  const onNodeHighlight = toolbox.target.once("inspector")
+    .then(inspector => inspector.highlighter.once("node-highlight"));
+
   EventUtils.synthesizeMouseAtCenter(node, {type: "mousemove"}, view);
 
   const nodeFront = await onNodeHighlight;
   is(nodeFront.displayName, "h1", "The correct node was highlighted");
 
   info("Unhighlight the node by moving away from the node");
   const onNodeUnhighlight = toolbox.highlighter.once("node-unhighlight");
   const btn = toolbox.doc.getElementById("toolbox-meatball-menu-button");
--- a/devtools/client/webconsole/webconsole-output-wrapper.js
+++ b/devtools/client/webconsole/webconsole-output-wrapper.js
@@ -205,29 +205,30 @@ WebConsoleOutputWrapper.prototype = {
           }),
           openNetworkPanel: (requestId) => {
             return this.toolbox.selectTool("netmonitor").then((panel) => {
               return panel.panelWin.Netmonitor.inspectRequest(requestId);
             });
           },
           sourceMapService: this.toolbox ? this.toolbox.sourceMapURLService : null,
           highlightDomElement: async (grip, options = {}) => {
+            await this.toolbox.initInspector();
             if (!this.toolbox.highlighter) {
               return null;
             }
-            await this.toolbox.initInspector();
             const nodeFront = await this.toolbox.walker.gripToNodeFront(grip);
             return this.toolbox.highlighter.highlight(nodeFront, options);
           },
           unHighlightDomElement: (forceHide = false) => {
             return this.toolbox.highlighter
               ? this.toolbox.highlighter.unhighlight(forceHide)
               : null;
           },
           openNodeInInspector: async (grip) => {
+            await this.toolbox.initInspector();
             const onSelectInspector = this.toolbox.selectTool("inspector", "inspect_dom");
             const onGripNodeToFront = this.toolbox.walker.gripToNodeFront(grip);
             const [
               front,
               inspector,
             ] = await Promise.all([onGripNodeToFront, onSelectInspector]);
 
             const onInspectorUpdated = inspector.once("inspector-updated");