Refactoring: Pull all fullscreen code out of Document and into its own helper class
[WebKit-https.git] / LayoutTests / accessibility / aria-required.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../resources/js-test-pre.js"></script>
5 </head>
6 <body id="body">
7
8 <div id="toBeHidden">
9
10
11   <!-- textfields -->
12   <input type="text" id="textfield" data-expectedrequired="false">
13   <input type="text" id="textfield_required" required data-expectedrequired="true">
14   <input type="text" required aria-required="true" id="textfield_required_ariarequired" data-expectedrequired="true">
15   <input type="text" aria-required="false" id="textfield_ariarequiredfalse" data-expectedrequired="false">
16   <!-- these last ones conflict with implicit value of @required, so host language attr should win -->
17   <input type="text" aria-required="textfield_required_ariarequiredfalse" required id="textfield5" data-expectedrequired="true">
18   <!-- BLOCKED by http://webkit.org/b/119988
19   <input type="text" aria-required="true" id="textfield_requiredfalse_ariarequiredtrue" data-expectedrequired="false">
20   -->
21
22
23   <!-- checkboxes -->
24   <input type="checkbox" id="checkbox" data-expectedrequired="false">
25   <input type="checkbox" id="checkbox_required" required data-expectedrequired="true">
26   <input type="checkbox" required aria-required="true" id="checkbox_required_ariarequired" data-expectedrequired="true">
27   <input type="checkbox" aria-required="false" id="checkbox_ariarequiredfalse" data-expectedrequired="false">
28   <!-- these last ones conflict with implicit value of @required, so ARIA should win -->
29   <input type="checkbox" aria-required="false" required id="checkbox_required_ariarequiredfalse" data-expectedrequired="false">
30   <input type="checkbox" aria-required="true" id="checkbox_requiredfalse_ariarequiredtrue" data-expectedrequired="true">
31
32
33   <!-- select -->
34   <select id="select" data-expectedrequired="false"><option>test</option></select>
35   <select id="select_required" required data-expectedrequired="true"><option>test</option></select>
36   <select required aria-required="true" id="select_required_ariarequired" data-expectedrequired="true"><option>test</option></select>
37   <select aria-required="false" id="select_ariarequiredfalse" data-expectedrequired="false"><option>test</option></select>
38   <!-- these last ones conflict with implicit value of @required, so ARIA should win -->
39   <select aria-required="false" required id="select_required_ariarequiredfalse" data-expectedrequired="false"><option>test</option></select>
40   <select aria-required="true" id="select_requiredfalse_ariarequiredtrue" data-expectedrequired="true"><option>test</option></select>
41
42   
43   <!-- textarea -->
44   <textarea id="textarea" data-expectedrequired="false"></textarea>
45   <textarea id="textarea_required" required data-expectedrequired="true"></textarea>
46   <textarea required aria-required="true" id="textarea_required_ariarequired" data-expectedrequired="true"></textarea>
47   <textarea aria-required="false" id="textarea_ariarequiredfalse" data-expectedrequired="false"></textarea>
48   <!-- these last ones conflict with implicit value of @required, so ARIA should win -->
49   <textarea aria-required="false" required id="textarea_required_ariarequiredfalse" data-expectedrequired="false"></textarea>
50   <textarea aria-required="true" id="textarea_requiredfalse_ariarequiredtrue" data-expectedrequired="true"></textarea>
51   
52
53   <!-- Custom ARIA controls (@required is not allowed on these elements, so no conflict resolution needed.) -->
54   <div tabindex="0" aria-required="true" role="listbox" id="listbox_ariarequiredtrue" data-expectedrequired="true">text</div>
55   <div tabindex="0" aria-required="false" role="listbox" id="listbox_ariarequiredfalse" data-expectedrequired="false">text</div>
56   <div tabindex="0" role="listbox" id="listbox" data-expectedrequired="false">text</div>
57
58   <div tabindex="0" aria-required="true" role="radiogroup" id="radiogroup_ariarequiredtrue" data-expectedrequired="true">text</div>
59   <div tabindex="0" aria-required="false" role="radiogroup" id="radiogroup_ariarequiredfalse" data-expectedrequired="false">text</div>
60   <div tabindex="0" role="radiogroup" id="radiogroup" data-expectedrequired="false">text</div>
61
62   <div tabindex="0" aria-required="true" role="spinbutton" id="spinbutton_ariarequiredtrue" data-expectedrequired="true">text</div>
63   <div tabindex="0" aria-required="false" role="spinbutton" id="spinbutton_ariarequiredfalse" data-expectedrequired="false">text</div>
64   <div tabindex="0" role="spinbutton" id="spinbutton" data-expectedrequired="false">text</div>
65
66   <div tabindex="0" aria-required="true" role="tree" id="tree_ariarequiredtrue" data-expectedrequired="true">text</div>
67   <div tabindex="0" aria-required="false" role="tree" id="tree_ariarequiredfalse" data-expectedrequired="false">text</div>
68   <div tabindex="0" role="tree" id="tree" data-expectedrequired="false">text</div>
69
70 </div>
71
72 <p id="description"></p>
73 <div id="console"></div>
74
75 <script>
76
77     description("This tests that aria-required is a usable attribute.");
78
79     if (window.accessibilityController) {
80
81         var result = document.getElementById('console');
82         var elements = document.querySelectorAll('[data-expectedrequired]');
83         result.innerText += "Elements to test: " + elements.length + "\n\n";
84
85         for (var i = 0, c = elements.length; i < c; i++) {
86             var el = elements[i];
87             var id = el.id;
88             var axElement = accessibilityController.accessibleElementById(id);
89             var isRequired = axElement.isRequired;
90
91             // Test whether elementis required.
92             var passed = el.dataset.expectedrequired === isRequired.toString();
93             var output = (passed ? "PASS" : "FAIL") + " " + id + " isRequired is " + isRequired;
94             if (!passed)
95                 output += ", expected " + el.dataset.expectedrequired;
96             result.innerText += output + "\n";
97         }
98
99     }
100
101     document.getElementById('toBeHidden').hidden = true; // hide this to avoid text diffs when adding more elements to the test
102
103 </script>
104
105 <script src="../resources/js-test-post.js"></script>
106 </body>
107 </html>