Skip to content
Browse files

Bug 667314 - Don't loop infinitely when closing the selected tab in t…

…he Ctrl+Tab panel. r=gavin
  • Loading branch information...
1 parent e864691 commit 67d6b894a569975c4cc8e12148061b5aefe85734 Dão Gottwald committed Jul 5, 2011
View
19 browser/base/content/browser-tabPreviews.js
@@ -215,15 +215,17 @@ var ctrlTab = {
if (this._tabList)
return this._tabList;
- let list = gBrowser.visibleTabs;
-
- if (this._closing)
- this.detachTab(this._closing, list);
+ // Using gBrowser.tabs instead of gBrowser.visibleTabs, as the latter
+ // exlcudes closing tabs, breaking the following loop in case the the
+ // selected tab is closing.
+ let list = Array.filter(gBrowser.tabs, function (tab) !tab.hidden);
// Rotate the list until the selected tab is first
while (!list[0].selected)
list.push(list.shift());
+ list = list.filter(function (tab) !tab.closing);
+
if (this.recentlyUsedLimit != 0) {
let recentlyUsedTabs = this._recentlyUsedTabs;
if (this.recentlyUsedLimit > 0)
@@ -370,11 +372,10 @@ var ctrlTab = {
else
this._recentlyUsedTabs.push(aTab);
},
- detachTab: function ctrlTab_detachTab(aTab, aTabs) {
- var tabs = aTabs || this._recentlyUsedTabs;
- var i = tabs.indexOf(aTab);
+ detachTab: function ctrlTab_detachTab(aTab) {
+ var i = this._recentlyUsedTabs.indexOf(aTab);
if (i >= 0)
- tabs.splice(i, 1);
+ this._recentlyUsedTabs.splice(i, 1);
},
open: function ctrlTab_open() {
@@ -498,10 +499,8 @@ var ctrlTab = {
return;
}
- this._closing = aTab;
this._tabList = null;
this.updatePreviews();
- this._closing = null;
if (this.selected.hidden)
this.advanceFocus(false);
View
2 browser/base/content/tabbrowser.xml
@@ -96,7 +96,7 @@
<getter><![CDATA[
return Array.filter(this.tabs, function(tab) {
return !tab.hidden && !tab.closing;
- }, this);
+ });
]]></getter>
</property>
<field name="mURIFixup" readonly="true">
View
10 browser/base/content/test/browser_ctrlTab.js
@@ -28,6 +28,16 @@ function test() {
releaseCtrl();
}
+ { // test for bug 667314
+ let tabs = gBrowser.tabs.length;
+ pressCtrlTab();
+ pressCtrlTab(true);
+ EventUtils.synthesizeKey("w", { ctrlKey: true });
+ is(gBrowser.tabs.length, tabs - 1, "Ctrl+Tab -> Ctrl+W removes the selected tab");
+ releaseCtrl();
+ }
+
+ gBrowser.addTab();
checkTabs(3);
ctrlTabTest([2, 1, 0], 9, 1);

0 comments on commit 67d6b89

Please sign in to comment.
Something went wrong with that request. Please try again.