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

branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
equal deleted inserted replaced
-1:000000000000 0:d9023f89daa6
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/. */
4
5 function test() {
6 waitForExplicitFinish();
7
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");
12
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");
17
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");
24
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");
30
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");
40
41 // Show all tabs
42 let allTabs = [tab for each (tab in gBrowser.tabs)];
43 gBrowser.showOnlyTheseTabs(allTabs);
44
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 }
57
58 function Disabled() {
59 updateTabContextMenu();
60 return document.getElementById("Browser:BookmarkAllTabs").getAttribute("disabled") == "true";
61 }
62
63 function Hidden() {
64 updateTabContextMenu();
65 return document.getElementById("context_bookmarkAllTabs").hidden;
66 }

mercurial