| OLD | NEW |
| 1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
| 2 <script src="../resources/gc.js"></script> | 2 <script src="../resources/gc.js"></script> |
| 3 <script src="../resources/testharness.js"></script> | 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> | 4 <script src="../resources/testharnessreport.js"></script> |
| 5 | 5 |
| 6 <!-- | 6 <!-- |
| 7 | 7 |
| 8 Accessibility Object Model | 8 Accessibility Object Model |
| 9 Explainer: https://github.com/WICG/aom/blob/master/explainer.md | 9 Explainer: https://github.com/WICG/aom/blob/master/explainer.md |
| 10 Spec: https://wicg.github.io/aom/spec/ | 10 Spec: https://wicg.github.io/aom/spec/ |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 var button = document.getElementById("button"); | 45 var button = document.getElementById("button"); |
| 46 var aomButton = button.accessibleNode; | 46 var aomButton = button.accessibleNode; |
| 47 var axButton = accessibilityController.accessibleElementById("button"); | 47 var axButton = accessibilityController.accessibleElementById("button"); |
| 48 | 48 |
| 49 button.setAttribute("role", "checkbox"); | 49 button.setAttribute("role", "checkbox"); |
| 50 button.setAttribute("aria-label", "Check Me"); | 50 button.setAttribute("aria-label", "Check Me"); |
| 51 | 51 |
| 52 assert_equals(axButton.role, "AXRole: AXCheckBox"); | 52 assert_equals(axButton.role, "AXRole: AXCheckBox"); |
| 53 assert_equals(axButton.name, "Check Me"); | 53 assert_equals(axButton.name, "Check Me"); |
| 54 | 54 |
| 55 assert_equals(aomButton.role, "checkbox"); | 55 assert_equals(aomButton.role, null); |
| 56 assert_equals(aomButton.label, "Check Me"); | 56 assert_equals(aomButton.label, null); |
| 57 }, "ARIA attributes are reflected into AOM properties"); | 57 }, "ARIA attributes are not reflected into AOM properties"); |
| 58 | 58 |
| 59 test(function(t) { | 59 test(function(t) { |
| 60 var button = document.getElementById("button"); | 60 var button = document.getElementById("button"); |
| 61 var aomButton = button.accessibleNode; | |
| 62 var axButton = accessibilityController.accessibleElementById("button"); | |
| 63 | |
| 64 button.setAttribute("role", "beyonce"); | |
| 65 | |
| 66 assert_equals(axButton.role, "AXRole: AXButton"); | |
| 67 | |
| 68 assert_equals(aomButton.role, "beyonce"); | |
| 69 }, "Invalid ARIA roles are still reflected into AOM properties"); | |
| 70 | |
| 71 test(function(t) { | |
| 72 var button = document.getElementById("button"); | |
| 73 var aomButton = button.accessibleNode; | 61 var aomButton = button.accessibleNode; |
| 74 var axButton = accessibilityController.accessibleElementById("button"); | 62 var axButton = accessibilityController.accessibleElementById("button"); |
| 75 | 63 |
| 76 aomButton.role = "slider"; | 64 aomButton.role = "slider"; |
| 77 assert_equals(aomButton.role, "slider"); | 65 assert_equals(aomButton.role, "slider"); |
| 78 assert_equals(axButton.role, "AXRole: AXSlider"); | 66 assert_equals(axButton.role, "AXRole: AXSlider"); |
| 79 }, "Test setting AccessibleNode.role"); | 67 }, "Test setting AccessibleNode.role"); |
| 80 | 68 |
| 81 test(function(t) { | 69 test(function(t) { |
| 82 var button = document.getElementById("button"); | 70 var button = document.getElementById("button"); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 assert_equals(axButton.role, "AXRole: AXTextField"); | 142 assert_equals(axButton.role, "AXRole: AXTextField"); |
| 155 assert_equals(axButton.name, "ARIA"); | 143 assert_equals(axButton.name, "ARIA"); |
| 156 | 144 |
| 157 aomButton.role = "radio"; | 145 aomButton.role = "radio"; |
| 158 aomButton.label = "AOM"; | 146 aomButton.label = "AOM"; |
| 159 assert_equals(axButton.role, "AXRole: AXRadioButton"); | 147 assert_equals(axButton.role, "AXRole: AXRadioButton"); |
| 160 assert_equals(axButton.name, "AOM"); | 148 assert_equals(axButton.name, "AOM"); |
| 161 | 149 |
| 162 aomButton.role = null; | 150 aomButton.role = null; |
| 163 aomButton.label = null; | 151 aomButton.label = null; |
| 164 assert_equals(axButton.role, "AXRole: AXButton"); | 152 assert_equals(axButton.role, "AXRole: AXTextField"); |
| 165 assert_equals(axButton.name, "Click Me"); | 153 assert_equals(axButton.name, "ARIA"); |
| 166 | 154 }, "Clearing an AOM property falls back on an ARIA attribute"); |
| 167 button.setAttribute("role", "combobox"); | |
| 168 button.setAttribute("aria-label", "ARIA 2"); | |
| 169 assert_equals(axButton.role, "AXRole: AXButton"); | |
| 170 assert_equals(axButton.name, "Click Me"); | |
| 171 }, "Once an AOM property has been set, ARIA no longer has any effect"); | |
| 172 </script> | 155 </script> |
| 173 | 156 |
| 174 <button id="button4">Click Me</button> | 157 <button id="button4">Click Me</button> |
| 175 | 158 |
| 176 <script> | 159 <script> |
| 177 test(function(t) { | 160 test(function(t) { |
| 178 var aomButton; | 161 var aomButton; |
| 179 (function() { | 162 (function() { |
| 180 var button = document.getElementById("button4"); | 163 var button = document.getElementById("button4"); |
| 181 button.setAttribute("role", "checkbox"); | |
| 182 button.setAttribute("aria-label", "Check Me"); | |
| 183 aomButton = button.accessibleNode; | 164 aomButton = button.accessibleNode; |
| 165 aomButton.role = "checkbox"; |
| 166 aomButton.label = "Check Me"; |
| 184 })(); | 167 })(); |
| 185 assert_equals(aomButton.role, "checkbox"); | 168 assert_equals(aomButton.role, "checkbox"); |
| 186 assert_equals(aomButton.label, "Check Me"); | 169 assert_equals(aomButton.label, "Check Me"); |
| 187 | 170 |
| 188 (function() { | 171 (function() { |
| 189 var button = document.getElementById("button4"); | 172 var button = document.getElementById("button4"); |
| 190 button.parentElement.removeChild(button); | 173 button.parentElement.removeChild(button); |
| 191 })(); | 174 })(); |
| 192 gc(); | 175 gc(); |
| 193 | 176 |
| 194 assert_equals(aomButton.role, "checkbox"); | 177 assert_equals(aomButton.role, "checkbox"); |
| 195 assert_equals(aomButton.label, "Check Me"); | 178 assert_equals(aomButton.label, "Check Me"); |
| 196 }, "An AccessibleNode keeps its element alive."); | 179 }, "An AccessibleNode keeps its element alive."); |
| 197 </script> | 180 </script> |
| OLD | NEW |