blob: e07f009c0126c5f9b9da48e17bd535347dfe7fbc [file] [edit]
<html>
<head>
<script src="../resources/accessibility-helper.js"></script>
<script src="../resources/js-test.js"></script>
</head>
<body>
<div id="content" role="group">
<img src="myimg.png" width="100" height="100" usemap="#mymap" alt="foo bar baz" />
<map name="mymap">
<area shape="rect" coords="0, 0, 33, 100" alt="foo" href="#">
<area shape="rect" coords="33, 0, 66, 100" alt="bar" href="#">
<area shape="rect" coords="66, 0, 100, 100" alt="baz" href="#">
</map>
</div>
<script>
let output = "This tests the hierarchy of an image with alt text and a map.\n\n";
function dumpAccessibilityChildren(element, level) {
if (!element)
return false;
let indent = "";
for (let k = 0; k < level; k++) { indent += " "; }
output += `${indent}${element.role} ${element.title} ${element.description}\n`;
let childrenCount = element.childrenCount;
for (let k = 0; k < childrenCount; k++) {
if (!dumpAccessibilityChildren(element.childAtIndex(k), level + 1))
return false;
}
return true;
}
if (window.accessibilityController) {
let content = accessibilityController.accessibleElementById("content");
dumpAccessibilityChildren(content, 0);
document.getElementById("content").style.visibility = "hidden";
debug(output);
}
</script>
</body>
</html>