Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: third_party/WebKit/LayoutTests/accessibility/aom.html

Issue 2750533006: Initial skeleton of Accessibility Object Model Phase 1 (Closed)
Patch Set: Use vector of pairs, add gc test Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE HTML>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4
5 <!--
6
7 Accessibility Object Model
8 Explainer: https://github.com/WICG/aom/blob/master/explainer.md
9 Spec: https://wicg.github.io/aom/spec/
10
11 -->
12
13 <script>
14 function gc()
esprehn 2017/03/28 21:39:58 Is this not in the testharness.js somewhere? Can y
dmazzoni 2017/03/29 07:00:42 Ah, found something in resources/gc.js. I filed ht
15 {
16 if (window.GCController)
17 return GCController.collect();
18
19 // Force garbage collection (FF requires about 9K allocations
20 // before a collect)
21 for (var i = 0; i < 10000; i++) {
22 var s = new String("abc");
23 }
24 }
25 </script>
26
27 <button id="button">Click Me</button>
28
29 <script>
30 if (window.internals)
31 internals.runtimeFlags.accessibilityObjectModelEnabled = true;
32
33 test(function(t) {
34 var button = document.getElementById("button");
35 assert_equals(button.nodeType, Node.ELEMENT_NODE);
36 assert_not_equals(button.accessibleNode, null);
37 }, "DOM Elements have an AccessibleNode");
38
39 test(function(t) {
40 var button = document.getElementById("button");
41 var staticText = button.firstChild;
42 assert_equals(staticText.nodeType, Node.TEXT_NODE);
43 assert_not_equals(staticText.accessibleNode, null);
44 }, "DOM Text nodes do not have an AccessibleNode.");
45
46 test(function(t) {
47 var button = document.getElementById("button");
48 var aomButton = button.accessibleNode;
49
50 assert_equals(aomButton.role, null);
51 assert_equals(aomButton.label, null);
52 assert_equals(aomButton.foo, undefined);
53 assert_equals(aomButton.bar, undefined);
54 }, "Supported properties on an AccessibleNode are all null by default");
55
56 test(function(t) {
57 var button = document.getElementById("button");
58 var aomButton = button.accessibleNode;
59 var axButton = accessibilityController.accessibleElementById("button");
60
61 button.setAttribute("role", "checkbox");
62 button.setAttribute("aria-label", "Check Me");
63
64 assert_equals(axButton.role, "AXRole: AXCheckBox");
65 assert_equals(axButton.name, "Check Me");
66
67 assert_equals(aomButton.role, "checkbox");
68 assert_equals(aomButton.label, "Check Me");
69 }, "ARIA attributes are reflected into AOM properties");
70
71 test(function(t) {
72 var button = document.getElementById("button");
73 var aomButton = button.accessibleNode;
74 var axButton = accessibilityController.accessibleElementById("button");
75
76 button.setAttribute("role", "beyonce");
77
78 assert_equals(axButton.role, "AXRole: AXButton");
79
80 assert_equals(aomButton.role, "beyonce");
81 }, "Invalid ARIA roles are still reflected into AOM properties");
82
83 test(function(t) {
84 var button = document.getElementById("button");
85 var aomButton = button.accessibleNode;
86 var axButton = accessibilityController.accessibleElementById("button");
87
88 aomButton.role = "slider";
89 assert_equals(aomButton.role, "slider");
90 assert_equals(axButton.role, "AXRole: AXSlider");
91 }, "Test setting AccessibleNode.role");
92
93 test(function(t) {
94 var button = document.getElementById("button");
95 var aomButton = button.accessibleNode;
96 var axButton = accessibilityController.accessibleElementById("button");
97
98 button.removeAttribute("role");
99 aomButton.role = null;
100 assert_equals(aomButton.role, null);
101 assert_equals(axButton.role, "AXRole: AXButton");
102
103 aomButton.role = "doctor";
104 assert_equals(aomButton.role, "doctor");
105 assert_equals(axButton.role, "AXRole: AXButton");
106 }, "An invalid role should be ignored if there's no ARIA.");
107
108 test(function(t) {
109 var button = document.getElementById("button");
110 var aomButton = button.accessibleNode;
111 var axButton = accessibilityController.accessibleElementById("button");
112
113 aomButton.role = "switch checkbox";
114 assert_equals(aomButton.role, "switch checkbox");
115 assert_equals(axButton.role, "AXRole: AXSwitch");
116
117 aomButton.role = "tickbox checkbox";
118 assert_equals(aomButton.role, "tickbox checkbox");
119 assert_equals(axButton.role, "AXRole: AXCheckBox");
120 }, "Fallback roles are supported.");
121
122 test(function(t) {
123 var button = document.getElementById("button");
124 var aomButton = button.accessibleNode;
125 var axButton = accessibilityController.accessibleElementById("button");
126
127 button.removeAttribute("aria-label");
128 aomButton.label = "New Label";
129 assert_equals(aomButton.label, "New Label");
130 assert_equals(axButton.name, "New Label");
131 }, "Test setting AccessibleNode.label");
132 </script>
133
134 <button id="button2">Click Me</button>
135
136 <script>
137 test(function(t) {
138 var button = document.getElementById("button2");
139 var aomButton = button.accessibleNode;
140 var axButton = accessibilityController.accessibleElementById("button2");
141
142 button.setAttribute("role", "textbox");
143 button.setAttribute("aria-label", "ARIA");
144 assert_equals(axButton.role, "AXRole: AXTextField");
145 assert_equals(axButton.name, "ARIA");
146
147 aomButton.role = "radio";
148 aomButton.label = "AOM";
149 assert_equals(axButton.role, "AXRole: AXRadioButton");
150 assert_equals(axButton.name, "AOM");
151 }, "Test that AOM properties override ARIA attributes");
152 </script>
153
154 <button id="button3">Click Me</button>
155
156 <script>
157 test(function(t) {
158 var button = document.getElementById("button3");
159 var aomButton = button.accessibleNode;
160 var axButton = accessibilityController.accessibleElementById("button3");
161 assert_equals(axButton.role, "AXRole: AXButton");
162 assert_equals(axButton.name, "Click Me");
163
164 button.setAttribute("role", "textbox");
165 button.setAttribute("aria-label", "ARIA");
166 assert_equals(axButton.role, "AXRole: AXTextField");
167 assert_equals(axButton.name, "ARIA");
168
169 aomButton.role = "radio";
170 aomButton.label = "AOM";
171 assert_equals(axButton.role, "AXRole: AXRadioButton");
172 assert_equals(axButton.name, "AOM");
173
174 aomButton.role = null;
175 aomButton.label = null;
176 assert_equals(axButton.role, "AXRole: AXButton");
177 assert_equals(axButton.name, "Click Me");
178
179 button.setAttribute("role", "combobox");
180 button.setAttribute("aria-label", "ARIA 2");
181 assert_equals(axButton.role, "AXRole: AXButton");
182 assert_equals(axButton.name, "Click Me");
183 }, "Once an AOM property has been set, ARIA no longer has any effect");
184 </script>
185
186 <button id="button4">Click Me</button>
187
188 <script>
189 test(function(t) {
190 var aomButton;
191 (function() {
192 var button = document.getElementById("button4");
193 button.setAttribute("role", "checkbox");
194 button.setAttribute("aria-label", "Check Me");
195 aomButton = button.accessibleNode;
196 })();
197 assert_equals(aomButton.role, "checkbox");
198 assert_equals(aomButton.label, "Check Me");
199
200 (function() {
201 var button = document.getElementById("button4");
202 button.parentElement.removeChild(button);
203 })();
204 gc();
205
206 assert_equals(aomButton.role, null);
207 assert_equals(aomButton.label, null);
esprehn 2017/03/28 21:39:58 This is leaking gc behavior, the AOMObject needs t
dmazzoni 2017/03/29 07:00:42 Done.
208
209 aomButton.role = "checkbox";
210 aomButton.label = "Check Me";
211
212 assert_equals(aomButton.role, null);
213 assert_equals(aomButton.label, null);
214 }, "No crash if AccessibleNode outlives its element.");
215 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698