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