Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | function test() { |
michael@0 | 6 | waitForExplicitFinish(); |
michael@0 | 7 | |
michael@0 | 8 | // There should be one tab when we start the test |
michael@0 | 9 | let [origTab] = gBrowser.visibleTabs; |
michael@0 | 10 | is(gBrowser.visibleTabs.length, 1, "1 tab should be open"); |
michael@0 | 11 | is(Disabled(), true, "Bookmark All Tabs should be disabled"); |
michael@0 | 12 | |
michael@0 | 13 | // Add a tab |
michael@0 | 14 | let testTab1 = gBrowser.addTab(); |
michael@0 | 15 | is(gBrowser.visibleTabs.length, 2, "2 tabs should be open"); |
michael@0 | 16 | is(Disabled(), true, "Bookmark All Tabs should be disabled since there are two tabs with the same address"); |
michael@0 | 17 | |
michael@0 | 18 | let testTab2 = gBrowser.addTab("about:mozilla"); |
michael@0 | 19 | is(gBrowser.visibleTabs.length, 3, "3 tabs should be open"); |
michael@0 | 20 | // Wait for tab load, the code checks for currentURI. |
michael@0 | 21 | testTab2.linkedBrowser.addEventListener("load", function () { |
michael@0 | 22 | testTab2.linkedBrowser.removeEventListener("load", arguments.callee, true); |
michael@0 | 23 | is(Disabled(), false, "Bookmark All Tabs should be enabled since there are two tabs with different addresses"); |
michael@0 | 24 | |
michael@0 | 25 | // Hide the original tab |
michael@0 | 26 | gBrowser.selectedTab = testTab2; |
michael@0 | 27 | gBrowser.showOnlyTheseTabs([testTab2]); |
michael@0 | 28 | is(gBrowser.visibleTabs.length, 1, "1 tab should be visible"); |
michael@0 | 29 | is(Disabled(), true, "Bookmark All Tabs should be disabled as there is only one visible tab"); |
michael@0 | 30 | |
michael@0 | 31 | // Add a tab that will get pinned |
michael@0 | 32 | let pinned = gBrowser.addTab(); |
michael@0 | 33 | is(gBrowser.visibleTabs.length, 2, "2 tabs should be visible now"); |
michael@0 | 34 | is(Disabled(), false, "Bookmark All Tabs should be available as there are two visible tabs"); |
michael@0 | 35 | gBrowser.pinTab(pinned); |
michael@0 | 36 | is(Hidden(), false, "Bookmark All Tabs should be visible on a normal tab"); |
michael@0 | 37 | is(Disabled(), true, "Bookmark All Tabs should not be available since one tab is pinned"); |
michael@0 | 38 | gBrowser.selectedTab = pinned; |
michael@0 | 39 | is(Hidden(), true, "Bookmark All Tabs should be hidden on a pinned tab"); |
michael@0 | 40 | |
michael@0 | 41 | // Show all tabs |
michael@0 | 42 | let allTabs = [tab for each (tab in gBrowser.tabs)]; |
michael@0 | 43 | gBrowser.showOnlyTheseTabs(allTabs); |
michael@0 | 44 | |
michael@0 | 45 | // reset the environment |
michael@0 | 46 | gBrowser.removeTab(testTab2); |
michael@0 | 47 | gBrowser.removeTab(testTab1); |
michael@0 | 48 | gBrowser.removeTab(pinned); |
michael@0 | 49 | is(gBrowser.visibleTabs.length, 1, "only orig is left and visible"); |
michael@0 | 50 | is(gBrowser.tabs.length, 1, "sanity check that it matches"); |
michael@0 | 51 | is(Disabled(), true, "Bookmark All Tabs should be hidden"); |
michael@0 | 52 | is(gBrowser.selectedTab, origTab, "got the orig tab"); |
michael@0 | 53 | is(origTab.hidden, false, "and it's not hidden -- visible!"); |
michael@0 | 54 | finish(); |
michael@0 | 55 | }, true); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | function Disabled() { |
michael@0 | 59 | updateTabContextMenu(); |
michael@0 | 60 | return document.getElementById("Browser:BookmarkAllTabs").getAttribute("disabled") == "true"; |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | function Hidden() { |
michael@0 | 64 | updateTabContextMenu(); |
michael@0 | 65 | return document.getElementById("context_bookmarkAllTabs").hidden; |
michael@0 | 66 | } |