| <!DOCTYPE html> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| |
| <div id="main"> |
| <a id="anchor1" href="#emptyAnchor">Empty anchor</a> |
| <a id="anchor2" href="#anchorWithContent">Anchor with content</a> |
| <a id="anchor3" href="#anchorWithID">Anchor with ID</a> |
| <a id="anchor4" href="#emptySpan">Empty span</a> |
| <a id="anchor5" href="#spanWithContent">Span with content</a> |
| <a id="anchor6" href="#paragraphWithContent">Paragraph with content</a> |
| |
| <p><a name="emptyAnchor"></a>After empty anchor</p> |
| <p><a name="anchorWithContent">Anchor with content</a></p> |
| <p><a id="anchorWithID">Anchor with ID</a></p> |
| <p><span id="emptySpan"></span>After empty span</span></p> |
| <p><span id="spanWithContent">Span with content</span></p> |
| <p id="paragraphWithContent">Paragraph with content</p> |
| </div> |
| |
| <script> |
| test(function() { |
| var anchor = accessibilityController.accessibleElementById('anchor1'); |
| assert_not_equals(anchor, undefined); |
| var target = anchor.inPageLinkTarget; |
| assert_not_equals(target, undefined); |
| // AXAncor because this is how the "a" tag is marked in the accessibility tree |
| // when it's a target and not a link. |
| assert_equals(target.role, 'AXRole: AXAnchor'); |
| assert_equals(target.name, ''); |
| }, 'Test finding the target when it is an empty anchor.'); |
| |
| test(function() { |
| var anchor = accessibilityController.accessibleElementById('anchor2'); |
| assert_not_equals(anchor, undefined); |
| var target = anchor.inPageLinkTarget; |
| assert_not_equals(target, undefined); |
| // AXAncor because this is how the "a" tag is marked in the accessibility tree |
| // when it's a target and not a link. |
| assert_equals(target.role, 'AXRole: AXAnchor'); |
| assert_equals(target.name, 'Anchor with content'); |
| }, 'Test finding the target when it is an anchor with content.'); |
| |
| test(function() { |
| var anchor = accessibilityController.accessibleElementById('anchor3'); |
| assert_not_equals(anchor, undefined); |
| var target = anchor.inPageLinkTarget; |
| assert_not_equals(target, undefined); |
| // AXAncor because this is how the "a" tag is marked in the accessibility tree |
| // when it's a target and not a link. |
| assert_equals(target.role, 'AXRole: AXAnchor'); |
| assert_equals(target.name, 'Anchor with ID'); |
| }, 'Test finding the target when it is an anchor with ID.'); |
| |
| test(function() { |
| var anchor = accessibilityController.accessibleElementById('anchor4'); |
| assert_not_equals(anchor, undefined); |
| var target = anchor.inPageLinkTarget; |
| assert_not_equals(target, undefined); |
| assert_equals(target.role, 'AXRole: AXStaticText'); |
| assert_equals(target.name, 'After empty span'); |
| }, 'Test finding an approximate target when the real one is an empty span.'); |
| |
| test(function() { |
| var anchor = accessibilityController.accessibleElementById('anchor5'); |
| assert_not_equals(anchor, undefined); |
| var target = anchor.inPageLinkTarget; |
| assert_not_equals(target, undefined); |
| assert_equals(target.role, 'AXRole: AXStaticText'); |
| assert_equals(target.name, 'Span with content'); |
| }, 'Test finding the target when it is a span with content.'); |
| |
| test(function() { |
| var anchor = accessibilityController.accessibleElementById('anchor6'); |
| assert_not_equals(anchor, undefined); |
| var target = anchor.inPageLinkTarget; |
| assert_not_equals(target, undefined); |
| assert_equals(target.role, 'AXRole: AXParagraph'); |
| }, 'Test finding the target when it is a paragraph.'); |
| </script> |
| |
| <script> |
| if (window.testRunner) |
| document.getElementById("main").style.display = "none"; |
| </script> |