OLD | NEW |
1 description("This test checks the behavior of the remove() method on the select.
options object."); | 1 description("This test checks the behavior of the remove() method on the select.
options object."); |
2 | 2 |
3 var select1 = document.getElementById("select1"); | 3 var select1 = document.getElementById("select1"); |
4 var value; | 4 var value; |
5 | 5 |
6 debug("1.1 Remove (object) from empty Options"); | 6 debug("1.1 Remove (object) from empty Options"); |
7 value = document.createElement("DIV"); | 7 value = document.createElement("DIV"); |
8 shouldBe("select1.options.remove(value)", "undefined"); | 8 shouldBe("select1.options.remove(value)", "undefined"); |
9 shouldBe("select1.options.length", "0"); | 9 shouldBe("select1.options.length", "0"); |
10 shouldBe("select1.selectedIndex", "-1"); | 10 shouldBe("select1.selectedIndex", "-1"); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 debug(""); | 60 debug(""); |
61 | 61 |
62 debug("1.9 Remove (positive infinity) from empty Options"); | 62 debug("1.9 Remove (positive infinity) from empty Options"); |
63 value = 1/0; | 63 value = 1/0; |
64 shouldBe("select1.options.remove(value)", "undefined"); | 64 shouldBe("select1.options.remove(value)", "undefined"); |
65 shouldBe("select1.options.length", "0"); | 65 shouldBe("select1.options.length", "0"); |
66 shouldBe("select1.selectedIndex", "-1"); | 66 shouldBe("select1.selectedIndex", "-1"); |
67 debug(""); | 67 debug(""); |
68 | 68 |
69 debug("1.10 Remove no args from empty Options"); | 69 debug("1.10 Remove no args from empty Options"); |
70 shouldBe("select1.options.remove()", "undefined"); | 70 shouldThrow("select1.options.remove()", "'TypeError: Not enough arguments'"); |
71 shouldBe("select1.options.length", "0"); | 71 shouldBe("select1.options.length", "0"); |
72 shouldBe("select1.selectedIndex", "-1"); | 72 shouldBe("select1.selectedIndex", "-1"); |
73 debug(""); | 73 debug(""); |
74 | 74 |
75 debug("1.11 Remove too many args from empty Options"); | 75 debug("1.11 Remove too many args from empty Options"); |
76 shouldThrow("select1.options.remove(0, 'foo')"); | 76 shouldThrow("select1.options.remove(0, 'foo')"); |
77 shouldBe("select1.options.length", "0"); | 77 shouldBe("select1.options.length", "0"); |
78 shouldBe("select1.selectedIndex", "-1"); | 78 shouldBe("select1.selectedIndex", "-1"); |
79 debug(""); | 79 debug(""); |
80 | 80 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 187 |
188 debug("2.10 Remove (positive infinity) from non-empty Options"); | 188 debug("2.10 Remove (positive infinity) from non-empty Options"); |
189 value = 1/0; | 189 value = 1/0; |
190 shouldBe("select2.options.remove(value)", "undefined"); | 190 shouldBe("select2.options.remove(value)", "undefined"); |
191 shouldBe("select2.options.length", "6"); | 191 shouldBe("select2.options.length", "6"); |
192 shouldBe("select2.selectedIndex", "4"); | 192 shouldBe("select2.selectedIndex", "4"); |
193 shouldBe("select2.options[0].value", "'K'"); | 193 shouldBe("select2.options[0].value", "'K'"); |
194 debug(""); | 194 debug(""); |
195 | 195 |
196 debug("2.11 Remove no args from non-empty Options"); | 196 debug("2.11 Remove no args from non-empty Options"); |
197 shouldBe("select2.options.remove()", "undefined"); | 197 shouldThrow("select2.options.remove()", "'TypeError: Not enough arguments'"); |
| 198 shouldBe("select2.options.length", "6"); |
| 199 shouldBe("select2.selectedIndex", "4"); |
| 200 shouldBe("select2.options[0].value", "'K'"); |
| 201 debug(""); |
| 202 |
| 203 debug("2.12 Remove too many args from non-empty Options"); |
| 204 shouldThrow("select2.options.remove(0, 'foo')"); |
| 205 shouldBe("select2.options.length", "6"); |
| 206 shouldBe("select2.selectedIndex", "4"); |
| 207 shouldBe("select2.options[0].value", "'K'"); |
| 208 debug(""); |
| 209 |
| 210 debug("2.13 Remove invalid index -2 from non-empty Options"); |
| 211 shouldBe("select2.options.remove(-2)", "undefined"); |
| 212 shouldBe("select2.options.length", "6"); |
| 213 shouldBe("select2.selectedIndex", "4"); |
| 214 shouldBe("select2.options[2].value", "'M'"); |
| 215 debug(""); |
| 216 |
| 217 debug("2.14 Remove invalid index -1 from non-empty Options"); |
| 218 shouldBe("select2.options.remove(-1)", "undefined"); |
| 219 shouldBe("select2.options.length", "6"); |
| 220 shouldBe("select2.selectedIndex", "4"); |
| 221 shouldBe("select2.options[3].value", "'N'"); |
| 222 debug(""); |
| 223 |
| 224 debug("2.15 Remove index 0 from non-empty Options"); |
| 225 shouldBe("select2.options.remove(0)", "undefined"); |
198 shouldBe("select2.options.length", "5"); | 226 shouldBe("select2.options.length", "5"); |
199 shouldBe("select2.selectedIndex", "3"); | 227 shouldBe("select2.selectedIndex", "3"); |
200 shouldBe("select2.options[0].value", "'L'"); | 228 shouldBe("select2.options[0].value", "'L'"); |
201 debug(""); | 229 debug(""); |
202 | 230 |
203 debug("2.12 Remove too many args from non-empty Options"); | 231 debug("2.16 Remove index 1 from non-empty Options"); |
204 shouldThrow("select2.options.remove(0, 'foo')"); | 232 shouldBe("select2.options.remove(1)", "undefined"); |
205 shouldBe("select2.options.length", "5"); | |
206 shouldBe("select2.selectedIndex", "3"); | |
207 shouldBe("select2.options[0].value", "'L'"); | |
208 debug(""); | |
209 | |
210 debug("2.13 Remove invalid index -2 from non-empty Options"); | |
211 shouldBe("select2.options.remove(-2)", "undefined"); | |
212 shouldBe("select2.options.length", "5"); | |
213 shouldBe("select2.selectedIndex", "3"); | |
214 shouldBe("select2.options[2].value", "'N'"); | |
215 debug(""); | |
216 | |
217 debug("2.14 Remove invalid index -1 from non-empty Options"); | |
218 shouldBe("select2.options.remove(-1)", "undefined"); | |
219 shouldBe("select2.options.length", "5"); | |
220 shouldBe("select2.selectedIndex", "3"); | |
221 shouldBe("select2.options[3].value", "'O'"); | |
222 debug(""); | |
223 | |
224 debug("2.15 Remove index 0 from non-empty Options"); | |
225 shouldBe("select2.options.remove(0)", "undefined"); | |
226 shouldBe("select2.options.length", "4"); | 233 shouldBe("select2.options.length", "4"); |
227 shouldBe("select2.selectedIndex", "2"); | 234 shouldBe("select2.selectedIndex", "2"); |
228 shouldBe("select2.options[0].value", "'M'"); | 235 shouldBe("select2.options[1].value", "'N'"); |
229 debug(""); | |
230 | |
231 debug("2.16 Remove index 1 from non-empty Options"); | |
232 shouldBe("select2.options.remove(1)", "undefined"); | |
233 shouldBe("select2.options.length", "3"); | |
234 shouldBe("select2.selectedIndex", "1"); | |
235 shouldBe("select2.options[1].value", "'O'"); | |
236 debug(""); | 236 debug(""); |
237 | 237 |
238 debug("2.17 Detach select element"); | 238 debug("2.17 Detach select element"); |
239 shouldNotBe("select2.parentNode", "null"); | 239 shouldNotBe("select2.parentNode", "null"); |
240 shouldBe("select2.remove()", "undefined"); | 240 shouldBe("select2.remove()", "undefined"); |
241 shouldBeNull("select2.parentNode"); | 241 shouldBeNull("select2.parentNode"); |
242 debug(""); | 242 debug(""); |
243 | 243 |
OLD | NEW |