1description("This test checks the behavior of the remove() method on the select.options object.");
2
3var select1 = document.getElementById("select1");
4var value;
5
6debug("1.1 Remove (object) from empty Options");
7value = document.createElement("DIV");
8shouldBe("select1.options.remove(value)", "undefined");
9shouldBe("select1.options.length", "0");
10shouldBe("select1.selectedIndex", "-1");
11debug("");
12
13debug("1.2 Remove (string) from empty Options");
14value = "o";
15shouldBe("select1.options.remove(value)", "undefined");
16shouldBe("select1.options.length", "0");
17shouldBe("select1.selectedIndex", "-1");
18debug("");
19
20debug("1.3 Remove (float) from empty Options");
21value = 3.14;
22shouldBe("select1.options.remove(value)", "undefined");
23shouldBe("select1.options.length", "0");
24shouldBe("select1.selectedIndex", "-1");
25debug("");
26
27debug("1.4 Remove (boolean) from empty Options");
28value = true;
29shouldBe("select1.options.remove(value)", "undefined");
30shouldBe("select1.options.length", "0");
31shouldBe("select1.selectedIndex", "-1");
32debug("");
33
34debug("1.5 Remove (undefined) from empty Options");
35value = undefined;
36shouldBe("select1.options.remove(value)", "undefined");
37shouldBe("select1.options.length", "0");
38shouldBe("select1.selectedIndex", "-1");
39debug("");
40
41debug("1.6 Remove (null) from empty Options");
42value = null;
43shouldBe("select1.options.remove(value)", "undefined");
44shouldBe("select1.options.length", "0");
45shouldBe("select1.selectedIndex", "-1");
46debug("");
47
48debug("1.7 Remove (negative infinity) from empty Options");
49value = -1/0;
50shouldBe("select1.options.remove(value)", "undefined");
51shouldBe("select1.options.length", "0");
52shouldBe("select1.selectedIndex", "-1");
53debug("");
54
55debug("1.8 Remove (NaN) from empty Options");
56value = 0/0;
57shouldBe("select1.options.remove(value)", "undefined");
58shouldBe("select1.options.length", "0");
59shouldBe("select1.selectedIndex", "-1");
60debug("");
61
62debug("1.9 Remove (positive infinity) from empty Options");
63value = 1/0;
64shouldBe("select1.options.remove(value)", "undefined");
65shouldBe("select1.options.length", "0");
66shouldBe("select1.selectedIndex", "-1");
67debug("");
68
69debug("1.10 Remove no args from empty Options");
70shouldBe("select1.options.remove()", "undefined");
71shouldBe("select1.options.length", "0");
72shouldBe("select1.selectedIndex", "-1");
73debug("");
74
75debug("1.11 Remove too many args from empty Options");
76shouldBe("select1.options.remove(0, 'foo')", "undefined");
77shouldBe("select1.options.length", "0");
78shouldBe("select1.selectedIndex", "-1");
79debug("");
80
81debug("1.12 Remove invalid index -2 from empty Options");
82shouldBe("select1.options.remove(-2)", "undefined");
83shouldBe("select1.options.length", "0");
84shouldBe("select1.selectedIndex", "-1");
85debug("");
86
87debug("1.13 Remove invalid index -1 from empty Options");
88shouldBe("select1.options.remove(-1)", "undefined");
89shouldBe("select1.options.length", "0");
90shouldBe("select1.selectedIndex", "-1");
91debug("");
92
93debug("1.14 Remove index 0 from empty Options");
94shouldBe("select1.options.remove(0)", "undefined");
95shouldBe("select1.options.length", "0");
96shouldBe("select1.selectedIndex", "-1");
97debug("");
98
99debug("1.15 Remove index 1 from empty Options");
100shouldBe("select1.options.remove(1)", "undefined");
101shouldBe("select1.options.length", "0");
102shouldBe("select1.selectedIndex", "-1");
103debug("");
104
105// ------------------------------------------------
106
107i = 0;
108var select2 = document.getElementById("select2");
109
110debug("2.1 Remove (object) from non-empty Options");
111value = document.createElement("DIV");
112shouldBe("select2.options.remove(value)", "undefined");
113shouldBe("select2.options.length", "15");
114shouldBe("select2.selectedIndex", "13");
115shouldBe("select2.options[0].value", "'B'");
116debug("");
117
118debug("2.2 Remove (string) from non-empty Options");
119value = "o";
120shouldBe("select2.options.remove(value)", "undefined");
121shouldBe("select2.options.length", "14");
122shouldBe("select2.selectedIndex", "12");
123shouldBe("select2.options[0].value", "'C'");
124debug("");
125
126debug("2.3 Remove (float) from non-empty Options");
127value = 3.14;
128shouldBe("select2.options.remove(value)", "undefined");
129shouldBe("select2.options.length", "13");
130shouldBe("select2.selectedIndex", "11");
131shouldBe("select2.options[3].value", "'G'");
132debug("");
133
134debug("2.4 Remove (boolean true) from non-empty Options");
135value = true;
136shouldBe("select2.options.remove(value)", "undefined");
137shouldBe("select2.options.length", "12");
138shouldBe("select2.selectedIndex", "10");
139shouldBe("select2.options[1].value", "'E'");
140debug("");
141
142debug("2.5 Remove (boolean false) from non-empty Options");
143value = false;
144shouldBe("select2.options.remove(value)", "undefined");
145shouldBe("select2.options.length", "11");
146shouldBe("select2.selectedIndex", "9");
147shouldBe("select2.options[1].value", "'G'");
148debug("");
149
150debug("2.6 Remove (undefined) from non-empty Options");
151value = undefined;
152shouldBe("select2.options.remove(value)", "undefined");
153shouldBe("select2.options.length", "10");
154shouldBe("select2.selectedIndex", "8");
155shouldBe("select2.options[0].value", "'G'");
156debug("");
157
158debug("2.7 Remove (null) from non-empty Options");
159value = null;
160shouldBe("select2.options.remove(value)", "undefined");
161shouldBe("select2.options.length", "9");
162shouldBe("select2.selectedIndex", "7");
163shouldBe("select2.options[0].value", "'H'");
164debug("");
165
166debug("2.8 Remove (negative infinity) from non-empty Options");
167value = -1/0;
168shouldBe("select2.options.remove(value)", "undefined");
169shouldBe("select2.options.length", "8");
170shouldBe("select2.selectedIndex", "6");
171shouldBe("select2.options[0].value", "'I'");
172debug("");
173
174debug("2.9 Remove (NaN) from non-empty Options");
175value = 0/0;
176shouldBe("select2.options.remove(value)", "undefined");
177shouldBe("select2.options.length", "7");
178shouldBe("select2.selectedIndex", "5");
179shouldBe("select2.options[0].value", "'J'");
180debug("");
181
182debug("2.10 Remove (positive infinity) from non-empty Options");
183value = 1/0;
184shouldBe("select2.options.remove(value)", "undefined");
185shouldBe("select2.options.length", "6");
186shouldBe("select2.selectedIndex", "4");
187shouldBe("select2.options[0].value", "'K'");
188debug("");
189
190debug("2.11 Remove no args from non-empty Options");
191shouldBe("select2.options.remove()", "undefined");
192shouldBe("select2.options.length", "5");
193shouldBe("select2.selectedIndex", "3");
194shouldBe("select2.options[0].value", "'L'");
195debug("");
196
197debug("2.12 Remove too many args from non-empty Options");
198shouldBe("select2.options.remove(0, 'foo')", "undefined");
199shouldBe("select2.options.length", "4");
200shouldBe("select2.selectedIndex", "2");
201shouldBe("select2.options[0].value", "'M'");
202debug("");
203
204debug("2.13 Remove invalid index -2 from non-empty Options");
205shouldBe("select2.options.remove(-2)", "undefined");
206shouldBe("select2.options.length", "4");
207shouldBe("select2.selectedIndex", "2");
208shouldBe("select2.options[2].value", "'O'");
209debug("");
210
211debug("2.14 Remove invalid index -1 from non-empty Options");
212shouldBe("select2.options.remove(-1)", "undefined");
213shouldBe("select2.options.length", "4");
214shouldBe("select2.selectedIndex", "2");
215shouldBe("select2.options[3].value", "'P'");
216debug("");
217
218debug("2.15 Remove index 0 from non-empty Options");
219shouldBe("select2.options.remove(0)", "undefined");
220shouldBe("select2.options.length", "3");
221shouldBe("select2.selectedIndex", "1");
222shouldBe("select2.options[0].value", "'N'");
223debug("");
224
225debug("2.16 Remove index 1 from non-empty Options");
226shouldBe("select2.options.remove(1)", "undefined");
227shouldBe("select2.options.length", "2");
228shouldBe("select2.selectedIndex", "0");
229shouldBe("select2.options[1].value", "'P'");
230debug("");
231
232successfullyParsed = true;
233