blob: d92289d38b431c3c87329f68ffd496dca5346a6c [file] [edit]
<html>
<head>
<script src="../../resources/accessibility-helper.js"></script>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<div id="content" role="list" tabindex="0">
<div id="item1" role="listitem">1</div>
<div id="item2" role="listitem" aria-current="page">2</div>
<div id="item3" role="listitem">3</div>
</div>
<p id="description"></p>
<div id="console"></div>
<script>
window.jsTestIsAsync = true;
description("This tests that changing the aria-current value results in a state-changed notification.");
if (window.testRunner && window.accessibilityController) {
var notificationCount = 0;
accessibilityController.addNotificationListener(function(element, notification) {
if (notification != "ActiveStateChanged")
return;
debug(notification + ": " + element.title + " " + element.role);
++notificationCount;
});
document.getElementById("content").focus();
var item1 = accessibilityController.accessibleElementById("item1");
shouldBe("item1.currentStateValue", "'false'");
var item2 = accessibilityController.accessibleElementById("item2");
shouldBe("item2.currentStateValue", "'page'");
var item3 = accessibilityController.accessibleElementById("item3");
shouldBe("item3.currentStateValue", "'false'");
debug("Setting aria-current to false on item2.");
document.getElementById("item2").setAttribute("aria-current", "false");
debug("Setting aria-current to page on item3.");
document.getElementById("item3").setAttribute("aria-current", "page");
document.getElementById("content").style.visibility = "hidden";
window.setTimeout(async function() {
await waitFor(() => {
return notificationCount == 2;
});
shouldBe("item1.currentStateValue", "'false'");
shouldBe("item2.currentStateValue", "'false'");
shouldBe("item3.currentStateValue", "'page'");
accessibilityController.removeNotificationListener();
finishJSTest();
}, 0);
}
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>