Bug 914403 - Part 3: Clear selection on remote inspector destuction. r=paul, a=lsblakk
authorJ. Ryan Stinnett <jryans@gmail.com>
Mon, 16 Sep 2013 19:28:53 -0500
changeset 160343 6dedfabac6906f06e27deab9b0abb6465fedd455
parent 160342 a72a845b6892e034c089df25d90430f2404847e7
child 160344 1eee5e8e71332d8098912164ee635952de45d525
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaul, lsblakk
bugs914403
milestone26.0a2
Bug 914403 - Part 3: Clear selection on remote inspector destuction. r=paul, a=lsblakk
browser/devtools/inspector/highlighter.js
browser/devtools/inspector/inspector-panel.js
browser/devtools/inspector/test/browser_inspector_basic_highlighter.js
--- a/browser/devtools/inspector/highlighter.js
+++ b/browser/devtools/inspector/highlighter.js
@@ -829,16 +829,17 @@ function BasicHighlighter(aTarget, aInsp
   this.highlight = this.highlight.bind(this);
   this.selection.on("new-node-front", this.highlight);
   EventEmitter.decorate(this);
   this.locked = true;
 }
 
 BasicHighlighter.prototype = {
   destroy: function() {
+    this.walker.highlight(null);
     this.selection.off("new-node-front", this.highlight);
     this.walker = null;
     this.selection = null;
   },
   toggleLockState: function() {
     this.locked = !this.locked;
     if (this.locked) {
       this.walker.cancelPick();
--- a/browser/devtools/inspector/inspector-panel.js
+++ b/browser/devtools/inspector/inspector-panel.js
@@ -442,16 +442,23 @@ InspectorPanel.prototype = {
 
   /**
    * Destroy the inspector.
    */
   destroy: function InspectorPanel__destroy() {
     if (this._destroyPromise) {
       return this._destroyPromise;
     }
+
+    if (this.highlighter) {
+      this.highlighter.off("locked", this.onLockStateChanged);
+      this.highlighter.off("unlocked", this.onLockStateChanged);
+      this.highlighter.destroy();
+    }
+
     if (this.walker) {
       this.walker.off("new-root", this.onNewRoot);
       this._destroyPromise = this.walker.release().then(null, console.error);
       delete this.walker;
       delete this.pageStyle;
     } else {
       this._destroyPromise = promise.resolve(null);
     }
@@ -459,22 +466,16 @@ InspectorPanel.prototype = {
     this.cancelUpdate();
     this.cancelLayoutChange();
 
     if (this.browser) {
       this.browser.removeEventListener("resize", this.scheduleLayoutChange, true);
       this.browser = null;
     }
 
-    if (this.highlighter) {
-      this.highlighter.off("locked", this.onLockStateChanged);
-      this.highlighter.off("unlocked", this.onLockStateChanged);
-      this.highlighter.destroy();
-    }
-
     this.target.off("thread-paused", this.updateDebuggerPausedWarning);
     this.target.off("thread-resumed", this.updateDebuggerPausedWarning);
     this._toolbox.off("select", this.updateDebuggerPausedWarning);
 
     this._toolbox = null;
 
     this.sidebar.off("select", this._setDefaultSidebar);
     this.sidebar.destroy();
--- a/browser/devtools/inspector/test/browser_inspector_basic_highlighter.js
+++ b/browser/devtools/inspector/test/browser_inspector_basic_highlighter.js
@@ -30,16 +30,22 @@ function test() {
   function runTests(aInspector) {
     inspector = aInspector;
 
     Task.spawn(function() {
       yield selectH1();
       yield verifyH1Selected();
       yield deselect();
       yield verifyNoNodeSelected();
+
+      yield selectH1();
+      yield verifyH1Selected();
+      yield destroyInspector();
+      yield verifyNoNodeSelected();
+
       finishUp();
     }).then(null, Cu.reportError);
   }
 
   function selectH1() {
     let deferred = promise.defer();
     let h1 = doc.querySelector("h1");
     inspector.selection.once("new-node-front", () => {
@@ -61,16 +67,20 @@ function test() {
     let deferred = promise.defer();
     inspector.selection.once("new-node-front", () => {
       executeSoon(deferred.resolve);
     });
     inspector.selection.setNode(null);
     return deferred.promise;
   }
 
+  function destroyInspector() {
+    return inspector.destroy();
+  }
+
   function verifyNoNodeSelected() {
     ok(doc.querySelectorAll(":-moz-devtools-highlighted").length === 0, "no node selected");
     return promise.resolve();
   }
 
   function finishUp() {
     let h = require("devtools/inspector/highlighter");
     h._forceBasic.value = false;