Bug 602708 - Closing a tab earlier than the current one results in wrong tab being shown [r=mfinkle]

This commit is contained in:
Wesley Johnston 2010-10-08 12:41:00 -04:00
parent 9624ba3f9a
commit 1f01c9107d
2 changed files with 34 additions and 9 deletions

View File

@ -610,10 +610,10 @@ var Browser = {
tab.chromeTab.dispatchEvent(event); tab.chromeTab.dispatchEvent(event);
tab.browser.messageManager.sendAsyncMessage("Browser:TabClose"); tab.browser.messageManager.sendAsyncMessage("Browser:TabClose");
this.selectedTab = nextTab;
tab.destroy(); tab.destroy();
this._tabs.splice(tabIndex, 1); this._tabs.splice(tabIndex, 1);
this.selectedTab = nextTab;
}, },
get selectedTab() { get selectedTab() {
@ -624,9 +624,16 @@ var Browser = {
if (tab instanceof XULElement) if (tab instanceof XULElement)
tab = this.getTabFromChrome(tab); tab = this.getTabFromChrome(tab);
if (!tab || this._selectedTab == tab) if (!tab)
return; return;
if (this._selectedTab == tab) {
// Deck does not update its selectedIndex when children
// are removed. See bug 602708
Elements.browsers.selectedPanel = tab.browser;
return;
}
TapHighlightHelper.hide(); TapHighlightHelper.hide();
if (this._selectedTab) { if (this._selectedTab) {
@ -2550,9 +2557,7 @@ Tab.prototype = {
this._listener = null; this._listener = null;
this._loading = false; this._loading = false;
Util.executeSoon(function() {
Elements.browsers.removeChild(browser); Elements.browsers.removeChild(browser);
});
} }
}, },

View File

@ -41,18 +41,22 @@ function load_tabs() {
function tab_switch_01() { function tab_switch_01() {
BrowserUI.selectTab(new_tab_01); BrowserUI.selectTab(new_tab_01);
is(Browser.selectedTab.browser.currentURI.spec, testURL_01, "Tab Switch 01 URL Matches"); is(Browser.selectedTab.browser.currentURI.spec, testURL_01, "Tab Switch 01 URL Matches");
is(Browser.selectedTab.browser, Elements.browsers.selectedPanel, "Deck has correct browser");
//Add new tab //Add new tab
new_tab_02 = Browser.addTab(testURL_02,false); new_tab_02 = Browser.addTab(testURL_02,false);
new_tab_02.browser.addEventListener("load", tab_switch_02, true); new_tab_02.browser.addEventListener("load", tab_switch_02, true);
is(Browser.selectedTab.browser, Elements.browsers.selectedPanel, "Deck has correct browser");
} }
function tab_switch_02() { function tab_switch_02() {
BrowserUI.selectTab(new_tab_02); BrowserUI.selectTab(new_tab_02);
is(Browser.selectedTab.browser.currentURI.spec, testURL_02, "Tab Switch 02 URL Matches"); is(Browser.selectedTab.browser.currentURI.spec, testURL_02, "Tab Switch 02 URL Matches");
is(Browser.selectedTab.browser, Elements.browsers.selectedPanel, "Deck has correct browser");
BrowserUI.selectTab(new_tab_01); BrowserUI.selectTab(new_tab_01);
is(Browser.selectedTab.browser.currentURI.spec, testURL_01, "Tab Switch 01 URL Matches"); is(Browser.selectedTab.browser.currentURI.spec, testURL_01, "Tab Switch 01 URL Matches");
is(Browser.selectedTab.browser, Elements.browsers.selectedPanel, "Deck has correct browser");
//Add new tab //Add new tab
new_tab_03 = Browser.addTab(testURL_03, true, new_tab_01); new_tab_03 = Browser.addTab(testURL_03, true, new_tab_01);
@ -62,9 +66,25 @@ function tab_switch_02() {
function tab_switch_03() { function tab_switch_03() {
is(Browser.selectedTab.browser.currentURI.spec, testURL_03, "Tab Switch 03 URL Matches"); is(Browser.selectedTab.browser.currentURI.spec, testURL_03, "Tab Switch 03 URL Matches");
is(new_tab_03.owner, new_tab_01, "Tab 03 owned by tab 01"); is(new_tab_03.owner, new_tab_01, "Tab 03 owned by tab 01");
is(Browser.selectedTab.browser, Elements.browsers.selectedPanel, "Deck has correct browser");
Browser.closeTab(new_tab_03); Browser.closeTab(new_tab_03);
is(Browser.selectedTab, new_tab_01, "Closing tab 03 returns to owner"); is(Browser.selectedTab, new_tab_01, "Closing tab 03 returns to owner");
is(Browser.selectedTab.browser, Elements.browsers.selectedPanel, "Deck has correct browser");
new_tab_03 = Browser.addTab(testURL_03, true, new_tab_01);
new_tab_03.browser.addEventListener("load", tab_switch_04, true);
}
function tab_switch_04() {
is(Browser.selectedTab.browser.currentURI.spec, testURL_03, "Tab Switch 03 URL Matches");
is(new_tab_03.owner, new_tab_01, "Tab 03 owned by tab 01");
is(Browser.selectedTab.browser, Elements.browsers.selectedPanel, "Deck has correct browser");
Browser.closeTab(new_tab_01);
is(Browser.selectedTab, new_tab_03, "Closing tab 01 keeps selectedTab");
is(new_tab_03.owner, null, "Closing tab 01 nulls tab3 owner");
is(Browser.selectedTab.browser, Elements.browsers.selectedPanel, "Deck has correct browser");
done(); done();
} }