browser/base/content/test/general/browser_visibleTabs_contextMenu.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     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");
    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");
    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");
    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");
    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");
    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");
    38   // Show all tabs
    39   let allTabs = [tab for each (tab in gBrowser.tabs)];
    40   gBrowser.showOnlyTheseTabs(allTabs);
    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");
    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");
    52   gBrowser.removeTab(testTab);
    53   gBrowser.removeTab(pinned);
    54 }

mercurial