From 4dab0769c02791f86da11dda12ad3748b0ac5b51 Mon Sep 17 00:00:00 2001 From: ketmar Date: Wed, 12 Aug 2015 20:21:08 +0000 Subject: [PATCH] we don't really need window observer FossilOrigin-Name: 15285e4bd2006faa689f6a402562d3fa2e61988899f322e6a4f111375ef3002f --- main/modules/injector.js | 57 +----------------------------------------------- 1 file changed, 1 insertion(+), 56 deletions(-) diff --git a/main/modules/injector.js b/main/modules/injector.js index d1f8867..8654d1b 100644 --- a/main/modules/injector.js +++ b/main/modules/injector.js @@ -36,7 +36,6 @@ const stripCredsRE = new RegExp("(://)([^:/]+)(:[^@/]+)?@"); //////////////////////////////////////////////////////////////////////////////// let consoleActivated = !addonOptions.openConsole; - function openConsole (win) { if (consoleActivated) return; consoleActivated = true; @@ -108,36 +107,9 @@ function runScripts (theWin, docStart) { //////////////////////////////////////////////////////////////////////////////// -let windowListener = { - onOpenWindow: function (aXULWindow) { - // wait for the window to finish loading - if (consoleActivated) return; - let aDOMWindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal||Ci.nsIDOMWindow); - aDOMWindow.addEventListener("load", function () { - aDOMWindow.removeEventListener("load", arguments.callee, false); - windowListener.loadIntoWindow(aDOMWindow, aXULWindow); - }, false); - }, - onCloseWindow: function (aXULWindow) {}, - onWindowTitleChange: function (aXULWindow, aNewTitle) {}, - register: function () { - Services.wm.addListener(windowListener); - }, - unregister: function () { Services.wm.removeListener(windowListener); }, - loadIntoWindow: function (aDOMWindow, aXULWindow) { - if (!aDOMWindow || !aDOMWindow.gBrowser) return; - if (isBootstrapped) openConsole(aDOMWindow); - }, - unloadFromWindow: function (aDOMWindow, aXULWindow) { - }, -}; - - -//////////////////////////////////////////////////////////////////////////////// function ContentObserver () {} -//////////////////////////////////////////////////////////////////////////////// ContentObserver.prototype.QueryInterface = XPCOMUtils.generateQI([Ci.nsIObserver]); @@ -163,31 +135,6 @@ ContentObserver.prototype.observe = function (aSubject, aTopic, aData) { // listen for whichever kind of load event arrives first win.addEventListener("DOMContentLoaded", gContentLoad, true); win.addEventListener("load", gContentLoad, true); - /* - win.addEventListener("popstate", function (evt) { - logError("POPSTATE!\n"+ - " state: "+JSON.stringify(evt.state)+"\n"+ - " location: "+doc.location); - }, true); - win.addEventListener("pagehide", function (evt) { - logError("PAGEHIDE!\n"+ - " location: "+doc.location); - }, true); - win.addEventListener("pageshow", function (evt) { - logError("PAGESHOW!\n"+ - " location: "+doc.location); - }, true); - win.addEventListener("unload", function (evt) { - logError("UNLOAD!\n"+ - " location: "+doc.location); - }, true); - win.addEventListener("readystatechange", function (evt) { - logError("STATE!\n"+ - " state: "+doc.readyState+"\n"+ - " location: "+doc.location); - }, true); - */ - //if (addonOptions.debugMode) conlog("document-start for "+doc.documentURI); runScripts(win, true); } else { logError("observe: "+aTopic); @@ -202,14 +149,12 @@ var gContentLoad = contentObserver.contentLoad.bind(contentObserver); //WARNING: //////////////////////////////////////////////////////////////////////////////// registerStartupHook("injector", function () { - windowListener.register(); Services.obs.addObserver(contentObserver, "document-element-inserted", false); if (!isBootstrapped) openConsole(window); }); registerShutdownHook("injector", function () { - closeStorageObjects(); - windowListener.unregister(); Services.obs.removeObserver(contentObserver, "document-element-inserted"); + closeStorageObjects(); }); -- 2.11.4.GIT