blob: d9e6d90375df41b093bc1de6befd6a527e2522e0 [file] [edit]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/accessibility-helper.js"></script>
<script src="../../resources/js-test.js"></script>
</head>
<body id="body">
<a id="link" href="#image">link</a>
<a id="display-contents-link" style="display:contents" href="#foo">display:contents link</a>
<script>
var output = "This tests the ability to search for accessible elements by key or text.\n\n";
if (window.accessibilityController) {
window.jsTestIsAsync = true;
window.testRunner.keepWebHistory();
var firstLinkText, resultElement, webArea;
document.getElementById("body").focus();
setTimeout(async function() {
await waitFor(() => {
webArea = accessibilityController.focusedElement;
return webArea && webArea.role && webArea.role.includes("WebArea");
});
// Start search for the second link from the text of the first link.
// This works around a quirky difference between display:contents links and non-display:contents links.
// The text within a non-display:contents link takes the style from its parent, and the style is how we determine whether a link is visited or unvisited.
// This means AXUnvisitedLinkSearchKey / AXVisitedLinkSearchKey will match for the link itself, and the text within. The same does not happen for text within display:contents links.
// This might not be the right behavior (especially for macOS -- but may be fine for iOS). https://bugs.webkit.org/show_bug.cgi?id=255579
firstLinkText = webArea.childAtIndex(0).childAtIndex(0);
resultElement = webArea.uiElementForSearchPredicate(webArea, true, "AXUnvisitedLinkSearchKey", "", false);
output += expect("resultElement.boolAttributeValue('AXVisited')", "false");
output += expect("resultElement.domIdentifier", "'link'");
resultElement = webArea.uiElementForSearchPredicate(firstLinkText, true, "AXUnvisitedLinkSearchKey", "", false);
output += expect("resultElement.boolAttributeValue('AXVisited')", "false");
output += expect("resultElement.domIdentifier", "'display-contents-link'");
// Visit the links.
webArea.childAtIndex(0).press();
webArea.childAtIndex(1).press();
// Wait for them to be visited.
await waitFor(() => {
resultElement = webArea.uiElementForSearchPredicate(webArea, true, "AXVisitedLinkSearchKey", "", false);
return resultElement;
})
output += expect("resultElement.boolAttributeValue('AXVisited')", "true");
output += expect("resultElement.domIdentifier", "'link'");
await waitFor(() => {
resultElement = webArea.uiElementForSearchPredicate(firstLinkText, true, "AXVisitedLinkSearchKey", "", false);
return resultElement;
})
output += expect("resultElement.boolAttributeValue('AXVisited')", "true");
output += expect("resultElement.domIdentifier", "'display-contents-link'");
debug(output);
finishJSTest();
});
}
</script>
</body>
</html>