|
| 1 | +/* Any copyright is dedicated to the Public Domain. |
| 2 | + https://creativecommons.org/publicdomain/zero/1.0/ */ |
| 3 | + |
| 4 | +"use strict"; |
| 5 | + |
| 6 | +const URL1 = "data:text/plain,tab1"; |
| 7 | +const URL2 = "data:text/plain,tab2"; |
| 8 | +const URL3 = "data:text/plain,tab3"; |
| 9 | + |
| 10 | +add_task(async function test_blurToRecentlyClosedTab() { |
| 11 | + const [tab1, tab2, tab3] = [ |
| 12 | + BrowserTestUtils.addTab(gBrowser, URL1), |
| 13 | + BrowserTestUtils.addTab(gBrowser, URL2), |
| 14 | + BrowserTestUtils.addTab(gBrowser, URL3), |
| 15 | + ]; |
| 16 | + |
| 17 | + gBrowser.selectedTab = tab2; |
| 18 | + gBrowser.selectedTab = tab3; |
| 19 | + gBrowser.selectedTab = tab1; |
| 20 | + |
| 21 | + gBrowser.selectedTab = tab2; |
| 22 | + gBrowser.removeTab(tab2); |
| 23 | + |
| 24 | + Assert.equal( |
| 25 | + gBrowser.selectedTab, |
| 26 | + tab1, |
| 27 | + "After closing the most recently used tab, the selection moves to the last used tab" |
| 28 | + ); |
| 29 | + |
| 30 | + gBrowser.selectedTab = tab3; |
| 31 | + gBrowser.removeTab(tab3); |
| 32 | + |
| 33 | + Assert.equal( |
| 34 | + gBrowser.selectedTab, |
| 35 | + tab1, |
| 36 | + "After closing the most recently used tab, the selection moves to the last used tab" |
| 37 | + ); |
| 38 | + |
| 39 | + gBrowser.removeTab(tab1); |
| 40 | +}); |
| 41 | + |
| 42 | +add_task(async function test_closeToLastTab() { |
| 43 | + await SpecialPowers.pushPrefEnv({ |
| 44 | + set: [ |
| 45 | + ["zen.tabs.select-recently-used-on-close", false], |
| 46 | + ["zen.view.show-newtab-button-top", false], |
| 47 | + ], |
| 48 | + }); |
| 49 | + |
| 50 | + const [tab1, tab2, tab3] = [ |
| 51 | + BrowserTestUtils.addTab(gBrowser, URL1), |
| 52 | + BrowserTestUtils.addTab(gBrowser, URL2), |
| 53 | + BrowserTestUtils.addTab(gBrowser, URL3), |
| 54 | + ]; |
| 55 | + |
| 56 | + gBrowser.selectedTab = tab2; |
| 57 | + gBrowser.selectedTab = tab3; |
| 58 | + gBrowser.selectedTab = tab1; |
| 59 | + |
| 60 | + gBrowser.selectedTab = tab2; |
| 61 | + gBrowser.removeTab(tab2); |
| 62 | + |
| 63 | + Assert.equal( |
| 64 | + gBrowser.selectedTab, |
| 65 | + tab3, |
| 66 | + "After closing the current tab, the selection moves to the next tab in order" |
| 67 | + ); |
| 68 | + |
| 69 | + gBrowser.selectedTab = tab1; |
| 70 | + gBrowser.removeTab(tab1); |
| 71 | + |
| 72 | + Assert.equal( |
| 73 | + gBrowser.selectedTab, |
| 74 | + tab3, |
| 75 | + "After closing the current tab, the selection moves to the next tab in order" |
| 76 | + ); |
| 77 | + |
| 78 | + gBrowser.removeTab(tab3); |
| 79 | + await SpecialPowers.popPrefEnv(); |
| 80 | +}); |
0 commit comments