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
☠☠ backed out by 7231e8751ad5 ☠ ☠
authorMihai Sucan <mihai.sucan@gmail.com>
Sat, 08 Mar 2014 23:13:59 +0200
changeset 172615 3d8d5d2cb3848e413dabd47ed8bcc10d4464599c
parent 172614 47bce8cc31b413092d3115998014656eaf0ef87c
child 172616 7231e8751ad5b69504a817c48faa403c0190eacc
push id5545
push usermihai.sucan@gmail.com
push dateSat, 08 Mar 2014 21:15:27 +0000
treeherderfx-team@3d8d5d2cb384 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs980835
milestone30.0a1
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,18 +33,19 @@ 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");
@@ -55,18 +56,18 @@ function test() {
 
       EventUtils.synthesizeMouseAtCenter(inspectorIcon, {},
         inspectorIcon.ownerDocument.defaultView);
       yield onInspectorSelected;
       yield onInspectorUpdated;
       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) {