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

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

mercurial