<!doctype HTML>
<html>
<meta charset="utf8">
<title>Content Visibility: accessibility</title>
<link rel="author" title="Rakina Zata Amni" href="mailto:[email protected]">
<link rel="help" href="https://github.com/WICG/display-locking">
<meta name="assert" content="content-visibility hidden subtree is not exposed to accessibility">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
.hidden {
content-visibility: hidden;
}
</style>
<div id="container">
<div role="group" id="target" class=hidden aria-labelledby="target_label">
target
<div id="child">
child
</div>
<div id="target_label">Label</div>
</div>
</div>
<script>
function axElementById(id) {
return accessibilityController.accessibleElementById(id);
}
async_test((t) => {
let target = document.getElementById("target");
let axTarget = axElementById("target");
t.step(() => { assert_false(axTarget.isIgnored); });
// Note that all children are ignored: most are not included in the tree. The
// one child that is included, is the target of an aria-labelledby relation.
t.step(() => { assert_equals(axTarget.childrenCount, 1); });
t.step(() => { assert_equals(axTarget.name, "Label"); });
for (let i = 0; i < axTarget.childrenCount; ++i) {
const axChild = axTarget.childAtIndex(i);
t.step(() => assert_true(axChild.isIgnored, "When locked, nodes in hidden subtree are ignored"));
}
target.classList.remove("hidden");
requestAnimationFrame(() => requestAnimationFrame(() => {
// The ax object for #target got replaced since the layout object changed, so use the new ax object.
axTarget = axElementById("target");
// There are now 3 children, as the whitespace nodes are no longer included in the tree.
// This is the same as it would be if content-visibility had never been used.
t.step(() => { assert_equals(axTarget.childrenCount, 3); });
t.step(() => { assert_equals(axTarget.name, "Label"); });
for (let i = 0; i < axTarget.childrenCount; ++i) {
const axChild = axTarget.childAtIndex(i);
t.step(() => { assert_false(axChild.isIgnored, "After update, isIgnored is false on child #" + i); });
}
t.done();
}));
}, "Nodes in hidden non-activatable tree are not exposed to accessibility tree");
</script>