|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 function test() { |
|
6 // There should be one tab when we start the test |
|
7 let [origTab] = gBrowser.visibleTabs; |
|
8 is(gBrowser.visibleTabs.length, 1, "there is one visible tab"); |
|
9 let testTab = gBrowser.addTab(); |
|
10 is(gBrowser.visibleTabs.length, 2, "there are now two visible tabs"); |
|
11 |
|
12 // Check the context menu with two tabs |
|
13 updateTabContextMenu(origTab); |
|
14 is(document.getElementById("context_closeTab").disabled, false, "Close Tab is enabled"); |
|
15 is(document.getElementById("context_reloadAllTabs").disabled, false, "Reload All Tabs is enabled"); |
|
16 |
|
17 // Hide the original tab. |
|
18 gBrowser.selectedTab = testTab; |
|
19 gBrowser.showOnlyTheseTabs([testTab]); |
|
20 is(gBrowser.visibleTabs.length, 1, "now there is only one visible tab"); |
|
21 |
|
22 // Check the context menu with one tab. |
|
23 updateTabContextMenu(testTab); |
|
24 is(document.getElementById("context_closeTab").disabled, false, "Close Tab is enabled when more than one tab exists"); |
|
25 is(document.getElementById("context_reloadAllTabs").disabled, true, "Reload All Tabs is disabled"); |
|
26 |
|
27 // Add a tab that will get pinned |
|
28 // So now there's one pinned tab, one visible unpinned tab, and one hidden tab |
|
29 let pinned = gBrowser.addTab(); |
|
30 gBrowser.pinTab(pinned); |
|
31 is(gBrowser.visibleTabs.length, 2, "now there are two visible tabs"); |
|
32 |
|
33 // Check the context menu on the unpinned visible tab |
|
34 updateTabContextMenu(testTab); |
|
35 is(document.getElementById("context_closeOtherTabs").disabled, true, "Close Other Tabs is disabled"); |
|
36 is(document.getElementById("context_closeTabsToTheEnd").disabled, true, "Close Tabs To The End is disabled"); |
|
37 |
|
38 // Show all tabs |
|
39 let allTabs = [tab for each (tab in gBrowser.tabs)]; |
|
40 gBrowser.showOnlyTheseTabs(allTabs); |
|
41 |
|
42 // Check the context menu now |
|
43 updateTabContextMenu(testTab); |
|
44 is(document.getElementById("context_closeOtherTabs").disabled, false, "Close Other Tabs is enabled"); |
|
45 is(document.getElementById("context_closeTabsToTheEnd").disabled, true, "Close Tabs To The End is disabled"); |
|
46 |
|
47 // Check the context menu of the original tab |
|
48 // Close Tabs To The End should now be enabled |
|
49 updateTabContextMenu(origTab); |
|
50 is(document.getElementById("context_closeTabsToTheEnd").disabled, false, "Close Tabs To The End is enabled"); |
|
51 |
|
52 gBrowser.removeTab(testTab); |
|
53 gBrowser.removeTab(pinned); |
|
54 } |