blob: 8d175c8d4946211808de202bd08abdfdce29f09a [file] [log] [blame]
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body id="body">
<select id="selectElement" title="selectElement">
<option SELECTED>Option 1</option>
<option>Option 2</option>
<option DISABLED>Option 3</option>
</select>
<p>This tests that non-multiple select elements expose their list options.</p>
<p id="notDRT">This test should only be run inside of DumpRenderTree.</p>
<p id="console"></p>
<script>
function dumpListOptionAttributes(list) {
for (var i = 0; i < list.childrenCount; ++i) {
var option = list.childAtIndex(i);
debug('option.title: ' + option.title);
debug('option.role: ' + option.role);
debug('option.width: ' + option.width);
debug('option.height: ' + option.height);
debug('option.x: ' + option.x);
debug('option.y: ' + option.y);
debug('option.isOffScreen: ' + option.isOffScreen);
debug('option.isEnabled: ' + option.isEnabled);
debug('option.isVisible: ' + option.isVisible);
debug('option.isSelected: ' + option.isSelected);
debug('option.isSelectable: ' + option.isSelectable);
debug("");
}
debug("---\n");
}
if (window.testRunner && window.accessibilityController) {
document.getElementById("notDRT").style.visibility = "hidden";
document.getElementById("selectElement").focus();
var selectElement = accessibilityController.focusedElement;
shouldBe('selectElement.role', '"AXRole: combo box"');
shouldBeFalse('selectElement.isMultiSelectable');
shouldBeTrue('selectElement.isCollapsed');
shouldBeTrue('selectElement.hasPopup');
debug("");
var list = accessibilityController.focusedElement.childAtIndex(0);
shouldBe('list.role', '"AXRole: list"');
shouldBeFalse('list.isVisible');
shouldBeTrue('list.isOffScreen');
debug("");
dumpListOptionAttributes(list);
document.getElementById("selectElement").selectedIndex = 1;
dumpListOptionAttributes(list);
document.getElementById("selectElement").selectedIndex = 0;
document.getElementById("selectElement").disabled = true;
dumpListOptionAttributes(list);
document.getElementById("selectElement").disabled = false;
selectElement.showMenu();
shouldBeFalse('selectElement.isCollapsed');
shouldBeFalse('list.isOffScreen');
debug("");
dumpListOptionAttributes(list);
// Test that accessing a detached <option> does not crash.
var option = list.childAtIndex(0);
shouldBeTrue('option.width != 0');
document.getElementById("selectElement").options[0] = null;
shouldBeTrue('option.width == 0');
}
</script>
</body>
</html>