From bc287f98aa1337cfdafca136f9701fb00016ce1b Mon Sep 17 00:00:00 2001 From: gorhill Date: Mon, 14 Sep 2015 11:28:33 -0400 Subject: [PATCH] this fixes #697 --- platform/firefox/frameModule.js | 2 +- platform/firefox/vapi-background.js | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/platform/firefox/frameModule.js b/platform/firefox/frameModule.js index 65de7a9e4..a11720e42 100644 --- a/platform/firefox/frameModule.js +++ b/platform/firefox/frameModule.js @@ -432,7 +432,7 @@ LocationChangeListener.prototype.onLocationChange = function(webProgress, reques } this.messageManager.sendAsyncMessage(locationChangedMessageName, { url: location.asciiSpec, - flags: flags, + flags: flags }); }; diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index f4d523999..c69b9981c 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -1035,7 +1035,11 @@ var tabWatcher = (function() { vAPI.toolbarButton.attachToNewWindow(window); } - tabContainer.addEventListener('TabOpen', onOpen); + // https://github.com/gorhill/uBlock/issues/697 + // Ignore `TabShow` events: unfortunately the `pending` attribute is + // not set when a tab is opened as a result of session restore -- it is + // set *after* the event is fired in such case. + //tabContainer.addEventListener('TabOpen', onOpen); tabContainer.addEventListener('TabShow', onShow); tabContainer.addEventListener('TabClose', onClose); // when new window is opened TabSelect doesn't run on the selected tab? @@ -1912,8 +1916,16 @@ vAPI.net.registerListeners = function() { var locationChangedListenerMessageName = location.host + ':locationChanged'; var locationChangedListener = function(e) { - var details = e.data; var browser = e.target; + + // https://github.com/gorhill/uBlock/issues/697 + // Dismiss event if the associated tab is pending. + var tab = tabWatcher.tabFromBrowser(browser); + if ( !tab || tab.hasAttribute('pending') ) { + return; + } + + var details = e.data; var tabId = tabWatcher.tabIdFromTarget(browser); // Ignore notifications related to our popup @@ -1921,8 +1933,6 @@ vAPI.net.registerListeners = function() { return; } - //console.debug("nsIWebProgressListener: onLocationChange: " + details.url + " (" + details.flags + ")"); - // LOCATION_CHANGE_SAME_DOCUMENT = "did not load a new document" if ( details.flags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT ) { vAPI.tabs.onUpdated(tabId, {url: details.url}, {