browser_bug533232.js (1694B)
1 function test() { 2 var tab1 = gBrowser.selectedTab; 3 var tab2 = BrowserTestUtils.addTab(gBrowser); 4 var childTab1; 5 var childTab2; 6 7 childTab1 = BrowserTestUtils.addTab(gBrowser, "about:blank", { 8 relatedToCurrent: true, 9 }); 10 gBrowser.selectedTab = childTab1; 11 gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true }); 12 is( 13 idx(gBrowser.selectedTab), 14 idx(tab1), 15 "closing a tab next to its parent selects the parent" 16 ); 17 18 childTab1 = BrowserTestUtils.addTab(gBrowser, "about:blank", { 19 relatedToCurrent: true, 20 }); 21 gBrowser.selectedTab = tab2; 22 gBrowser.selectedTab = childTab1; 23 gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true }); 24 is( 25 idx(gBrowser.selectedTab), 26 idx(tab2), 27 "closing a tab next to its parent doesn't select the parent if another tab had been selected ad interim" 28 ); 29 30 gBrowser.selectedTab = tab1; 31 childTab1 = BrowserTestUtils.addTab(gBrowser, "about:blank", { 32 relatedToCurrent: true, 33 }); 34 childTab2 = BrowserTestUtils.addTab(gBrowser, "about:blank", { 35 relatedToCurrent: true, 36 }); 37 gBrowser.selectedTab = childTab1; 38 gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true }); 39 is( 40 idx(gBrowser.selectedTab), 41 idx(childTab2), 42 "closing a tab next to its parent selects the next tab with the same parent" 43 ); 44 gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true }); 45 is( 46 idx(gBrowser.selectedTab), 47 idx(tab2), 48 "closing the last tab in a set of child tabs doesn't go back to the parent" 49 ); 50 51 gBrowser.removeTab(tab2, { skipPermitUnload: true }); 52 } 53 54 function idx(tab) { 55 return Array.prototype.indexOf.call(gBrowser.tabs, tab); 56 }