fix
bug 1297535
MozReview-Commit-ID: 6bazA1Bl5Ph
--- a/devtools/client/framework/devtools-browser.js
+++ b/devtools/client/framework/devtools-browser.js
@@ -411,20 +411,23 @@ var gDevToolsBrowser = exports.gDevTools
* is called after delayed-startup notification. This method should only do
* what has to be done early. Otherwise devtools should be initialized lazily
* to prevent overloading Firefox startup.
*
* @param {ChromeWindow} window
* The window to which devtools should be hooked to.
*/
_onBrowserWindowLoaded: function (win) {
- if (!win.gBrowser) {
+ // This method is called for all top level window, only consider firefox
+ // windows
+ if (!win.location.href.endsWith("browser.xul")) {
return;
}
BrowserMenus.addMenus(win.document);
+ win.addEventListener("unload", this);
},
/**
* Add this DevTools's presence to a browser window's document
*
* @param {ChromeWindow} win
* The window to which devtools should be hooked to.
*/
@@ -441,17 +444,16 @@ var gDevToolsBrowser = exports.gDevTools
// Inject lazily DeveloperToolbar on the chrome window
loader.lazyGetter(win, "DeveloperToolbar", function () {
let { DeveloperToolbar } = require("devtools/client/shared/developer-toolbar");
return new DeveloperToolbar(win);
});
this.updateCommandAvailability(win);
this.ensurePrefObserver();
- win.addEventListener("unload", this);
let tabContainer = win.gBrowser.tabContainer;
tabContainer.addEventListener("TabSelect", this, false);
tabContainer.addEventListener("TabOpen", this, false);
tabContainer.addEventListener("TabClose", this, false);
tabContainer.addEventListener("TabPinned", this, false);
tabContainer.addEventListener("TabUnpinned", this, false);
},
@@ -638,23 +640,26 @@ var gDevToolsBrowser = exports.gDevTools
/**
* Called on browser unload to remove menu entries, toolboxes and event
* listeners from the closed browser window.
*
* @param {XULWindow} win
* The window containing the menu entry
*/
_forgetBrowserWindow: function (win) {
+ // _forgetBrowserWindow can only be called once for each window, but
+ // _registerBrowserWindow may not have been called. Instead, only
+ // _onBrowserWindowLoaded was and we only need to revert that.
+ win.removeEventListener("unload", this);
+ BrowserMenus.removeMenus(win.document);
+
if (!gDevToolsBrowser._trackedBrowserWindows.has(win)) {
return;
}
gDevToolsBrowser._trackedBrowserWindows.delete(win);
- win.removeEventListener("unload", this);
-
- BrowserMenus.removeMenus(win.document);
// Destroy toolboxes for closed window
for (let [target, toolbox] of gDevTools._toolboxes) {
if (toolbox.win.top == win) {
toolbox.destroy();
}
}