OLD | NEW |
1 <select multiple id="test" size="3"> | 1 <select multiple 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", "0"); | 19 shouldBe("mySelect.selectedIndex", "0"); |
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", "0"); | 24 shouldBe("mySelect.selectedIndex", "0"); |
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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 debug((++i) + ") trying to set a option element using an invalid index: NaN"); | 130 debug((++i) + ") trying to set a option element using an invalid index: NaN"); |
131 mySelect.options[0/0] = document.createElement("option"); | 131 mySelect.options[0/0] = document.createElement("option"); |
132 shouldBe("mySelect.options.length", "10"); | 132 shouldBe("mySelect.options.length", "10"); |
133 shouldBe("mySelect.selectedIndex", "0"); | 133 shouldBe("mySelect.selectedIndex", "0"); |
134 | 134 |
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", "0"); | 138 shouldBe("mySelect.selectedIndex", "0"); |
139 | 139 |
| 140 debug((++i) + ") setting length to a value greater than 10000"); |
| 141 mySelect.options.length = 10001; |
| 142 shouldBe("mySelect.options.length", "10"); |
| 143 shouldBe("mySelect.selectedIndex", "0"); |
| 144 |
140 debug(""); | 145 debug(""); |
141 </script> | 146 </script> |
OLD | NEW |