From 7e89b7a1619a6a672fec7e8913a14315f0b9cd97 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 18 Oct 2015 17:18:04 -0400 Subject: [PATCH] attach to window even if a tab browser is not present --- platform/firefox/vapi-background.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index 6dbb71158..b8d8b6a71 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -1112,9 +1112,14 @@ var tabWatcher = (function() { // On some platforms, the tab browser isn't immediately available, // try waiting a bit if this happens. + // https://github.com/gorhill/uBlock/issues/763 + // Not getting a tab browser should not prevent from attaching ourself + // to the window. var tabBrowser = getTabBrowser(window); - if ( tabBrowser === null ) { - attachToTabBrowserLater({ window: window, tryCount: tryCount }); + if ( + tabBrowser === null && + attachToTabBrowserLater({ window: window, tryCount: tryCount }) + ) { return; } @@ -1122,6 +1127,10 @@ var tabWatcher = (function() { vAPI.toolbarButton.attachToNewWindow(window); } + if ( tabBrowser === null ) { + return; + } + var tabContainer; if ( tabBrowser.deck ) { // Fennec tabContainer = tabBrowser.deck; @@ -1206,7 +1215,15 @@ var tabWatcher = (function() { // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWindowWatcher var windowWatcher = { - observe: function(win, topic) { + observe: function(subject, topic) { + var win; + try { + win = subject.QueryInterface(Ci.nsIDOMWindow); + } catch (ex) { + } + if ( !win ) { + return; + } if ( topic === 'domwindowopened' ) { onWindowLoad.call(win); return;