chromium/third_party/blink/web_tests/accessibility/aria-hidden-hides-all-elements.html

<!DOCTYPE HTML>
<html>
<head>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body id="body">

<div id="content" role="group">

<main id="main" aria-hidden="true">
    <video controls="controls"></video>
    <select id="select"><option>a</select>
    <input type="range">
    <input type="data">
    <progress></progress>
    <ul id="ul"><li>item</li></ul>
    <select size="10"><option>a</select>
    <img src="resources/cake.png" width="145" height="126" usemap="#map">
    <map name="map">
        <area shape="rect" coords="0,0,100,100" href="#" alt="cake">
    </map>
</main>
<button aria-describedby="main">Do not remove aria-hidden nodes from tree within #main</button>

</div>

<script>
function expectUnignoredChildren(parent, expected_unignored_child_indices) {
    for (let i = 0; i < parent.childrenCount; i++) {
      let child = parent.childAtIndex(i);
      if (expected_unignored_child_indices.includes(i)) {
        assert_false(child.isIgnored,
                    'Child#' + i + ' (' + child.role + ') ignored state: ');
      }
      else {
        assert_true(child.isIgnored,
                    'Child#' + i + ' (' + child.role + ') ignored state: ');
      }
    }
}

test(function(t) {
    var content = accessibilityController.accessibleElementById("main");
    assert_equals(content.childrenCount, 8);
    assert_true(content.isIgnored);
    expectUnignoredChildren(content, []);

    document.getElementById("ul").tabIndex = 0;
    document.getElementById("ul").focus();
    content = accessibilityController.accessibleElementById("main");
    assert_equals(content.childrenCount, 8,
                      "Focusing list should make everything unignored");
    assert_false(content.isIgnored, "There is no reason to mark the main content as ignored now that its aria-hidden has been marked as illegal.");
    expectUnignoredChildren(content, [0, 1, 2, 3, 4, 5, 6, 7]);

    document.getElementById("ul").removeAttribute("tabindex");
    content = accessibilityController.accessibleElementById("main");
    assert_equals(content.childrenCount, 8,
                          "Making list unfocusable should not change which items are ignored, since the aria-hidden is permanently repaired to the value of false");
    assert_false(content.isIgnored);
    expectUnignoredChildren(content, [0, 1, 2, 3, 4, 5, 6, 7]);
});
</script>

</body>
</html>