OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
5 <script src="resources/common.js"></script> | 5 <script src="resources/common.js"></script> |
6 </head> | 6 </head> |
7 <body> | 7 <body> |
8 <input id="search" type="search" onsearch="searchEventDispatched()" /> | 8 <input id="search" type="search" onsearch="searchEventDispatched()" /> |
9 <p id="description"> | 9 <p id="description"> |
10 | 10 |
11 </p> | 11 </p> |
12 | 12 |
13 <script> | 13 <script> |
14 var searchEventObserved; | 14 var searchEventObserved; |
15 | 15 |
16 description("This tests if the value in a search input form is cleared and a 'se
arch' event is triggered, when we press the Escape key. " + | 16 description("This tests if the value in a search input form is cleared and a 'se
arch' event is triggered, when we press the Escape key. " + |
17 "To run (a part of) this test manually, type some text in the search
form and then press the Escape key. " + | 17 "To run (a part of) this test manually, type some text in the search
form and then press the Escape key. " + |
18 "If the text is cleared, then the test passes."); | 18 "If the text is cleared, then the test passes."); |
19 | 19 |
20 if (window.testRunner && window.eventSender) { | 20 if (window.testRunner && window.eventSender) { |
21 var input = $("search"); | 21 var input = $("search"); |
22 var enabled = false; | 22 var enabled = false; |
23 var disabled = true; | 23 var disabled = true; |
24 var readonly = true; | 24 var readonly = true; |
25 | 25 |
26 searchEventObserved = false; | 26 searchEventObserved = false; |
27 input.focus(); | 27 input.focus(); |
28 setInputAttributes(input, "foo", enabled); | 28 setInputAttributes(input, "foo", enabled); |
29 eventSender.keyDown("\x1B"); | 29 eventSender.keyDown("escape"); |
30 shouldBeEqualToString('input.value', ""); | 30 shouldBeEqualToString('input.value', ""); |
31 shouldBe('searchEventObserved', 'true'); | 31 shouldBe('searchEventObserved', 'true'); |
32 input.blur(); | 32 input.blur(); |
33 | 33 |
34 searchEventObserved = false; | 34 searchEventObserved = false; |
35 input.focus(); | 35 input.focus(); |
36 setInputAttributes(input, "", enabled); | 36 setInputAttributes(input, "", enabled); |
37 eventSender.keyDown("\x1B"); | 37 eventSender.keyDown("escape"); |
38 shouldBeEqualToString('input.value', ""); | 38 shouldBeEqualToString('input.value', ""); |
39 shouldBe('searchEventObserved', 'true'); | 39 shouldBe('searchEventObserved', 'true'); |
40 input.blur(); | 40 input.blur(); |
41 | 41 |
42 searchEventObserved = false; | 42 searchEventObserved = false; |
43 input.focus(); | 43 input.focus(); |
44 setInputAttributes(input, "foo", enabled, readonly); | 44 setInputAttributes(input, "foo", enabled, readonly); |
45 eventSender.keyDown("\x1B"); | 45 eventSender.keyDown("escape"); |
46 shouldBeEqualToString('input.value', "foo"); | 46 shouldBeEqualToString('input.value', "foo"); |
47 shouldBe('searchEventObserved', 'false'); | 47 shouldBe('searchEventObserved', 'false'); |
48 input.blur(); | 48 input.blur(); |
49 | 49 |
50 searchEventObserved = false; | 50 searchEventObserved = false; |
51 input.focus(); | 51 input.focus(); |
52 setInputAttributes(input, "foo", disabled); | 52 setInputAttributes(input, "foo", disabled); |
53 eventSender.keyDown("\x1B"); | 53 eventSender.keyDown("escape"); |
54 shouldBeEqualToString('input.value', "foo"); | 54 shouldBeEqualToString('input.value', "foo"); |
55 shouldBe('searchEventObserved', 'false'); | 55 shouldBe('searchEventObserved', 'false'); |
56 input.blur(); | 56 input.blur(); |
57 | 57 |
58 searchEventObserved = false; | 58 searchEventObserved = false; |
59 input.focus(); | 59 input.focus(); |
60 setInputAttributes(input, "foo", disabled, readonly); | 60 setInputAttributes(input, "foo", disabled, readonly); |
61 eventSender.keyDown("\x1B"); | 61 eventSender.keyDown("escape"); |
62 shouldBeEqualToString('input.value', "foo"); | 62 shouldBeEqualToString('input.value', "foo"); |
63 shouldBe('searchEventObserved', 'false'); | 63 shouldBe('searchEventObserved', 'false'); |
64 input.blur(); | 64 input.blur(); |
65 } | 65 } |
66 | 66 |
67 function setInputAttributes(input, text, disabled, readonly) { | 67 function setInputAttributes(input, text, disabled, readonly) { |
68 input.value = text; | 68 input.value = text; |
69 input.disabled = disabled; | 69 input.disabled = disabled; |
70 input.readOnly = !!readonly; | 70 input.readOnly = !!readonly; |
71 } | 71 } |
72 | 72 |
73 function searchEventDispatched() { | 73 function searchEventDispatched() { |
74 searchEventObserved = true; | 74 searchEventObserved = true; |
75 } | 75 } |
76 </script> | 76 </script> |
77 </body> | 77 </body> |
78 </html> | 78 </html> |
OLD | NEW |