blob: 963438e7a9c18403524b9f1a4fa2bf69dbb4f2a4 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
</head>
<body id="body">
<select id="group" multiple="multiple">
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
<option>Option 4</option>
</select>
<p id="description"></p>
<div id="console"></div>
<script>
description("Tests that checks whether setting selection at the given index works correctly");
if (window.accessibilityController) {
document.getElementById("group").focus();
var selectElement = accessibilityController.focusedElement;
shouldBe("selectElement.selectedChildrenCount", "0");
var option1 = selectElement.childAtIndex(0);
var option2 = selectElement.childAtIndex(1);
var option3 = selectElement.childAtIndex(2);
var option4 = selectElement.childAtIndex(3);
selectElement.setSelectedChildAtIndex(0);
shouldBe("selectElement.selectedChildrenCount", "1");
shouldBeTrue("option1.isSelected");
shouldBeTrue("selectElement.selectedChildAtIndex(0).isEqual(option1)");
selectElement.setSelectedChildAtIndex(1);
shouldBe("selectElement.selectedChildrenCount", "2");
shouldBeTrue("option2.isSelected");
shouldBeTrue("selectElement.selectedChildAtIndex(1).isEqual(option2)");
shouldBeFalse("option3.isSelected");
selectElement.setSelectedChildAtIndex(3);
shouldBe("selectElement.selectedChildrenCount", "3");
shouldBeTrue("option4.isSelected");
// The index expected by selectedChildAtIndex is with respect to the array of
// selected children; not the array of all children. The element whose text is
// "Option 4" is the third of three selected items, thus the index should be 2.
shouldBeTrue("selectElement.selectedChildAtIndex(2).isEqual(option4)");
// atk_selection_remove_selection() works like atk_selection_ref_selection()
// in that the index is with respect to the array of selected children; not
// the array of all children. Thus to remove the selection from "Option 4"
// in ATK, we again need to specify an index of 2.
if (accessibilityController.platformName == "atk")
selectElement.removeSelectionAtIndex(2);
else
selectElement.removeSelectionAtIndex(3);
shouldBeFalse("option4.isSelected");
shouldBe("selectElement.selectedChildrenCount", "2");
selectElement.removeSelectionAtIndex(1);
shouldBeFalse("option2.isSelected");
shouldBe("selectElement.selectedChildrenCount", "1");
selectElement.removeSelectionAtIndex(0);
shouldBeFalse("option1.isSelected");
shouldBe("selectElement.selectedChildrenCount", "0");
}
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>