1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00
This commit is contained in:
gorhill 2015-10-13 09:34:11 -04:00
parent 24a9d91b71
commit 6424aee788

View File

@ -1051,6 +1051,10 @@ var tabWatcher = (function() {
} }
}; };
var removeTarget = function(target) {
onClose({ target: target });
};
// https://developer.mozilla.org/en-US/docs/Web/Events/TabOpen // https://developer.mozilla.org/en-US/docs/Web/Events/TabOpen
//var onOpen = function({target}) { //var onOpen = function({target}) {
// var tabId = tabIdFromTarget(target); // var tabId = tabIdFromTarget(target);
@ -1246,6 +1250,7 @@ var tabWatcher = (function() {
browserFromTarget: browserFromTarget, browserFromTarget: browserFromTarget,
currentBrowser: currentBrowser, currentBrowser: currentBrowser,
indexFromTarget: indexFromTarget, indexFromTarget: indexFromTarget,
removeTarget: removeTarget,
start: start, start: start,
tabFromBrowser: tabFromBrowser, tabFromBrowser: tabFromBrowser,
tabIdFromTarget: tabIdFromTarget tabIdFromTarget: tabIdFromTarget
@ -2050,10 +2055,22 @@ vAPI.net.registerListeners = function() {
var locationChangedListener = function(e) { var locationChangedListener = function(e) {
var browser = e.target; var browser = e.target;
// I have seen this happens (at startup time)
if ( !browser.currentURI ) {
return;
}
// https://github.com/gorhill/uBlock/issues/697 // https://github.com/gorhill/uBlock/issues/697
// Dismiss event if the associated tab is pending. // Dismiss event if the associated tab is pending.
var tab = tabWatcher.tabFromBrowser(browser); var tab = tabWatcher.tabFromBrowser(browser);
if ( !vAPI.fennec && tab && tab.hasAttribute('pending') ) { if ( !vAPI.fennec && tab && tab.hasAttribute('pending') ) {
// https://github.com/gorhill/uBlock/issues/820
// Firefox quirk: it happens the `pending` attribute was not
// present for certain tabs at startup -- and this can cause
// unwanted [browser <--> tab id] associations internally.
// Dispose of these if it is found the `pending` attribute is
// set.
tabWatcher.removeTarget(tab);
return; return;
} }