blob: beb03dbbc0f0c4c5ca4a592d2cb71075c46e1c0d [file] [log] [blame]
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
<body>
<select size="1">
<option id="opt1" value="1">1</option>
<option id="opt2" value="2">2</option>
<option id="opt2" value="3">3</option>
</select>
<div id="console"></div>
</body>
<script>
var selectElement = document.getElementsByTagName('select')[0];
var optionElements = selectElement.getElementsByTagName('option');
shouldBe("selectElement.selectedIndex = 0; selectElement.selectedIndex", "0");
shouldBe("optionElements[0].selected", "true");
shouldBe("optionElements[1].selected", "false");
shouldBe("optionElements[2].selected", "false");
shouldBe("selectElement.selectedIndex = -1; selectElement.selectedIndex", "-1");
shouldBe("optionElements[0].selected", "false");
shouldBe("optionElements[1].selected", "false");
shouldBe("optionElements[2].selected", "false");
shouldBe("selectElement.selectedIndex = -2; selectElement.selectedIndex", "-1");
optionElements[2].selected = true;
optionElements[1].selected = true;
shouldBe("selectElement.selectedIndex", "1");
shouldBe("optionElements[0].selected", "false");
shouldBe("optionElements[1].selected", "true");
shouldBe("optionElements[2].selected", "false");
optionElements[1].selected = true;
optionElements[2].selected = true;
shouldBe("selectElement.selectedIndex", "2");
shouldBe("optionElements[0].selected", "false");
shouldBe("optionElements[1].selected", "false");
shouldBe("optionElements[2].selected", "true");
optionElements[0].selected = false;
optionElements[2].selected = false;
shouldBe("selectElement.selectedIndex", "0");
shouldBe("optionElements[0].selected", "true");
shouldBe("optionElements[1].selected", "false");
shouldBe("optionElements[2].selected", "false");
optionElements[0].disabled = true;
optionElements[0].selected = false;
shouldBe("selectElement.selectedIndex", "1");
shouldBe("optionElements[0].selected", "false");
shouldBe("optionElements[1].selected", "true");
shouldBe("optionElements[2].selected", "false");
</script>
</html>