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 | function testState(aPinned) { |
michael@0 | 9 | function elemAttr(id, attr) document.getElementById(id).getAttribute(attr); |
michael@0 | 10 | |
michael@0 | 11 | if (aPinned) { |
michael@0 | 12 | is(elemAttr("key_close", "disabled"), "true", |
michael@0 | 13 | "key_close should be disabled when a pinned-tab is selected"); |
michael@0 | 14 | is(elemAttr("menu_close", "key"), "", |
michael@0 | 15 | "menu_close shouldn't have a key set when a pinned is selected"); |
michael@0 | 16 | } |
michael@0 | 17 | else { |
michael@0 | 18 | is(elemAttr("key_close", "disabled"), "", |
michael@0 | 19 | "key_closed shouldn't have disabled state set when a non-pinned tab is selected"); |
michael@0 | 20 | is(elemAttr("menu_close", "key"), "key_close", |
michael@0 | 21 | "menu_close should have key_close set as its key when a non-pinned tab is selected"); |
michael@0 | 22 | } |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | let lastSelectedTab = gBrowser.selectedTab; |
michael@0 | 26 | ok(!lastSelectedTab.pinned, "We should have started with a regular tab selected"); |
michael@0 | 27 | |
michael@0 | 28 | testState(false); |
michael@0 | 29 | |
michael@0 | 30 | let pinnedTab = gBrowser.addTab("about:blank"); |
michael@0 | 31 | gBrowser.pinTab(pinnedTab); |
michael@0 | 32 | |
michael@0 | 33 | // Just pinning the tab shouldn't change the key state. |
michael@0 | 34 | testState(false); |
michael@0 | 35 | |
michael@0 | 36 | // Test updating key state after selecting a tab. |
michael@0 | 37 | gBrowser.selectedTab = pinnedTab; |
michael@0 | 38 | testState(true); |
michael@0 | 39 | |
michael@0 | 40 | gBrowser.selectedTab = lastSelectedTab; |
michael@0 | 41 | testState(false); |
michael@0 | 42 | |
michael@0 | 43 | gBrowser.selectedTab = pinnedTab; |
michael@0 | 44 | testState(true); |
michael@0 | 45 | |
michael@0 | 46 | // Test updating the key state after un/pinning the tab. |
michael@0 | 47 | gBrowser.unpinTab(pinnedTab); |
michael@0 | 48 | testState(false); |
michael@0 | 49 | |
michael@0 | 50 | gBrowser.pinTab(pinnedTab); |
michael@0 | 51 | testState(true); |
michael@0 | 52 | |
michael@0 | 53 | // Test updating the key state after removing the tab. |
michael@0 | 54 | gBrowser.removeTab(pinnedTab); |
michael@0 | 55 | testState(false); |
michael@0 | 56 | |
michael@0 | 57 | finish(); |
michael@0 | 58 | } |