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 function test() {
5 let cw, search, searchButton;
7 let assertSearchIsEnabled = function () {
8 isnot(search.style.display, "none", "search is enabled");
9 }
11 let assertSearchIsDisabled = function () {
12 is(search.style.display, "none", "search is disabled");
13 }
15 let testSearchInitiatedByKeyPress = function () {
16 EventUtils.synthesizeKey("a", {}, cw);
17 assertSearchIsEnabled();
19 EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw);
20 assertSearchIsDisabled();
21 }
23 let testSearchInitiatedByMouseClick = function () {
24 EventUtils.sendMouseEvent({type: "mousedown"}, searchButton, cw);
25 assertSearchIsEnabled();
27 EventUtils.synthesizeKey("a", {}, cw);
28 EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw);
29 EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw);
30 assertSearchIsEnabled();
32 EventUtils.synthesizeKey("VK_ESCAPE", {}, cw);
33 assertSearchIsDisabled();
34 }
36 waitForExplicitFinish();
38 newWindowWithTabView(function (win) {
39 registerCleanupFunction(function () win.close());
41 cw = win.TabView.getContentWindow();
42 search = cw.document.getElementById("search");
43 searchButton = cw.document.getElementById("searchbutton");
45 SimpleTest.waitForFocus(function () {
46 assertSearchIsDisabled();
48 testSearchInitiatedByKeyPress();
49 testSearchInitiatedByMouseClick();
51 finish();
52 }, cw);
53 });
54 }