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

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

Issue 2750533006: Initial skeleton of Accessibility Object Model Phase 1 (Closed)
Patch Set: Add comment about ugly AXObjectCache interface 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 <button id="button">Click Me</button>
14
15 <script>
16 if (window.internals)
17 internals.runtimeFlags.accessibilityObjectModelEnabled = true;
18
19 test(function(t) {
20 var button = document.getElementById("button");
21 assert_equals(button.nodeType, Node.ELEMENT_NODE);
22 assert_not_equals(button.accessibleNode, null);
23 }, "DOM Elements have an AccessibleNode");
24
25 test(function(t) {
26 var button = document.getElementById("button");
27 var staticText = button.firstChild;
28 assert_equals(staticText.nodeType, Node.TEXT_NODE);
29 assert_not_equals(staticText.accessibleNode, null);
30 }, "DOM Text nodes do not have an AccessibleNode.");
31
32 test(function(t) {
33 var button = document.getElementById("button");
34 var aomButton = button.accessibleNode;
35
36 assert_equals(aomButton.role, null);
37 assert_equals(aomButton.label, null);
38 assert_equals(aomButton.foo, undefined);
39 assert_equals(aomButton.bar, undefined);
40 }, "Supported properties on an AccessibleNode are all null by default");
41
42 test(function(t) {
43 var button = document.getElementById("button");
44 var aomButton = button.accessibleNode;
45 var axButton = accessibilityController.accessibleElementById("button");
46
47 button.setAttribute("role", "checkbox");
48 button.setAttribute("aria-label", "Check Me");
49
50 assert_equals(axButton.role, "AXRole: AXCheckBox");
51 assert_equals(axButton.name, "Check Me");
52
53 assert_equals(aomButton.role, null);
54 assert_equals(aomButton.label, null);
55 }, "AccessibleNode does not reflect ARIA attributes.");
56
57 test(function(t) {
58 var button = document.getElementById("button");
59 var aomButton = button.accessibleNode;
60 var axButton = accessibilityController.accessibleElementById("button");
61
62 button.removeAttribute("role");
63 aomButton.role = "slider";
64 assert_equals(aomButton.role, "slider");
65 assert_equals(axButton.role, "AXRole: AXSlider");
66 }, "Test setting AccessibleNode.role");
67
68 test(function(t) {
69 var button = document.getElementById("button");
70 var aomButton = button.accessibleNode;
71 var axButton = accessibilityController.accessibleElementById("button");
72
73 aomButton.role = null;
74 assert_equals(aomButton.role, null);
75 assert_equals(axButton.role, "AXRole: AXButton");
76
77 aomButton.role = "doctor";
78 assert_equals(aomButton.role, null);
79 assert_equals(axButton.role, "AXRole: AXButton");
80 }, "An invalid role should be ignored.");
81
82 test(function(t) {
83 var button = document.getElementById("button");
84 var aomButton = button.accessibleNode;
85 var axButton = accessibilityController.accessibleElementById("button");
86
87 aomButton.role = "switch checkbox";
88 assert_equals(aomButton.role, "switch checkbox");
89 assert_equals(axButton.role, "AXRole: AXSwitch");
90
91 aomButton.role = "tickbox checkbox";
92 assert_equals(aomButton.role, "tickbox checkbox");
93 assert_equals(axButton.role, "AXRole: AXCheckBox");
94 }, "Fallback roles are supported.");
95
96 test(function(t) {
97 var button = document.getElementById("button");
98 var aomButton = button.accessibleNode;
99 var axButton = accessibilityController.accessibleElementById("button");
100
101 button.removeAttribute("aria-label");
102 aomButton.label = "New Label";
103 assert_equals(aomButton.label, "New Label");
104 assert_equals(axButton.name, "New Label");
105 }, "Test setting AccessibleNode.label");
106
107 test(function(t) {
108 var button = document.getElementById("button");
109 var aomButton = button.accessibleNode;
110 var axButton = accessibilityController.accessibleElementById("button");
111
112 button.removeAttribute("role");
113 button.removeAttribute("aria-label");
114 aomButton.role = "radio";
115 aomButton.label = "AOM";
116 assert_equals(axButton.role, "AXRole: AXRadioButton");
117 assert_equals(axButton.name, "AOM");
118
119 button.setAttribute("role", "textbox");
120 button.setAttribute("aria-label", "ARIA");
121 assert_equals(axButton.role, "AXRole: AXTextField");
122 assert_equals(axButton.name, "ARIA");
123 }, "Test that ARIA attributes override AOM properties");
124 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698