OLD | NEW |
1 <!DOCTYPE HTML> | |
2 <html> | 1 <html> |
3 <body> | 2 <body> |
4 <script src="../../resources/js-test.js"></script> | 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../resources/testharnessreport.js"></script> |
5 <div id="container"> | 5 <div id="container"> |
| 6 |
6 <div> | 7 <div> |
7 <a id="link1" href="#">Link</a> | 8 <a id="link1" href="#">Link</a> |
8 <button id="button1">Button</button> | 9 <button id="button1">Button</button> |
9 <input id="text1" type="text"> | 10 <input id="text1" type="text"> |
10 <input id="checkbox1" type="checkbox"> | 11 <input id="checkbox1" type="checkbox"> |
11 <input id="radio1" type="radio"> | 12 <input id="radio1" type="radio"> |
12 <input id="slider1" type="range"> | 13 <input id="slider1" type="range"> |
13 <input id="submit1" type="submit"> | 14 <input id="submit1" type="submit"> |
14 <select id="combobox1"><option>1<option>2</select> | 15 <select id="combobox1"><option>1<option>2</select> |
15 <select id="listbox1" multiple><option>1<option>2</select> | 16 <select id="listbox1" multiple><option>1<option>2</select> |
(...skipping 11 matching lines...) Expand all Loading... |
27 <input id="submit2" type="submit"> | 28 <input id="submit2" type="submit"> |
28 <select id="combobox2"><option>1<option>2</select> | 29 <select id="combobox2"><option>1<option>2</select> |
29 <select id="listbox2" multiple><option>1<option>2</select> | 30 <select id="listbox2" multiple><option>1<option>2</select> |
30 <textarea id="textarea2"></textarea> | 31 <textarea id="textarea2"></textarea> |
31 <div id="focusable2" tabindex="0">Focusable</div> | 32 <div id="focusable2" tabindex="0">Focusable</div> |
32 </canvas> | 33 </canvas> |
33 | 34 |
34 <canvas hidden id="hiddenCanvas" width="300" height="300"> | 35 <canvas hidden id="hiddenCanvas" width="300" height="300"> |
35 <a id="linkInHiddenCanvas" href="#">Link</a> | 36 <a id="linkInHiddenCanvas" href="#">Link</a> |
36 </canvas> | 37 </canvas> |
| 38 |
37 </div> | 39 </div> |
38 <div id="console"></div> | |
39 <script> | 40 <script> |
40 description("This test makes sure that focusable elements in canvas fallback con
tent are focusable."); | 41 var element; |
| 42 var previousFocusedElement; |
41 | 43 |
42 if (window.testRunner) | |
43 window.testRunner.dumpAsText(); | |
44 | |
45 var element; | |
46 function checkFocusable(id) { | 44 function checkFocusable(id) { |
47 debug(id + " should be focusable."); | |
48 element = document.getElementById(id); | 45 element = document.getElementById(id); |
49 element.focus(); | 46 element.focus(); |
50 shouldBe("document.activeElement == element", "true"); | 47 assert_true(document.activeElement == element); |
51 debug(""); | |
52 } | 48 } |
53 | 49 |
54 checkFocusable("link1"); | |
55 checkFocusable("button1"); | |
56 checkFocusable("text1"); | |
57 checkFocusable("checkbox1"); | |
58 checkFocusable("radio1"); | |
59 checkFocusable("slider1"); | |
60 checkFocusable("submit1"); | |
61 checkFocusable("combobox1"); | |
62 checkFocusable("listbox1"); | |
63 checkFocusable("textarea1"); | |
64 checkFocusable("focusable1"); | |
65 | |
66 checkFocusable("link2"); | |
67 checkFocusable("button2"); | |
68 checkFocusable("text2"); | |
69 checkFocusable("checkbox2"); | |
70 checkFocusable("radio2"); | |
71 checkFocusable("slider2"); | |
72 checkFocusable("submit2"); | |
73 checkFocusable("combobox2"); | |
74 checkFocusable("listbox2"); | |
75 checkFocusable("textarea2"); | |
76 checkFocusable("focusable2"); | |
77 | |
78 var previousFocusedElement; | |
79 function checkNotFocusable(id) { | 50 function checkNotFocusable(id) { |
80 debug(id + " should not be focusable."); | |
81 previousFocusedElement = document.activeElement; | 51 previousFocusedElement = document.activeElement; |
82 element = document.getElementById(id); | 52 element = document.getElementById(id); |
83 element.focus(); | 53 element.focus(); |
84 shouldBe("document.activeElement == previousFocusedElement", "true"); | 54 assert_true(document.activeElement == previousFocusedElement); |
85 debug(""); | |
86 } | 55 } |
87 | 56 |
88 checkNotFocusable("linkInHiddenCanvas"); | 57 var focusableTestScenarios = [ |
| 58 ['FocusableTestCase1', "link1"], |
| 59 ['FocusableTestCase2', "button1"], |
| 60 ['FocusableTestCase3', "text1"], |
| 61 ['FocusableTestCase4', "checkbox1"], |
| 62 ['FocusableTestCase5', "radio1"], |
| 63 ['FocusableTestCase6', "slider1"], |
| 64 ['FocusableTestCase7', "submit1"], |
| 65 ['FocusableTestCase8', "combobox1"], |
| 66 ['FocusableTestCase9', "listbox1"], |
| 67 ['FocusableTestCase10', "textarea1"], |
| 68 ['FocusableTestCase11', "focusable1"], |
89 | 69 |
| 70 ['FocusableTestCase12', "link2"], |
| 71 ['FocusableTestCase13', "button2"], |
| 72 ['FocusableTestCase14', "text2"], |
| 73 ['FocusableTestCase15', "checkbox2"], |
| 74 ['FocusableTestCase16', "radio2"], |
| 75 ['FocusableTestCase17', "slider2"], |
| 76 ['FocusableTestCase18', "submit2"], |
| 77 ['FocusableTestCase19', "combobox2"], |
| 78 ['FocusableTestCase20', "listbox2"], |
| 79 ['FocusableTestCase21', "textarea2"], |
| 80 ['FocusableTestCase22', "focusable2"] |
| 81 ]; |
| 82 |
| 83 var notFocusableTestScenarios = [ |
| 84 ['NotFocusableTestCase', "linkInHiddenCanvas"], |
| 85 ]; |
| 86 |
| 87 generate_tests(checkFocusable, focusableTestScenarios); |
| 88 generate_tests(checkNotFocusable, notFocusableTestScenarios); |
90 document.querySelector("#container").remove(); | 89 document.querySelector("#container").remove(); |
| 90 |
91 </script> | 91 </script> |
92 | |
93 </body> | 92 </body> |
94 </html> | 93 </html> |
OLD | NEW |