Bug 646297 - On tab close in Fennec, switch to sibling before parent [r=mfinkle]

This commit is contained in:
Matt Brubeck 2011-04-27 09:10:52 -07:00
parent 5c6ac73f77
commit 009f7fb2ca
3 changed files with 15 additions and 2 deletions

View File

@ -880,6 +880,8 @@ var BrowserUI = {
if (browser.canGoBack) {
browser.goBack();
} else if (tab.owner) {
// When going back, always return to the owner (not a sibling).
Browser.selectedTab = tab.owner;
this.closeTab(tab);
}
#ifdef ANDROID

View File

@ -717,7 +717,12 @@ var Browser = {
let nextTab = this._selectedTab;
if (nextTab == aTab) {
nextTab = aTab.owner || this.getTabAtIndex(tabIndex + 1) || this.getTabAtIndex(tabIndex - 1);
nextTab = this.getTabAtIndex(tabIndex + 1) || this.getTabAtIndex(tabIndex - 1);
// If the next tab is not a sibling, switch back to the parent.
if (aTab.owner && nextTab.owner != aTab.owner)
nextTab = aTab.owner;
if (!nextTab)
return null;
}

View File

@ -83,6 +83,8 @@ function tab_switch_02() {
//Add new tab
new_tab_03 = Browser.addTab(testURL_03, true, new_tab_01);
new_tab_04 = Browser.addTab(testURL_03, false, new_tab_01);
checkExpectedSize();
new_tab_03.browser.addEventListener("load", tab_switch_03, true);
}
@ -93,7 +95,11 @@ function tab_switch_03() {
is(Browser.selectedTab.notification, Elements.browsers.selectedPanel, "Deck has correct browser");
Browser.closeTab(new_tab_03, { forceClose: true });
is(Browser.selectedTab, new_tab_01, "Closing tab 03 returns to owner");
is(Browser.selectedTab, new_tab_04, "Closing tab 03 goes to sibling");
is(Browser.selectedTab.notification, Elements.browsers.selectedPanel, "Deck has correct browser");
Browser.closeTab(new_tab_04, { forceClose: true });
is(Browser.selectedTab, new_tab_01, "Closing tab 04 returns to owner");
is(Browser.selectedTab.notification, Elements.browsers.selectedPanel, "Deck has correct browser");
new_tab_03 = Browser.addTab(testURL_03, true, new_tab_01);