diff --git a/browser/devtools/inspector/highlighter.js b/browser/devtools/inspector/highlighter.js index 279c0ab63be..d8a4cdf97fd 100644 --- a/browser/devtools/inspector/highlighter.js +++ b/browser/devtools/inspector/highlighter.js @@ -834,6 +834,7 @@ function BasicHighlighter(aTarget, aInspector) BasicHighlighter.prototype = { destroy: function() { + this.walker.highlight(null); this.selection.off("new-node-front", this.highlight); this.walker = null; this.selection = null; diff --git a/browser/devtools/inspector/inspector-panel.js b/browser/devtools/inspector/inspector-panel.js index d87e8c3a8bd..d72fc2a1684 100644 --- a/browser/devtools/inspector/inspector-panel.js +++ b/browser/devtools/inspector/inspector-panel.js @@ -447,6 +447,13 @@ InspectorPanel.prototype = { 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); @@ -464,12 +471,6 @@ InspectorPanel.prototype = { 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); diff --git a/browser/devtools/inspector/test/browser_inspector_basic_highlighter.js b/browser/devtools/inspector/test/browser_inspector_basic_highlighter.js index d922b7156db..2817383d42b 100644 --- a/browser/devtools/inspector/test/browser_inspector_basic_highlighter.js +++ b/browser/devtools/inspector/test/browser_inspector_basic_highlighter.js @@ -35,6 +35,12 @@ function test() { yield verifyH1Selected(); yield deselect(); yield verifyNoNodeSelected(); + + yield selectH1(); + yield verifyH1Selected(); + yield destroyInspector(); + yield verifyNoNodeSelected(); + finishUp(); }).then(null, Cu.reportError); } @@ -66,6 +72,10 @@ function test() { return deferred.promise; } + function destroyInspector() { + return inspector.destroy(); + } + function verifyNoNodeSelected() { ok(doc.querySelectorAll(":-moz-devtools-highlighted").length === 0, "no node selected"); return promise.resolve();