| <!DOCTYPE html> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| <style> |
| p::first-letter { |
| font-size: 200%; |
| } |
| </style> |
| <h1 id="heading">Test heading</h1> |
| <p id="text">Test text</p> |
| <script> |
| test(function () { |
| if (!window.accessibilityController) { |
| assert_unreached("This test requires accessibilityController."); |
| return; |
| } |
| |
| // Test an element that gets its own accessible name. |
| let element = accessibilityController.accessibleElementById("heading"); |
| assert_equals(element.name, "Test heading"); |
| |
| function getAccessibilityChildren(element) { |
| let children = []; |
| let childrenCount = element.childrenCount; |
| for (let i = 0; i < childrenCount; i++) { |
| let child = element.childAtIndex(i); |
| children.push(child); |
| child.children = getAccessibilityChildren(child); |
| } |
| return children; |
| } |
| |
| // Test by concatenating names of all children. |
| element = accessibilityController.accessibleElementById("text"); |
| let children = getAccessibilityChildren(element); |
| assert_equals(children.length, 1); |
| let name = children.map(e => e.name).join(''); |
| assert_equals(name, "Test text"); |
| }); |
| </script> |