Bug 1345563 - Bring devtools Inspect Element code in line with Firefox (fixes regression from bug 1240907). r=frg a=IanN DONTBUILD
author11522914
Sun, 12 Mar 2017 21:25:31 +0000
changeset 31392 44cfd725acc15f0abcd33dfc00dda54e889e1fb3
parent 31391 835660435eafe84e7a14103e80cde6b44e7700d5
child 31393 95cca2602d76e5be7c06a55c37521f3d8f07606e
push id1
push userclokep@gmail.com
push dateMon, 07 May 2018 22:45:56 +0000
treeherdercomm-esr60@57eacde5ef40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrg, IanN
bugs1345563, 1240907
Bug 1345563 - Bring devtools Inspect Element code in line with Firefox (fixes regression from bug 1240907). r=frg a=IanN DONTBUILD
suite/common/nsContextMenu.js
--- a/suite/common/nsContextMenu.js
+++ b/suite/common/nsContextMenu.js
@@ -480,34 +480,36 @@ nsContextMenu.prototype = {
         this.setItemAttr("context-video-showstats", "disabled", hasError);
         this.setItemAttr("context-video-hidestats", "disabled", hasError);
       }
     }
     this.showItem("context-media-sep-commands", onMedia);
   },
 
   inspectNode: function() {
-    var tmp = {};
+    let tmp = {};
     Components.utils.import("resource://devtools/shared/Loader.jsm", tmp);
-    var gBrowser = this.browser.ownerDocument.defaultView.gBrowser;
-    var tt = tmp.devtools.TargetFactory.forTab(gBrowser.selectedTab);
+    let gBrowser = this.browser.ownerDocument.defaultView.gBrowser;
+    let tt = tmp.devtools.TargetFactory.forTab(gBrowser.selectedTab);
     return gDevTools.showToolbox(tt, "inspector").then(toolbox => {
-      var inspector = toolbox.getCurrentPanel();
-      /* Currently "isRemote" is always false.
-      if (this.isRemote) {
-        this.browser.messageManager
-            .sendAsyncMessage("debug:inspect", {}, { node: this.target });
-        inspector.walker.findInspectingNode().then(nodeFront => {
-          inspector.selection.setNodeFront(nodeFront, "browser-context-menu");
-        });
-      } else {
-        inspector.selection.setNode(this.target, "browser-context-menu");
-      }
-      */
-      inspector.selection.setNode(this.target, "browser-context-menu");
+      let inspector = toolbox.getCurrentPanel();
+      // new-node-front tells us when the node has been selected, whether the
+      // browser is remote or not.
+      let onNewNode = inspector.selection.once("new-node-front");
+
+      this.browser.messageManager.sendAsyncMessage("debug:inspect", {}, {node: this.target});
+      inspector.walker.findInspectingNode().then(nodeFront => {
+        inspector.selection.setNodeFront(nodeFront, "browser-context-menu");
+      });
+
+      return onNewNode.then(() => {
+        // Now that the node has been selected, wait until the inspector is
+        // fully updated.
+        return inspector.once("inspector-updated");
+      });
     });
   },
 
   // Set various context menu attributes based on the state of the world.
   setTarget: function(aNode, aRangeParent, aRangeOffset) {
     // Currently "isRemote" is always false.
     //this.isRemote = gContextMenuContentData && gContextMenuContentData.isRemote;