michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function test() { michael@0: // There should be one tab when we start the test michael@0: let [origTab] = gBrowser.visibleTabs; michael@0: is(gBrowser.visibleTabs.length, 1, "there is one visible tab"); michael@0: let testTab = gBrowser.addTab(); michael@0: is(gBrowser.visibleTabs.length, 2, "there are now two visible tabs"); michael@0: michael@0: // Check the context menu with two tabs michael@0: updateTabContextMenu(origTab); michael@0: is(document.getElementById("context_closeTab").disabled, false, "Close Tab is enabled"); michael@0: is(document.getElementById("context_reloadAllTabs").disabled, false, "Reload All Tabs is enabled"); michael@0: michael@0: // Hide the original tab. michael@0: gBrowser.selectedTab = testTab; michael@0: gBrowser.showOnlyTheseTabs([testTab]); michael@0: is(gBrowser.visibleTabs.length, 1, "now there is only one visible tab"); michael@0: michael@0: // Check the context menu with one tab. michael@0: updateTabContextMenu(testTab); michael@0: is(document.getElementById("context_closeTab").disabled, false, "Close Tab is enabled when more than one tab exists"); michael@0: is(document.getElementById("context_reloadAllTabs").disabled, true, "Reload All Tabs is disabled"); michael@0: michael@0: // Add a tab that will get pinned michael@0: // So now there's one pinned tab, one visible unpinned tab, and one hidden tab michael@0: let pinned = gBrowser.addTab(); michael@0: gBrowser.pinTab(pinned); michael@0: is(gBrowser.visibleTabs.length, 2, "now there are two visible tabs"); michael@0: michael@0: // Check the context menu on the unpinned visible tab michael@0: updateTabContextMenu(testTab); michael@0: is(document.getElementById("context_closeOtherTabs").disabled, true, "Close Other Tabs is disabled"); michael@0: is(document.getElementById("context_closeTabsToTheEnd").disabled, true, "Close Tabs To The End is disabled"); michael@0: michael@0: // Show all tabs michael@0: let allTabs = [tab for each (tab in gBrowser.tabs)]; michael@0: gBrowser.showOnlyTheseTabs(allTabs); michael@0: michael@0: // Check the context menu now michael@0: updateTabContextMenu(testTab); michael@0: is(document.getElementById("context_closeOtherTabs").disabled, false, "Close Other Tabs is enabled"); michael@0: is(document.getElementById("context_closeTabsToTheEnd").disabled, true, "Close Tabs To The End is disabled"); michael@0: michael@0: // Check the context menu of the original tab michael@0: // Close Tabs To The End should now be enabled michael@0: updateTabContextMenu(origTab); michael@0: is(document.getElementById("context_closeTabsToTheEnd").disabled, false, "Close Tabs To The End is enabled"); michael@0: michael@0: gBrowser.removeTab(testTab); michael@0: gBrowser.removeTab(pinned); michael@0: }