Skip to content

Commit 73c8a96

Browse files
committed
1 parent a7316b7 commit 73c8a96

2 files changed

Lines changed: 28 additions & 21 deletions

File tree

platform/firefox/vapi-background.js

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,36 +1064,43 @@ vAPI.tabs._remove = (function() {
10641064
tabBrowser.closeTab(tab);
10651065
};
10661066
}
1067-
return function(tab, tabBrowser, nuke) {
1068-
if ( !tabBrowser ) {
1069-
return;
1070-
}
1071-
if ( tabBrowser.tabs.length === 1 && nuke ) {
1072-
getOwnerWindow(tab).close();
1073-
} else {
1074-
tabBrowser.removeTab(tab);
1075-
}
1067+
return function(tab, tabBrowser) {
1068+
if ( !tabBrowser ) { return; }
1069+
tabBrowser.removeTab(tab);
10761070
};
10771071
})();
10781072

10791073
/******************************************************************************/
10801074

1075+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1317173
1076+
// Work around FF45 (and earlier) timing issue by delaying the closing
1077+
// of tabs. The picked delay is just what seemed to work for the test case
1078+
// reported in the issue above.
1079+
10811080
vAPI.tabs.remove = (function() {
1082-
var remove = function(tabId, nuke) {
1083-
var browser = tabWatcher.browserFromTabId(tabId);
1084-
if ( !browser ) {
1085-
return;
1086-
}
1087-
var tab = tabWatcher.tabFromBrowser(browser);
1088-
if ( !tab ) {
1089-
return;
1081+
var timer = null,
1082+
queue = [];
1083+
1084+
var remove = function() {
1085+
timer = null;
1086+
var tabId, browser, tab;
1087+
while ( (tabId = queue.pop()) ) {
1088+
browser = tabWatcher.browserFromTabId(tabId);
1089+
if ( !browser ) { continue; }
1090+
tab = tabWatcher.tabFromBrowser(browser);
1091+
if ( !tab ) { continue; }
1092+
this._remove(tab, getTabBrowser(getOwnerWindow(browser)));
10901093
}
1091-
this._remove(tab, getTabBrowser(getOwnerWindow(browser)), nuke);
10921094
};
10931095

10941096
// Do this asynchronously
1095-
return function(tabId, nuke) {
1096-
vAPI.setTimeout(remove.bind(this, tabId, nuke), 1);
1097+
return function(tabId, delay) {
1098+
queue.push(tabId);
1099+
if ( timer !== null ) {
1100+
if ( !delay ) { return; }
1101+
clearTimeout(timer);
1102+
}
1103+
timer = vAPI.setTimeout(remove.bind(this), delay ? 250 : 25);
10971104
};
10981105
})();
10991106

src/js/tab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ vAPI.tabs.onPopupUpdated = (function() {
777777
// It is a popup, block and remove the tab.
778778
if ( popupType === 'popup' ) {
779779
µb.unbindTabFromPageStats(targetTabId);
780-
vAPI.tabs.remove(targetTabId, true);
780+
vAPI.tabs.remove(targetTabId, false);
781781
} else {
782782
µb.unbindTabFromPageStats(openerTabId);
783783
vAPI.tabs.remove(openerTabId, true);

0 commit comments

Comments
 (0)