This commit is contained in:
gorhill 2016-11-16 16:08:03 -05:00
parent a7316b7456
commit 73c8a96c48
2 changed files with 28 additions and 21 deletions

View File

@ -1064,36 +1064,43 @@ vAPI.tabs._remove = (function() {
tabBrowser.closeTab(tab); tabBrowser.closeTab(tab);
}; };
} }
return function(tab, tabBrowser, nuke) { return function(tab, tabBrowser) {
if ( !tabBrowser ) { if ( !tabBrowser ) { return; }
return; tabBrowser.removeTab(tab);
}
if ( tabBrowser.tabs.length === 1 && nuke ) {
getOwnerWindow(tab).close();
} else {
tabBrowser.removeTab(tab);
}
}; };
})(); })();
/******************************************************************************/ /******************************************************************************/
// https://bugzilla.mozilla.org/show_bug.cgi?id=1317173
// Work around FF45 (and earlier) timing issue by delaying the closing
// of tabs. The picked delay is just what seemed to work for the test case
// reported in the issue above.
vAPI.tabs.remove = (function() { vAPI.tabs.remove = (function() {
var remove = function(tabId, nuke) { var timer = null,
var browser = tabWatcher.browserFromTabId(tabId); queue = [];
if ( !browser ) {
return; var remove = function() {
timer = null;
var tabId, browser, tab;
while ( (tabId = queue.pop()) ) {
browser = tabWatcher.browserFromTabId(tabId);
if ( !browser ) { continue; }
tab = tabWatcher.tabFromBrowser(browser);
if ( !tab ) { continue; }
this._remove(tab, getTabBrowser(getOwnerWindow(browser)));
} }
var tab = tabWatcher.tabFromBrowser(browser);
if ( !tab ) {
return;
}
this._remove(tab, getTabBrowser(getOwnerWindow(browser)), nuke);
}; };
// Do this asynchronously // Do this asynchronously
return function(tabId, nuke) { return function(tabId, delay) {
vAPI.setTimeout(remove.bind(this, tabId, nuke), 1); queue.push(tabId);
if ( timer !== null ) {
if ( !delay ) { return; }
clearTimeout(timer);
}
timer = vAPI.setTimeout(remove.bind(this), delay ? 250 : 25);
}; };
})(); })();

View File

@ -777,7 +777,7 @@ vAPI.tabs.onPopupUpdated = (function() {
// It is a popup, block and remove the tab. // It is a popup, block and remove the tab.
if ( popupType === 'popup' ) { if ( popupType === 'popup' ) {
µb.unbindTabFromPageStats(targetTabId); µb.unbindTabFromPageStats(targetTabId);
vAPI.tabs.remove(targetTabId, true); vAPI.tabs.remove(targetTabId, false);
} else { } else {
µb.unbindTabFromPageStats(openerTabId); µb.unbindTabFromPageStats(openerTabId);
vAPI.tabs.remove(openerTabId, true); vAPI.tabs.remove(openerTabId, true);