blob: 2a849b1e2608be4069a0f01b8355546c7a4c787e [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<style>
.offscreen {
position:relative;
top:9999px;
}
</style>
<title>Search Predicate Element Count</title>
</head>
<body>
<div id="container">
<p id="start">Start</p>
<!-- Headings. -->
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5 class="offscreen">Heading 5</h5>
<h6 class="offscreen">Heading 6</h6>
<br>
<!-- Tables. -->
<table border="1">
<tr><th>A</th><th>B</th></tr>
<tr><td>C</td><td>D</td></tr>
</table>
<table border="1">
<tr><th>W</th><th>X</th></tr>
<tr><td>Y</td><td>Z</td></tr>
</table>
<br>
<!-- Links. -->
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
<br>
<!-- Images. -->
<img alt="Cake" src="resources/cake.png">
<img alt="Cake" src="resources/cake.png">
<img alt="Cake" src="resources/cake.png">
<img alt="Cake" src="resources/cake.png">
<br>
<!-- Inputs. -->
<input type="submit" value="Submit">
<div role="checkbox">Role checkbox</div>
<div role="radio">Role radio</div>
<div role="searchbox">Role searchbox</div>
<div role="switch">Role switch</div>
<br>
<!-- Form controls. -->
<button>Button</button>
<div role="button">Role button</div>
<div role="combobox">Role combobox</div>
<div role="slider">Role slider</div>
<div role="textbox">Role textbox</div>
<!-- The following two are popup buttons and are also form controls. -->
<button aria-haspopup="menu">Button with aria-haspopup</button>
<div role="button" aria-haspopup="menu">Role button with aria-haspopup</div>
</div>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests that search predicate based element count results are accurate.");
if (window.accessibilityController) {
document.getElementById("container").focus();
var containerElement = accessibilityController.focusedElement;
var startElement = accessibilityController.accessibleElementById("start");
// Tables.
var tableCount = containerElement.uiElementCountForSearchPredicate(startElement, true, "AXTableSearchKey", "", false);
shouldBe("tableCount", "2");
// Links.
var linkCount = containerElement.uiElementCountForSearchPredicate(startElement, true, "AXLinkSearchKey", "", false);
shouldBe("linkCount", "3");
// Images.
var imageCount = containerElement.uiElementCountForSearchPredicate(startElement, true, "AXGraphicSearchKey", "", false);
shouldBe("imageCount", "4");
// Inputs.
var inputCount = containerElement.uiElementCountForSearchPredicate(startElement, true, "AXButtonSearchKey", "", false);
shouldBe("inputCount", "5");
// Form controls include inputs, so the count should be the sum of inputs and controls.
var controlCount = containerElement.uiElementCountForSearchPredicate(startElement, true, "AXControlSearchKey", "", false);
shouldBe("controlCount", "12");
// Headings.
var headingCount = containerElement.uiElementCountForSearchPredicate(startElement, true, "AXHeadingSearchKey", "", false);
shouldBe("headingCount", "6");
// Onscreen
var onscreenCount = containerElement.uiElementCountForSearchPredicate(startElement, true, "AXHeadingSearchKey", "", false);
shouldBe("onscreenCount", "6");
// Offscreen
var offscreenCount = containerElement.uiElementCountForSearchPredicate(startElement, true, "AXHeadingSearchKey", "", true);
shouldBe("offscreenCount", "4");
// Hide superfluous text.
document.getElementById("container").style.display = "none";
}
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>