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