Bug 533232 - closing tab to the right of its parent should select the parent, not the next tab on the right. r=mano a=dietrich

This commit is contained in:
Dão Gottwald 2010-09-06 11:39:59 +02:00
Родитель 3012fd8433
Коммит 798f3e5597
3 изменённых файлов: 46 добавлений и 1 удалений

Просмотреть файл

@ -758,7 +758,11 @@
if (!this._previewMode && oldTab != this.selectedTab)
oldTab.owner = null;
this._lastRelatedTab = null;
if (this._lastRelatedTab) {
if (this._lastRelatedTab != this.selectedTab)
this._lastRelatedTab.owner = null;
this._lastRelatedTab = null;
}
var oldBrowser = this.mCurrentBrowser;
if (oldBrowser) {
@ -1252,6 +1256,10 @@
Services.prefs.getBoolPref("browser.tabs.insertRelatedAfterCurrent")) {
let newTabPos = (this._lastRelatedTab ||
this.selectedTab)._tPos + 1;
if (this._lastRelatedTab)
this._lastRelatedTab.owner = null;
else
t.owner = this.selectedTab;
this.moveTabTo(t, newTabPos);
this._lastRelatedTab = t;
}

Просмотреть файл

@ -132,6 +132,7 @@ _BROWSER_FILES = \
browser_bug519216.js \
browser_bug520538.js \
browser_bug521216.js \
browser_bug533232.js \
browser_bug537474.js \
browser_bug550565.js \
browser_bug553455.js \

Просмотреть файл

@ -0,0 +1,36 @@
function test() {
var tab1 = gBrowser.selectedTab;
var tab2 = gBrowser.addTab();
var childTab1;
var childTab2;
childTab1 = gBrowser.addTab("about:blank", { relatedToCurrent: true });
gBrowser.selectedTab = childTab1;
gBrowser.removeCurrentTab();
is(idx(gBrowser.selectedTab), idx(tab1),
"closing a tab next to its parent selects the parent");
childTab1 = gBrowser.addTab("about:blank", { relatedToCurrent: true });
gBrowser.selectedTab = tab2;
gBrowser.selectedTab = childTab1;
gBrowser.removeCurrentTab();
is(idx(gBrowser.selectedTab), idx(tab2),
"closing a tab next to its parent doesn't select the parent if another tab had been selected ad interim");
gBrowser.selectedTab = tab1;
childTab1 = gBrowser.addTab("about:blank", { relatedToCurrent: true });
childTab2 = gBrowser.addTab("about:blank", { relatedToCurrent: true });
gBrowser.selectedTab = childTab1;
gBrowser.removeCurrentTab();
is(idx(gBrowser.selectedTab), idx(childTab2),
"closing a tab next to its parent selects the next tab with the same parent");
gBrowser.removeCurrentTab();
is(idx(gBrowser.selectedTab), idx(tab2),
"closing the last tab in a set of child tabs doesn't go back to the parent");
gBrowser.removeTab(tab2);
}
function idx(tab) {
return Array.indexOf(gBrowser.tabs, tab);
}