Refactoring: Pull all fullscreen code out of Document and into its own helper class
[WebKit-https.git] / LayoutTests / accessibility / canvas-fallback-content.html
1 <!DOCTYPE HTML>
2 <html>
3 <body>
4 <script src="../resources/js-test-pre.js"></script>
5 <script src="../resources/accessibility-helper.js"></script>
6 <style>
7 myelement {
8   display: block;
9 }
10 </style>
11
12 <div>
13   <a id="link1" href="#">Link</a>
14   <button id="button1">Button</button>
15   <input id="text1" type="text">
16   <input id="checkbox1" type="checkbox">
17   <input id="radio1" type="radio">
18   <input id="submit1" type="submit">
19   <select id="combobox1"><option>1<option>2</select>
20   <myelement id="focusable1" tabindex="0">Focusable</myelement>
21   <div id="aria-button1" tabindex="0" role="button">ARIA button</div>
22   <div id="aria-link1" tabindex="0" role="link">ARIA link</div>
23 </div>
24
25 <canvas id="myCanvas" width="300" height="300">
26   <a id="link2" href="#">Link</a>
27   <button id="button2">Button</button>
28   <input id="text2" type="text">
29   <input id="checkbox2" type="checkbox">
30   <input id="radio2" type="radio">
31   <input id="submit2" type="submit">
32   <select id="combobox2"><option>1<option>2</select>
33   <myelement id="focusable2" tabindex="0">Focusable</myelement>
34   <div id="aria-button2" tabindex="0" role="button">ARIA button</div>
35   <div id="aria-link2" tabindex="0" role="link">ARIA link</div>
36 </canvas>
37
38 <div id="console"></div>
39 <script>
40 description("This test makes sure that focusable elements in canvas fallback content are accessible.");
41
42 if (window.testRunner && window.accessibilityController) {
43     window.jsTestIsAsync = true;
44     window.testRunner.dumpAsText();
45
46     function check(id, expectedRole) {
47         debug(id);
48         window.element = document.getElementById(id);
49         element.focus();
50         shouldBe("document.activeElement == element", "true");
51         window.axElement = accessibilityController.focusedElement;
52         shouldBe("axElement.role", "\"" + expectedRole + "\"");
53         debug("");
54     }
55
56     var comboBoxRole = platformRoleForComboBox(accessibilityController.platformName);
57
58     // Check rendered controls.
59     check("link1", "AXRole: AXLink");
60     check("button1", "AXRole: AXButton");
61     check("text1", "AXRole: AXTextField");
62     check("checkbox1", "AXRole: AXCheckBox");
63     check("radio1", "AXRole: AXRadioButton");
64     check("submit1", "AXRole: AXButton");
65     check("combobox1", comboBoxRole);
66     check("focusable1", "AXRole: AXGroup");
67     check("aria-button1", "AXRole: AXButton");
68     check("aria-link1", "AXRole: AXLink");
69
70     // Check unrendered controls inside a canvas.
71     check("link2", "AXRole: AXLink");
72     check("button2", "AXRole: AXButton");
73     check("text2", "AXRole: AXTextField");
74     check("checkbox2", "AXRole: AXCheckBox");
75     check("radio2", "AXRole: AXRadioButton");
76     check("submit2", "AXRole: AXButton");
77     check("combobox2", comboBoxRole);
78     check("focusable2", "AXRole: AXGroup");
79     check("aria-button2", "AXRole: AXButton");
80     check("aria-link2", "AXRole: AXLink");
81
82     // Check that the role is updated when the element changes.
83     document.getElementById('focusable1').setAttribute('role', 'button');
84     setTimeout(function() {
85         check("focusable1", "AXRole: AXButton");
86     }, 1);
87
88     document.getElementById('focusable2').setAttribute('role', 'button');
89     setTimeout(function() {
90         check("focusable2", "AXRole: AXButton");
91         finishJSTest();
92     }, 1);
93 }
94
95 </script>
96
97 <script src="../resources/js-test-post.js"></script>
98 </body>
99 </html>