blob: a5c78d9d69b12d969633dac96c71ad90808207dd [file] [edit]
<html>
<head>
<script src="../../resources/accessibility-helper.js"></script>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<div id="button1" role="button" aria-pressed="false" tabindex="0"></div>
<div id="button2" role="button" aria-pressed="true" tabindex="0"></div>
<p id="description"></p>
<div id="console"></div>
<script>
window.jsTestIsAsync = true;
description("This tests that changing the aria-pressed value results in a state-changed notification.");
if (window.testRunner && window.accessibilityController) {
var notificationCount = 0;
accessibilityController.addNotificationListener(function(element, notification, state) {
if (notification != "AXPressedStateChanged")
return;
debug(notification + " " + (state == "1") + " on " + element.domIdentifier);
++notificationCount;
});
var button1 = accessibilityController.accessibleElementById("button1");
var button2 = accessibilityController.accessibleElementById("button2");
var element = document.getElementById("button1");
element.focus();
debug("Setting aria-pressed to true on button1.");
element.setAttribute("aria-pressed", "true");
element = document.getElementById("button2");
element.focus();
debug("Setting aria-pressed to false on button2.");
element.setAttribute("aria-pressed", "false");
window.setTimeout(async function() {
await waitFor(() => {
return notificationCount == 2;
});
accessibilityController.removeNotificationListener();
finishJSTest();
}, 0);
}
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>