|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 let contentWindow; |
|
5 |
|
6 function test() { |
|
7 requestLongerTimeout(2); |
|
8 waitForExplicitFinish(); |
|
9 |
|
10 showTabView(test1); |
|
11 } |
|
12 |
|
13 function test1() { |
|
14 ok(TabView.isVisible(), "Tab View is visible"); |
|
15 |
|
16 contentWindow = document.getElementById("tab-view").contentWindow; |
|
17 whenTabViewIsHidden(function() { |
|
18 ok(!TabView.isVisible(), "Tab View is not visible"); |
|
19 showTabView(test2); |
|
20 }); |
|
21 EventUtils.synthesizeKey("e", { accelKey: true, shiftKey: true }, contentWindow); |
|
22 } |
|
23 |
|
24 function test2() { |
|
25 ok(TabView.isVisible(), "Tab View is visible"); |
|
26 |
|
27 whenSearchIsEnabled(function() { |
|
28 ok(contentWindow.Search.isEnabled(), "The search is enabled") |
|
29 |
|
30 whenSearchIsDisabled(test3); |
|
31 hideSearch(); |
|
32 }); |
|
33 EventUtils.synthesizeKey("f", { accelKey: true }, contentWindow); |
|
34 } |
|
35 |
|
36 function test3() { |
|
37 ok(!contentWindow.Search.isEnabled(), "The search is disabled") |
|
38 |
|
39 is(gBrowser.tabs.length, 1, "There is one tab before cmd/ctrl + t is pressed"); |
|
40 |
|
41 whenTabViewIsHidden(function() { |
|
42 is(gBrowser.tabs.length, 2, "There are two tabs after cmd/ctrl + t is pressed"); |
|
43 |
|
44 gBrowser.tabs[0].linkedBrowser.loadURI("about:mozilla"); |
|
45 gBrowser.tabs[1].linkedBrowser.loadURI("http://example.com/"); |
|
46 |
|
47 afterAllTabsLoaded(function () { |
|
48 showTabView(test4); |
|
49 }); |
|
50 }); |
|
51 EventUtils.synthesizeKey("t", { accelKey: true }, contentWindow); |
|
52 } |
|
53 |
|
54 function test4() { |
|
55 is(gBrowser.tabs.length, 2, "There are two tabs"); |
|
56 |
|
57 let onTabClose = function() { |
|
58 gBrowser.tabContainer.removeEventListener("TabClose", onTabClose, true); |
|
59 executeSoon(function() { |
|
60 is(gBrowser.tabs.length, 1, "There is one tab after removing one"); |
|
61 |
|
62 EventUtils.synthesizeKey("t", { accelKey: true, shiftKey: true }, contentWindow); |
|
63 is(gBrowser.tabs.length, 2, "There are two tabs after restoring one"); |
|
64 |
|
65 gBrowser.tabs[0].linkedBrowser.loadURI("about:blank"); |
|
66 gBrowser.selectedTab = gBrowser.tabs[0]; |
|
67 test8(); |
|
68 }); |
|
69 }; |
|
70 gBrowser.tabContainer.addEventListener("TabClose", onTabClose, true); |
|
71 gBrowser.removeTab(gBrowser.tabs[1]); |
|
72 } |
|
73 |
|
74 // below key combination shouldn't trigger actions in tabview UI |
|
75 function test8() { |
|
76 showTabView(function() { |
|
77 is(gBrowser.tabs.length, 2, "There are two tabs before cmd/ctrl + w is pressed"); |
|
78 EventUtils.synthesizeKey("w", { accelKey: true }, contentWindow); |
|
79 is(gBrowser.tabs.length, 2, "There are two tabs after cmd/ctrl + w is pressed"); |
|
80 |
|
81 gBrowser.removeTab(gBrowser.tabs[1]); |
|
82 test9(); |
|
83 }); |
|
84 } |
|
85 |
|
86 function test9() { |
|
87 let zoomLevel = ZoomManager.zoom; |
|
88 EventUtils.synthesizeKey("+", { accelKey: true }, contentWindow); |
|
89 is(ZoomManager.zoom, zoomLevel, "The zoom level remains unchanged after cmd/ctrl + + is pressed"); |
|
90 |
|
91 EventUtils.synthesizeKey("-", { accelKey: true }, contentWindow); |
|
92 is(ZoomManager.zoom, zoomLevel, "The zoom level remains unchanged after cmd/ctrl + - is pressed"); |
|
93 |
|
94 test10(); |
|
95 } |
|
96 |
|
97 function test10() { |
|
98 is(gBrowser.tabs.length, 1, "There is one tab before cmd/ctrl + shift + a is pressed"); |
|
99 // it would open about:addons on a new tab if it passes through the white list. |
|
100 EventUtils.synthesizeKey("a", { accelKey: true, shiftKey: true }, contentWindow); |
|
101 |
|
102 executeSoon(function() { |
|
103 is(gBrowser.tabs.length, 1, "There is still one tab after cmd/ctrl + shift + a is pressed"); |
|
104 hideTabView(finish); |
|
105 }) |
|
106 } |