|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
3 */ |
|
4 |
|
5 // Bug 570760 - Make ctrl-f and / focus the search box in the add-ons manager |
|
6 |
|
7 var gManagerWindow; |
|
8 var focusCount = 0; |
|
9 |
|
10 function test() { |
|
11 waitForExplicitFinish(); |
|
12 |
|
13 open_manager(null, function(aWindow) { |
|
14 gManagerWindow = aWindow; |
|
15 |
|
16 var searchBox = gManagerWindow.document.getElementById("header-search"); |
|
17 function focusHandler() { |
|
18 searchBox.blur(); |
|
19 focusCount++; |
|
20 } |
|
21 searchBox.addEventListener("focus", focusHandler); |
|
22 f_key_test(); |
|
23 slash_key_test(); |
|
24 searchBox.removeEventListener("focus", focusHandler); |
|
25 end_test(); |
|
26 }); |
|
27 } |
|
28 |
|
29 function end_test() { |
|
30 close_manager(gManagerWindow, finish); |
|
31 } |
|
32 |
|
33 function f_key_test() { |
|
34 EventUtils.synthesizeKey("f", { accelKey: true }, gManagerWindow); |
|
35 is(focusCount, 1, "Search box should have been focused due to the f key"); |
|
36 } |
|
37 |
|
38 function slash_key_test() { |
|
39 EventUtils.synthesizeKey("/", { }, gManagerWindow); |
|
40 is(focusCount, 2, "Search box should have been focused due to the / key"); |
|
41 } |