diff --git a/platform/firefox/bootstrap.js b/platform/firefox/bootstrap.js index 9cac5344a..2dbd4294c 100644 --- a/platform/firefox/bootstrap.js +++ b/platform/firefox/bootstrap.js @@ -10,7 +10,7 @@ var bgProcess; function startup(data, reason) { bgProcess = function(ev) { if (ev) { - this.removeEventListener('load', bgProcess); + this.removeEventListener(ev.type, bgProcess); } bgProcess = Services.appShell.hiddenDOMWindow.document; @@ -22,9 +22,9 @@ function startup(data, reason) { if (reason === APP_STARTUP) { Services.ww.registerNotification({ - observe: function(subject) { + observe: function(win) { Services.ww.unregisterNotification(this); - subject.addEventListener('load', bgProcess); + win.addEventListener('DOMContentLoaded', bgProcess); } }); } diff --git a/platform/firefox/frameModule.js b/platform/firefox/frameModule.js index 126a4d9e9..9763a8494 100644 --- a/platform/firefox/frameModule.js +++ b/platform/firefox/frameModule.js @@ -6,6 +6,7 @@ this.EXPORTED_SYMBOLS = ['contentPolicy', 'docObserver']; Components.utils['import']('resource://gre/modules/Services.jsm'); Components.utils['import']('resource://gre/modules/XPCOMUtils.jsm'); +// Components.utils['import']('resource://gre/modules/devtools/Console.jsm'); const Ci = Components.interfaces; let appName; diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index be36e3188..d0181f4d1 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -248,9 +248,9 @@ var windowWatcher = { e.target.ownerDocument.defaultView ); }, - onLoad: function(e) { + onReady: function(e) { if (e) { - this.removeEventListener('load', windowWatcher.onLoad); + this.removeEventListener(e.type, windowWatcher.onReady); } var docElement = this.document.documentElement; @@ -275,7 +275,7 @@ var windowWatcher = { }, observe: function(win, topic) { if (topic === 'domwindowopened') { - win.addEventListener('load', this.onLoad); + win.addEventListener('DOMContentLoaded', this.onReady); } } }; @@ -318,12 +318,11 @@ vAPI.tabs.registerListeners = function() { // onClosed - handled in windowWatcher.onTabClose // onPopup ? - Services.ww.registerNotification(windowWatcher); - for (var win of this.getWindows()) { - windowWatcher.onLoad.call(win); + windowWatcher.onReady.call(win); } + Services.ww.registerNotification(windowWatcher); vAPI.toolbarButton.init(); vAPI.unload.push(function() { @@ -332,7 +331,7 @@ vAPI.tabs.registerListeners = function() { for (var win of vAPI.tabs.getWindows()) { vAPI.toolbarButton.remove(win.document); - win.removeEventListener('load', windowWatcher.onLoad); + win.removeEventListener('load', windowWatcher.onReady); win.gBrowser.removeTabsProgressListener(tabsProgressListener); var tC = win.gBrowser.tabContainer;