browser/base/content/test/general/browser_visibleTabs_bookmarkAllTabs.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   waitForExplicitFinish();
     8   // There should be one tab when we start the test
     9   let [origTab] = gBrowser.visibleTabs;
    10   is(gBrowser.visibleTabs.length, 1, "1 tab should be open");  
    11   is(Disabled(), true, "Bookmark All Tabs should be disabled");
    13   // Add a tab
    14   let testTab1 = gBrowser.addTab();
    15   is(gBrowser.visibleTabs.length, 2, "2 tabs should be open");
    16   is(Disabled(), true, "Bookmark All Tabs should be disabled since there are two tabs with the same address");
    18   let testTab2 = gBrowser.addTab("about:mozilla");
    19   is(gBrowser.visibleTabs.length, 3, "3 tabs should be open");
    20   // Wait for tab load, the code checks for currentURI.
    21   testTab2.linkedBrowser.addEventListener("load", function () {
    22     testTab2.linkedBrowser.removeEventListener("load", arguments.callee, true);
    23     is(Disabled(), false, "Bookmark All Tabs should be enabled since there are two tabs with different addresses");
    25     // Hide the original tab
    26     gBrowser.selectedTab = testTab2;
    27     gBrowser.showOnlyTheseTabs([testTab2]);
    28     is(gBrowser.visibleTabs.length, 1, "1 tab should be visible");  
    29     is(Disabled(), true, "Bookmark All Tabs should be disabled as there is only one visible tab");
    31     // Add a tab that will get pinned
    32     let pinned = gBrowser.addTab();
    33     is(gBrowser.visibleTabs.length, 2, "2 tabs should be visible now");
    34     is(Disabled(), false, "Bookmark All Tabs should be available as there are two visible tabs");
    35     gBrowser.pinTab(pinned);
    36     is(Hidden(), false, "Bookmark All Tabs should be visible on a normal tab");
    37     is(Disabled(), true, "Bookmark All Tabs should not be available since one tab is pinned");
    38     gBrowser.selectedTab = pinned;
    39     is(Hidden(), true, "Bookmark All Tabs should be hidden on a pinned tab");
    41     // Show all tabs
    42     let allTabs = [tab for each (tab in gBrowser.tabs)];
    43     gBrowser.showOnlyTheseTabs(allTabs);
    45     // reset the environment  
    46     gBrowser.removeTab(testTab2);
    47     gBrowser.removeTab(testTab1);
    48     gBrowser.removeTab(pinned);
    49     is(gBrowser.visibleTabs.length, 1, "only orig is left and visible");
    50     is(gBrowser.tabs.length, 1, "sanity check that it matches");
    51     is(Disabled(), true, "Bookmark All Tabs should be hidden");
    52     is(gBrowser.selectedTab, origTab, "got the orig tab");
    53     is(origTab.hidden, false, "and it's not hidden -- visible!");
    54     finish();
    55   }, true);
    56 }
    58 function Disabled() {
    59   updateTabContextMenu();
    60   return document.getElementById("Browser:BookmarkAllTabs").getAttribute("disabled") == "true";
    61 }
    63 function Hidden() {
    64   updateTabContextMenu();
    65   return document.getElementById("context_bookmarkAllTabs").hidden;
    66 }

mercurial