blob: 2791c4341800dd9245caecc6fc7b4ec7f35901ba [file] [log] [blame]
<!DOCTYPE HTML>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="../resources/accessibility-helper.js"></script>
</head>
<body>
<!-- implicit level of tag -->
<h1 class="ex" data-expected="1">X</h1>
<h2 class="ex" data-expected="2">X</h2>
<h3 class="ex" data-expected="3">X</h3>
<h4 class="ex" data-expected="4">X</h4>
<h5 class="ex" data-expected="5">X</h5>
<h6 class="ex" data-expected="6">X</h6>
<!-- explicit aria-level overrides on h1-h6 (withOUT explicit heading role declaration) -->
<h6 class="ex" data-expected="1" aria-level="1">X</h6>
<h5 class="ex" data-expected="2" aria-level="2">X</h5>
<h4 class="ex" data-expected="3" aria-level="3">X</h4>
<h3 class="ex" data-expected="4" aria-level="4">X</h3>
<h2 class="ex" data-expected="5" aria-level="5">X</h2>
<h1 class="ex" data-expected="6" aria-level="6">X</h1>
<!-- explicit aria-level overrides on h1-h6 (with explicit heading role declaration) -->
<h6 class="ex" role="heading" data-expected="1" aria-level="1">X</h6>
<h5 class="ex" role="heading" data-expected="2" aria-level="2">X</h5>
<h4 class="ex" role="heading" data-expected="3" aria-level="3">X</h4>
<h3 class="ex" role="heading" data-expected="4" aria-level="4">X</h3>
<h2 class="ex" role="heading" data-expected="5" aria-level="5">X</h2>
<h1 class="ex" role="heading" data-expected="6" aria-level="6">X</h1>
<!-- explicit aria-level set on div with explicit heading role declaration -->
<div class="ex" role="heading" data-expected="1" aria-level="1">X</div>
<div class="ex" role="heading" data-expected="2" aria-level="2">X</div>
<div class="ex" role="heading" data-expected="3" aria-level="3">X</div>
<div class="ex" role="heading" data-expected="4" aria-level="4">X</div>
<div class="ex" role="heading" data-expected="5" aria-level="5">X</div>
<div class="ex" role="heading" data-expected="6" aria-level="6">X</div>
<!-- implicit level for heading role -->
<div class="ex" role="heading" data-expected="2">X</div>
<!-- todo: h1 elements nested in section elements should inherit nested level. -->
<script>
description("This tests that headings have a level matching the implicit default value or explicitly defined aria-level value.")
if (window.testRunner && window.accessibilityController) {
window.jsTestIsAsync = true;
setTimeout(async () => {
var examples = document.querySelectorAll('.ex');
for (let i = 0; i < examples.length; ++i) {
window.el = examples[i];
el.id = `ex${i}`;
window.axElement = null;
await waitFor(() => {
axElement = accessibilityController.accessibleElementById(el.id);
return axElement;
});
// Test AXLevel.
shouldBe("axElement.intValue", "parseInt(el.getAttribute('data-expected'))");
el.style.display = 'none'; // Hide each example after verification.
}
finishJSTest();
}, 0);
}
</script>
</body>
</html>