|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 function test() { |
|
5 let cw, search, searchButton; |
|
6 |
|
7 let assertSearchIsEnabled = function () { |
|
8 isnot(search.style.display, "none", "search is enabled"); |
|
9 } |
|
10 |
|
11 let assertSearchIsDisabled = function () { |
|
12 is(search.style.display, "none", "search is disabled"); |
|
13 } |
|
14 |
|
15 let testSearchInitiatedByKeyPress = function () { |
|
16 EventUtils.synthesizeKey("a", {}, cw); |
|
17 assertSearchIsEnabled(); |
|
18 |
|
19 EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw); |
|
20 assertSearchIsDisabled(); |
|
21 } |
|
22 |
|
23 let testSearchInitiatedByMouseClick = function () { |
|
24 EventUtils.sendMouseEvent({type: "mousedown"}, searchButton, cw); |
|
25 assertSearchIsEnabled(); |
|
26 |
|
27 EventUtils.synthesizeKey("a", {}, cw); |
|
28 EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw); |
|
29 EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw); |
|
30 assertSearchIsEnabled(); |
|
31 |
|
32 EventUtils.synthesizeKey("VK_ESCAPE", {}, cw); |
|
33 assertSearchIsDisabled(); |
|
34 } |
|
35 |
|
36 waitForExplicitFinish(); |
|
37 |
|
38 newWindowWithTabView(function (win) { |
|
39 registerCleanupFunction(function () win.close()); |
|
40 |
|
41 cw = win.TabView.getContentWindow(); |
|
42 search = cw.document.getElementById("search"); |
|
43 searchButton = cw.document.getElementById("searchbutton"); |
|
44 |
|
45 SimpleTest.waitForFocus(function () { |
|
46 assertSearchIsDisabled(); |
|
47 |
|
48 testSearchInitiatedByKeyPress(); |
|
49 testSearchInitiatedByMouseClick(); |
|
50 |
|
51 finish(); |
|
52 }, cw); |
|
53 }); |
|
54 } |