From 7b651310b4bed3cc6663d7c5fd73e305efde2fef Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 6 Aug 2015 14:46:37 -0400 Subject: [PATCH] this fixes https://github.com/gorhill/uBlock/issues/574 --- platform/firefox/vapi-background.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index 98ed5b1..855d20a 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -688,6 +688,11 @@ vAPI.tabs.open = function(details) { } this.select(tab); + + // Update URL if fragment is different + if ( URI.equals(browser.currentURI) === false ) { + browser.loadURI(URI.asciiSpec); + } return; } } @@ -1096,10 +1101,9 @@ var tabWatcher = (function() { return; } - var tabContainer = null; - if ( tabBrowser.tabContainer ) { - tabContainer = tabBrowser.tabContainer; - } + // https://github.com/gorhill/uBlock/issues/574 + // To keep in mind: not all browser windows are tab containers. + var tabContainer = tabBrowser.tabContainer; if ( tabContainer ) { tabContainer.removeEventListener('TabOpen', onOpen); tabContainer.removeEventListener('TabShow', onShow); @@ -1107,8 +1111,20 @@ var tabWatcher = (function() { tabContainer.removeEventListener('TabSelect', onSelect); } + // https://github.com/gorhill/uBlock/issues/574 + // To keep in mind: not all windows are tab containers, + // sometimes the window IS the tab. + var tabs; + if ( tabBrowser.tabs ) { + tabs = tabBrowser.tabs; + } else if ( tabBrowser.localName === 'browser' ) { + tabs = [tabBrowser]; + } else { + tabs = []; + } + var browser, URI, tabId; - for ( var tab of tabBrowser.tabs ) { + for ( var tab of tabs ) { browser = tabWatcher.browserFromTarget(tab); if ( browser === null ) { continue;