diff --git a/browser/devtools/highlighter/inspector.jsm b/browser/devtools/highlighter/inspector.jsm index 1ae4cf7d101b..b7a49dd85118 100644 --- a/browser/devtools/highlighter/inspector.jsm +++ b/browser/devtools/highlighter/inspector.jsm @@ -80,6 +80,9 @@ const INSPECTOR_NOTIFICATIONS = { // Fires once the Inspector is closed. CLOSED: "inspector-closed", + // Fires once the Inspector is destroyed. Not fired on tab switch. + DESTROYED: "inspector-destroyed", + // Fires when the Inspector is reopened after tab-switch. STATE_RESTORED: "inspector-state-restored", @@ -1046,6 +1049,8 @@ InspectorUI.prototype = { return; } + let winId = new String(this.winID); // retain this to notify observers. + this.closing = true; this.toolbar.hidden = true; @@ -1104,6 +1109,8 @@ InspectorUI.prototype = { delete this.stylePanel; delete this.toolbar; Services.obs.notifyObservers(null, INSPECTOR_NOTIFICATIONS.CLOSED, null); + if (!aKeepStore) + Services.obs.notifyObservers(null, INSPECTOR_NOTIFICATIONS.DESTROYED, winId); }, /** diff --git a/browser/devtools/highlighter/test/browser_inspector_initialization.js b/browser/devtools/highlighter/test/browser_inspector_initialization.js index 01e57a7c2bf0..c5500b8d0fbb 100644 --- a/browser/devtools/highlighter/test/browser_inspector_initialization.js +++ b/browser/devtools/highlighter/test/browser_inspector_initialization.js @@ -39,6 +39,7 @@ let doc; let salutation; let closing; +let winId; function createDocument() { @@ -182,11 +183,12 @@ function inspectNodesFromContextTestWhileOpen() function inspectNodesFromContextTestHighlight() { + winId = InspectorUI.winID; Services.obs.removeObserver(inspectNodesFromContextTestHighlight, InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING); - Services.obs.addObserver(finishInspectorTests, InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED, false); + Services.obs.addObserver(finishInspectorTests, InspectorUI.INSPECTOR_NOTIFICATIONS.DESTROYED, false); is(InspectorUI.selection, closing, "InspectorUI.selection is header"); executeSoon(function() { - InspectorUI.closeInspectorUI(true); + InspectorUI.closeInspectorUI(); }); } @@ -196,11 +198,12 @@ function inspectNodesFromContextTestTrap() ok(false, "Inspector UI has been opened again. We Should Not Be Here!"); } -function finishInspectorTests() +function finishInspectorTests(subject, topic, aWinIdString) { Services.obs.removeObserver(finishInspectorTests, - InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED); + InspectorUI.INSPECTOR_NOTIFICATIONS.DESTROYED); + is(parseInt(aWinIdString), winId, "winId of destroyed Inspector matches"); ok(!InspectorUI.highlighter, "Highlighter is gone"); ok(!InspectorUI.treePanel, "Inspector Tree Panel is closed"); ok(!InspectorUI.inspecting, "Inspector is not inspecting"); @@ -211,6 +214,7 @@ function finishInspectorTests() is(InspectorUI.sidebarDeck.children.length, 0, "No items in the Sidebar deck"); ok(!InspectorUI.toolbar, "toolbar is hidden"); + Services.obs.removeObserver(inspectNodesFromContextTestTrap, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED); gBrowser.removeCurrentTab(); finish(); }