1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/general/browser_visibleTabs_contextMenu.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +function test() { 1.9 + // There should be one tab when we start the test 1.10 + let [origTab] = gBrowser.visibleTabs; 1.11 + is(gBrowser.visibleTabs.length, 1, "there is one visible tab"); 1.12 + let testTab = gBrowser.addTab(); 1.13 + is(gBrowser.visibleTabs.length, 2, "there are now two visible tabs"); 1.14 + 1.15 + // Check the context menu with two tabs 1.16 + updateTabContextMenu(origTab); 1.17 + is(document.getElementById("context_closeTab").disabled, false, "Close Tab is enabled"); 1.18 + is(document.getElementById("context_reloadAllTabs").disabled, false, "Reload All Tabs is enabled"); 1.19 + 1.20 + // Hide the original tab. 1.21 + gBrowser.selectedTab = testTab; 1.22 + gBrowser.showOnlyTheseTabs([testTab]); 1.23 + is(gBrowser.visibleTabs.length, 1, "now there is only one visible tab"); 1.24 + 1.25 + // Check the context menu with one tab. 1.26 + updateTabContextMenu(testTab); 1.27 + is(document.getElementById("context_closeTab").disabled, false, "Close Tab is enabled when more than one tab exists"); 1.28 + is(document.getElementById("context_reloadAllTabs").disabled, true, "Reload All Tabs is disabled"); 1.29 + 1.30 + // Add a tab that will get pinned 1.31 + // So now there's one pinned tab, one visible unpinned tab, and one hidden tab 1.32 + let pinned = gBrowser.addTab(); 1.33 + gBrowser.pinTab(pinned); 1.34 + is(gBrowser.visibleTabs.length, 2, "now there are two visible tabs"); 1.35 + 1.36 + // Check the context menu on the unpinned visible tab 1.37 + updateTabContextMenu(testTab); 1.38 + is(document.getElementById("context_closeOtherTabs").disabled, true, "Close Other Tabs is disabled"); 1.39 + is(document.getElementById("context_closeTabsToTheEnd").disabled, true, "Close Tabs To The End is disabled"); 1.40 + 1.41 + // Show all tabs 1.42 + let allTabs = [tab for each (tab in gBrowser.tabs)]; 1.43 + gBrowser.showOnlyTheseTabs(allTabs); 1.44 + 1.45 + // Check the context menu now 1.46 + updateTabContextMenu(testTab); 1.47 + is(document.getElementById("context_closeOtherTabs").disabled, false, "Close Other Tabs is enabled"); 1.48 + is(document.getElementById("context_closeTabsToTheEnd").disabled, true, "Close Tabs To The End is disabled"); 1.49 + 1.50 + // Check the context menu of the original tab 1.51 + // Close Tabs To The End should now be enabled 1.52 + updateTabContextMenu(origTab); 1.53 + is(document.getElementById("context_closeTabsToTheEnd").disabled, false, "Close Tabs To The End is enabled"); 1.54 + 1.55 + gBrowser.removeTab(testTab); 1.56 + gBrowser.removeTab(pinned); 1.57 +}