1 description("This test checks the behavior of the remove() method on the select.options object.");
3 var select1
= document
.getElementById("select1");
6 debug("1.1 Remove (object) from empty Options");
7 value
= document
.createElement("DIV");
8 shouldBe("select1.options.remove(value)", "undefined");
9 shouldBe("select1.options.length", "0");
10 shouldBe("select1.selectedIndex", "-1");
13 debug("1.2 Remove (string) from empty Options");
15 shouldBe("select1.options.remove(value)", "undefined");
16 shouldBe("select1.options.length", "0");
17 shouldBe("select1.selectedIndex", "-1");
20 debug("1.3 Remove (float) from empty Options");
22 shouldBe("select1.options.remove(value)", "undefined");
23 shouldBe("select1.options.length", "0");
24 shouldBe("select1.selectedIndex", "-1");
27 debug("1.4 Remove (boolean) from empty Options");
29 shouldBe("select1.options.remove(value)", "undefined");
30 shouldBe("select1.options.length", "0");
31 shouldBe("select1.selectedIndex", "-1");
34 debug("1.5 Remove (undefined) from empty Options");
36 shouldBe("select1.options.remove(value)", "undefined");
37 shouldBe("select1.options.length", "0");
38 shouldBe("select1.selectedIndex", "-1");
41 debug("1.6 Remove (null) from empty Options");
43 shouldBe("select1.options.remove(value)", "undefined");
44 shouldBe("select1.options.length", "0");
45 shouldBe("select1.selectedIndex", "-1");
48 debug("1.7 Remove (negative infinity) from empty Options");
50 shouldBe("select1.options.remove(value)", "undefined");
51 shouldBe("select1.options.length", "0");
52 shouldBe("select1.selectedIndex", "-1");
55 debug("1.8 Remove (NaN) from empty Options");
57 shouldBe("select1.options.remove(value)", "undefined");
58 shouldBe("select1.options.length", "0");
59 shouldBe("select1.selectedIndex", "-1");
62 debug("1.9 Remove (positive infinity) from empty Options");
64 shouldBe("select1.options.remove(value)", "undefined");
65 shouldBe("select1.options.length", "0");
66 shouldBe("select1.selectedIndex", "-1");
69 debug("1.10 Remove no args from empty Options");
70 shouldThrow("select1.options.remove()");
71 shouldBe("select1.options.length", "0");
72 shouldBe("select1.selectedIndex", "-1");
75 debug("1.11 Remove too many args from empty Options");
76 shouldBe("select1.options.remove(0, 'foo')", "undefined");
77 shouldBe("select1.options.length", "0");
78 shouldBe("select1.selectedIndex", "-1");
81 debug("1.12 Remove invalid index -2 from empty Options");
82 shouldBe("select1.options.remove(-2)", "undefined");
83 shouldBe("select1.options.length", "0");
84 shouldBe("select1.selectedIndex", "-1");
87 debug("1.13 Remove invalid index -1 from empty Options");
88 shouldBe("select1.options.remove(-1)", "undefined");
89 shouldBe("select1.options.length", "0");
90 shouldBe("select1.selectedIndex", "-1");
93 debug("1.14 Remove index 0 from empty Options");
94 shouldBe("select1.options.remove(0)", "undefined");
95 shouldBe("select1.options.length", "0");
96 shouldBe("select1.selectedIndex", "-1");
99 debug("1.15 Remove index 1 from empty Options");
100 shouldBe("select1.options.remove(1)", "undefined");
101 shouldBe("select1.options.length", "0");
102 shouldBe("select1.selectedIndex", "-1");
105 debug("1.16 Detach select element");
106 shouldNotBe("select1.parentNode", "null");
107 shouldBe("select1.remove()", "undefined");
108 shouldBeNull("select1.parentNode");
111 // ------------------------------------------------
114 var select2
= document
.getElementById("select2");
116 debug("2.1 Remove (object) from non-empty Options");
117 value
= document
.createElement("DIV");
118 shouldBe("select2.options.remove(value)", "undefined");
119 shouldBe("select2.options.length", "15");
120 shouldBe("select2.selectedIndex", "13");
121 shouldBe("select2.options[0].value", "'B'");
124 debug("2.2 Remove (string) from non-empty Options");
126 shouldBe("select2.options.remove(value)", "undefined");
127 shouldBe("select2.options.length", "14");
128 shouldBe("select2.selectedIndex", "12");
129 shouldBe("select2.options[0].value", "'C'");
132 debug("2.3 Remove (float) from non-empty Options");
134 shouldBe("select2.options.remove(value)", "undefined");
135 shouldBe("select2.options.length", "13");
136 shouldBe("select2.selectedIndex", "11");
137 shouldBe("select2.options[3].value", "'G'");
140 debug("2.4 Remove (boolean true) from non-empty Options");
142 shouldBe("select2.options.remove(value)", "undefined");
143 shouldBe("select2.options.length", "12");
144 shouldBe("select2.selectedIndex", "10");
145 shouldBe("select2.options[1].value", "'E'");
148 debug("2.5 Remove (boolean false) from non-empty Options");
150 shouldBe("select2.options.remove(value)", "undefined");
151 shouldBe("select2.options.length", "11");
152 shouldBe("select2.selectedIndex", "9");
153 shouldBe("select2.options[1].value", "'G'");
156 debug("2.6 Remove (undefined) from non-empty Options");
158 shouldBe("select2.options.remove(value)", "undefined");
159 shouldBe("select2.options.length", "10");
160 shouldBe("select2.selectedIndex", "8");
161 shouldBe("select2.options[0].value", "'G'");
164 debug("2.7 Remove (null) from non-empty Options");
166 shouldBe("select2.options.remove(value)", "undefined");
167 shouldBe("select2.options.length", "9");
168 shouldBe("select2.selectedIndex", "7");
169 shouldBe("select2.options[0].value", "'H'");
172 debug("2.8 Remove (negative infinity) from non-empty Options");
174 shouldBe("select2.options.remove(value)", "undefined");
175 shouldBe("select2.options.length", "8");
176 shouldBe("select2.selectedIndex", "6");
177 shouldBe("select2.options[0].value", "'I'");
180 debug("2.9 Remove (NaN) from non-empty Options");
182 shouldBe("select2.options.remove(value)", "undefined");
183 shouldBe("select2.options.length", "7");
184 shouldBe("select2.selectedIndex", "5");
185 shouldBe("select2.options[0].value", "'J'");
188 debug("2.10 Remove (positive infinity) from non-empty Options");
190 shouldBe("select2.options.remove(value)", "undefined");
191 shouldBe("select2.options.length", "6");
192 shouldBe("select2.selectedIndex", "4");
193 shouldBe("select2.options[0].value", "'K'");
196 debug("2.11 Remove no args from non-empty Options");
197 shouldThrow("select2.options.remove()");
198 shouldBe("select2.options.length", "6");
199 shouldBe("select2.selectedIndex", "4");
200 shouldBe("select2.options[0].value", "'K'");
203 debug("2.12 Remove too many args from non-empty Options");
204 shouldBe("select2.options.remove(0, 'foo')", "undefined");
205 shouldBe("select2.options.length", "5");
206 shouldBe("select2.selectedIndex", "3");
207 shouldBe("select2.options[0].value", "'L'");
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'");
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'");
224 debug("2.15 Remove index 0 from non-empty Options");
225 shouldBe("select2.options.remove(0)", "undefined");
226 shouldBe("select2.options.length", "4");
227 shouldBe("select2.selectedIndex", "2");
228 shouldBe("select2.options[0].value", "'M'");
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'");
238 debug("2.17 Detach select element");
239 shouldNotBe("select2.parentNode", "null");
240 shouldBe("select2.remove()", "undefined");
241 shouldBeNull("select2.parentNode");