OLD | NEW |
1 <select id="test" size="3"> | 1 <select id="test" size="3"> |
2 </select> | 2 </select> |
3 <div id="console"></div> | 3 <div id="console"></div> |
4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
5 <script> | 5 <script> |
6 function reset(mySelect) { | 6 function reset(mySelect) { |
7 mySelect.length = 0; | 7 mySelect.length = 0; |
8 mySelect.options[mySelect.length] = new Option("one", "value", true, true); | 8 mySelect.options[mySelect.length] = new Option("one", "value", true, true); |
9 mySelect.options[mySelect.length] = new Option("two", "value", true, true); | 9 mySelect.options[mySelect.length] = new Option("two", "value", true, true); |
10 } | 10 } |
11 | 11 |
12 var mySelect = document.getElementById("test"); | 12 var mySelect = document.getElementById("test"); |
13 reset(mySelect); | 13 reset(mySelect); |
14 var i = 0; | 14 var i = 0; |
15 | 15 |
16 debug((++i) + ") setting length to a negative length"); | 16 debug((++i) + ") setting length to a negative length"); |
17 shouldThrow("mySelect.options.length = -1;"); | 17 mySelect.options.length = -1; |
18 shouldBe("mySelect.options.length", "2"); | 18 shouldBe("mySelect.options.length", "2"); |
19 shouldBe("mySelect.selectedIndex", "1"); | 19 shouldBe("mySelect.selectedIndex", "1"); |
20 | 20 |
21 debug((++i) + ") setting length to a larger length"); | 21 debug((++i) + ") setting length to a larger length"); |
22 mySelect.options.length = 5; | 22 mySelect.options.length = 5; |
23 shouldBe("mySelect.options.length", "5"); | 23 shouldBe("mySelect.options.length", "5"); |
24 shouldBe("mySelect.selectedIndex", "1"); | 24 shouldBe("mySelect.selectedIndex", "1"); |
25 | 25 |
26 debug((++i) + ") setting length to a smaller length"); | 26 debug((++i) + ") setting length to a smaller length"); |
27 mySelect.options.length = 2; | 27 mySelect.options.length = 2; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 debug((++i) + ") trying to set a option element using an invalid index: positive
infinity"); | 135 debug((++i) + ") trying to set a option element using an invalid index: positive
infinity"); |
136 mySelect.options[1/0] = document.createElement("option"); | 136 mySelect.options[1/0] = document.createElement("option"); |
137 shouldBe("mySelect.options.length", "10"); | 137 shouldBe("mySelect.options.length", "10"); |
138 shouldBe("mySelect.selectedIndex", "-1"); | 138 shouldBe("mySelect.selectedIndex", "-1"); |
139 | 139 |
140 debug((++i) + ") trying to add a non-option element"); | 140 debug((++i) + ") trying to add a non-option element"); |
141 shouldThrow("mySelect.options.add({})"); | 141 shouldThrow("mySelect.options.add({})"); |
142 shouldBe("mySelect.options.length", "10"); | 142 shouldBe("mySelect.options.length", "10"); |
143 shouldBe("mySelect.selectedIndex", "-1"); | 143 shouldBe("mySelect.selectedIndex", "-1"); |
144 | 144 |
| 145 debug((++i) + ") setting length to a value greater than 10000"); |
| 146 mySelect.options.length = 10001; |
| 147 shouldBe("mySelect.options.length", "10"); |
| 148 shouldBe("mySelect.selectedIndex", "-1"); |
| 149 |
145 debug(""); | 150 debug(""); |
146 </script> | 151 </script> |
OLD | NEW |