blob: 7c1a1a0b20e4d64625904a7c4457078806e502e5 [file] [log] [blame]
<html>
<html>
<head>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body id="body">
<div role="group" id="parent">
<div role="button" id="button1">Button 1</div>
<div role="button" id="button2">Button 2</div>
<div role="button" id="button3">Button 3</div>
</div>
<script>
function axElementById(id) {
return accessibilityController.accessibleElementById(id);
}
test((t) => {
// Get the parent element.
var parent = axElementById("parent");
// Get all three children.
var button1 = axElementById("button1");
var button2 = axElementById("button2");
var button3 = axElementById("button3");
// Verify that the 3 children are present.
assert_equals(parent.childAtIndex(0).name, button1.name, "button1 is first");
assert_equals(parent.childAtIndex(1).name, button2.name, "button2 is second");
assert_equals(parent.childAtIndex(2).name, button3.name, "button3 is third");
// Make the 2nd button hidden. Only 1 and 3 should be present.
document.getElementById("button2").setAttribute("aria-hidden", "true");
assert_equals(parent.childAtIndex(0).name, button1.name, "button1 is first after setting button2 aria-hidden");
assert_equals(parent.childAtIndex(1).name, button3.name, "button3 is second after setting button2 aria-hidden");
// Make the 1st button hidden. Only 3 should be present.
document.getElementById("button1").setAttribute("aria-hidden", "true");
assert_equals(parent.childAtIndex(0).name, button3.name, "button3 is first after setting button1 aria-hidden");
// Make the 2nd button not hidden. 2 and 3 should be present.
document.getElementById("button2").setAttribute("aria-hidden", "false");
assert_equals(parent.childAtIndex(0).name, button2.name, "button2 is first after clearning button2 aria-hidden");
assert_equals(parent.childAtIndex(1).name, button3.name, "button3 is second after clearing button2 aria-hidden");
}, "This test makes sure that when aria-hidden changes, the AX hierarchy is updated.");
</script>
</body>
</html>