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.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 let contentWindow;
6 function test() {
7 requestLongerTimeout(2);
8 waitForExplicitFinish();
10 showTabView(test1);
11 }
13 function test1() {
14 ok(TabView.isVisible(), "Tab View is visible");
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 }
24 function test2() {
25 ok(TabView.isVisible(), "Tab View is visible");
27 whenSearchIsEnabled(function() {
28 ok(contentWindow.Search.isEnabled(), "The search is enabled")
30 whenSearchIsDisabled(test3);
31 hideSearch();
32 });
33 EventUtils.synthesizeKey("f", { accelKey: true }, contentWindow);
34 }
36 function test3() {
37 ok(!contentWindow.Search.isEnabled(), "The search is disabled")
39 is(gBrowser.tabs.length, 1, "There is one tab before cmd/ctrl + t is pressed");
41 whenTabViewIsHidden(function() {
42 is(gBrowser.tabs.length, 2, "There are two tabs after cmd/ctrl + t is pressed");
44 gBrowser.tabs[0].linkedBrowser.loadURI("about:mozilla");
45 gBrowser.tabs[1].linkedBrowser.loadURI("http://example.com/");
47 afterAllTabsLoaded(function () {
48 showTabView(test4);
49 });
50 });
51 EventUtils.synthesizeKey("t", { accelKey: true }, contentWindow);
52 }
54 function test4() {
55 is(gBrowser.tabs.length, 2, "There are two tabs");
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");
62 EventUtils.synthesizeKey("t", { accelKey: true, shiftKey: true }, contentWindow);
63 is(gBrowser.tabs.length, 2, "There are two tabs after restoring one");
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 }
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");
81 gBrowser.removeTab(gBrowser.tabs[1]);
82 test9();
83 });
84 }
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");
91 EventUtils.synthesizeKey("-", { accelKey: true }, contentWindow);
92 is(ZoomManager.zoom, zoomLevel, "The zoom level remains unchanged after cmd/ctrl + - is pressed");
94 test10();
95 }
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);
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 }