From e0d742b0406b1419002ca8f85f129bc669996bcd Mon Sep 17 00:00:00 2001 From: Deathamns Date: Tue, 16 Dec 2014 18:09:55 +0100 Subject: [PATCH] Firefox: initialize buttons when DOM is ready --- platform/firefox/vapi-background.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index be36e31..d0181f4 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;