blob: 953e5a6f12bb2cd2c69a5ece61e1fdb4e6fe44e4 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body id="body">
<ul id="tree0" role="tree" aria-labelledby="treelabel" aria-activedescendant="tree0_item0_2_0_1" tabindex="0">
<li id="tree0_item0" role="treeitem" aria-level="1" aria-expanded="true">
<span>
<span class="expander"></span>
Animals
</span>
<ul role="group">
<li id="tree0_item0_0" role="treeitem" aria-level="2"><span>Birds</span></li>
</ul>
</li>
</ul>
<p id="description"></p>
<div id="console"></div>
<div id="notifications"></div>
<script>
description("This tests that when aria-expanded is toggled, the appropriate notifications are sent out");
var axTree = 0;
var notifyCount = 0;
var notifyName = 0;
// The order of notifications should be Row Count, Row Collapsed, Row Count, Row Expanded
function notifyCallback(element, notification) {
if (notification == "AXLoadComplete" || notification == "AXLayoutComplete")
return;
notifyName = notification;
if (notifyCount == 0)
shouldBeEqualToString("notifyName", "AXRowCountChanged");
else if (notifyCount == 1)
shouldBeEqualToString("notifyName", "AXRowCollapsed");
else if (notifyCount == 2)
shouldBeEqualToString("notifyName", "AXRowCountChanged");
else if (notifyCount == 3) {
shouldBeEqualToString("notifyName", "AXRowExpanded");
accessibilityController.removeNotificationListener();
finishJSTest();
}
notifyCount++;
}
if (window.accessibilityController) {
jsTestIsAsync = true;
var domTree = document.getElementById("tree0");
domTree.focus();
axTree = window.accessibilityController.focusedElement;
var addedNotification = accessibilityController.addNotificationListener(notifyCallback);
shouldBe("addedNotification", "true");
accessibilityController.accessibleElementById("tree0");
accessibilityController.accessibleElementById("tree0_item0");
// the first aria-expanded should generate row count, row collapsed.
document.getElementById("tree0_item0").setAttribute("aria-expanded", "false");
// the second aria-expanded should generate row count, row expanded.
document.getElementById("tree0_item0").setAttribute("aria-expanded", "true");
}
</script>
</body>
</html>