Bug 980835 - Fix for intermittent | browser_webconsole_output_dom_elements_02.js | The current inspector selection is correct - Got [object HTMLParagraphElement], expected [object HTMLBodyElement]; r=me
authorMihai Sucan <mihai.sucan@gmail.com>
Sat, 08 Mar 2014 23:13:59 +0200
changeset 190184 09ba2ea97c87bc09d6bee6a495b087886f97566b
parent 190183 610ea14ada942f5e664bef9114e443a9642e3036
child 190185 731be5361993d488ac76cc4d1e2e30c8aad57086
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs980835
milestone30.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 980835 - Fix for intermittent | browser_webconsole_output_dom_elements_02.js | The current inspector selection is correct - Got [object HTMLParagraphElement], expected [object HTMLBodyElement]; r=me
browser/devtools/styleinspector/style-inspector.js
browser/devtools/webconsole/console-output.js
browser/devtools/webconsole/test/browser_webconsole_output_dom_elements_02.js
--- a/browser/devtools/styleinspector/style-inspector.js
+++ b/browser/devtools/styleinspector/style-inspector.js
@@ -85,16 +85,20 @@ function RuleViewTool(aInspector, aWindo
 
   this.onSelect();
 }
 
 exports.RuleViewTool = RuleViewTool;
 
 RuleViewTool.prototype = {
   onSelect: function RVT_onSelect(aEvent) {
+    if (!this.view) {
+      // Skip the event if RuleViewTool has been destroyed.
+      return;
+    }
     this.view.setPageStyle(this.inspector.pageStyle);
 
     if (!this.inspector.selection.isConnected() ||
         !this.inspector.selection.isElementNode()) {
       this.view.highlight(null);
       return;
     }
 
@@ -153,16 +157,20 @@ function ComputedViewTool(aInspector, aW
   this.onSelect();
 }
 
 exports.ComputedViewTool = ComputedViewTool;
 
 ComputedViewTool.prototype = {
   onSelect: function CVT_onSelect(aEvent)
   {
+    if (!this.view) {
+      // Skip the event if ComputedViewTool has been destroyed.
+      return;
+    }
     this.view.setPageStyle(this.inspector.pageStyle);
 
     if (!this.inspector.selection.isConnected() ||
         !this.inspector.selection.isElementNode()) {
       this.view.highlight(null);
       return;
     }
 
--- a/browser/devtools/webconsole/console-output.js
+++ b/browser/devtools/webconsole/console-output.js
@@ -519,16 +519,17 @@ Messages.BaseMessage.prototype = {
   },
 
   destroy: function()
   {
     // Destroy all widgets that have registered themselves in this.widgets
     for (let widget of this.widgets) {
       widget.destroy();
     }
+    this.widgets.clear();
   }
 }; // Messages.BaseMessage.prototype
 
 
 /**
  * The NavigationMarker is used to show a page load event.
  *
  * @constructor
--- a/browser/devtools/webconsole/test/browser_webconsole_output_dom_elements_02.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_output_dom_elements_02.js
@@ -33,40 +33,43 @@ const TEST_DATA = [
 function test() {
   Task.spawn(function*() {
     let {tab} = yield loadTab(TEST_URI);
     let hud = yield openConsole(tab);
     let toolbox = gDevTools.getToolbox(hud.target);
 
     // Loading the inspector panel at first, to make it possible to listen for
     // new node selections
-    yield toolbox.loadTool("inspector");
-    let inspector = toolbox.getPanel("inspector");
+    yield toolbox.selectTool("inspector");
+    let inspector = toolbox.getCurrentPanel();
+    yield toolbox.selectTool("webconsole");
 
     info("Iterating over the test data");
     for (let data of TEST_DATA) {
       let [result] = yield jsEval(data.input, hud, {text: data.output});
       let {widget, msg} = yield getWidgetAndMessage(result);
 
       let inspectorIcon = msg.querySelector(".open-inspector");
       ok(inspectorIcon, "Inspector icon found in the ElementNode widget");
 
       info("Clicking on the inspector icon and waiting for the inspector to be selected");
       let onInspectorSelected = toolbox.once("inspector-selected");
       let onInspectorUpdated = inspector.once("inspector-updated");
+      let onNewNode = toolbox.selection.once("new-node");
 
       EventUtils.synthesizeMouseAtCenter(inspectorIcon, {},
         inspectorIcon.ownerDocument.defaultView);
       yield onInspectorSelected;
       yield onInspectorUpdated;
+      yield onNewNode;
       ok(true, "Inspector selected and new node got selected");
 
       let rawNode = content.wrappedJSObject[data.input.replace(/\(\)/g, "")]();
-      is(rawNode, inspector.selection.node.wrappedJSObject,
-        "The current inspector selection is correct");
+      is(inspector.selection.node.wrappedJSObject, rawNode,
+         "The current inspector selection is correct");
 
       info("Switching back to the console");
       yield toolbox.selectTool("webconsole");
     }
   }).then(finishTest);
 }
 
 function jsEval(input, hud, message) {