Chromium Code Reviews| OLD | NEW |
|---|---|
| (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) { | |
|
aboxhall
2017/03/16 05:49:33
I imagine we'll want to split these out into separ
dmazzoni
2017/03/16 20:43:13
Agreed. For now it's simpler to have them in one p
| |
| 20 var button = document.getElementById("button"); | |
| 21 assert_true(button.nodeType == 1); // ELEMENT | |
|
aboxhall
2017/03/16 05:49:33
Why not just use Node.ELEMENT_NODE ?
Also, could u
dmazzoni
2017/03/16 20:43:12
Done.
| |
| 22 assert_true(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_true(staticText.nodeType == 3); // TEXT | |
|
aboxhall
2017/03/16 05:49:33
Node.TEXT_NODE
dmazzoni
2017/03/16 20:43:12
Done.
| |
| 29 assert_false(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_true(aomButton.role === null); | |
| 37 assert_true(aomButton.label === null); | |
| 38 assert_true(aomButton.foo === undefined); | |
| 39 assert_true(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_true(aomButton.role === null); | |
| 54 assert_true(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 aomButton.role = "slider"; | |
| 63 assert_equals(aomButton.role, "slider"); | |
| 64 assert_equals(axButton.role, "AXRole: AXSlider"); | |
| 65 }, "Test setting AccessibleNode.role"); | |
| 66 | |
| 67 test(function(t) { | |
| 68 var button = document.getElementById("button"); | |
| 69 var aomButton = button.accessibleNode; | |
| 70 var axButton = accessibilityController.accessibleElementById("button"); | |
| 71 | |
| 72 button.removeAttribute("role"); | |
| 73 aomButton.role = null; | |
| 74 assert_true(aomButton.role === null); | |
| 75 assert_equals(axButton.role, "AXRole: AXButton"); | |
| 76 | |
| 77 aomButton.role = "doctor"; | |
| 78 assert_true(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 aomButton.label = "New Label"; | |
| 102 assert_equals(aomButton.label, "New Label"); | |
| 103 assert_equals(axButton.name, "New Label"); | |
| 104 }, "Test setting AccessibleNode.label"); | |
| 105 </script> | |
|
aboxhall
2017/03/16 05:49:33
Do we want a test asserting the precedence order o
dmazzoni
2017/03/16 20:43:11
The tests were kind of doing that implicitly.
I a
| |
| OLD | NEW |