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