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