blob: 9c9eb93f0d0b610c7a969f61a2a85bbd1d146073 [file] [log] [blame]
<!doctype HTML>
<html>
<meta charset="utf8">
<title>Content Visibility: accessibility</title>
<link rel="author" title="Rakina Zata Amni" href="mailto:rakina@chromium.org">
<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 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 when locked, the ignored text nodes don't show up as children; so we expect 2.
t.step(() => { assert_equals(axTarget.childrenCount, 2, "When locked, nodes in hidden subtree are ignored"); });
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));
}
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");
t.step(() => { assert_equals(axTarget.childrenCount, 3, "After getting unlocked, nodes in hidden subtree are not ignored"); });
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));
}
t.done();
}));
}, "Nodes in hidden non-activatable tree are not exposed to accessibility tree");
</script>