1 This test checks the behavior of the add() method on the select.options object.
2 It covers both the the one-argument (1.x) and two-argument (2.x) signatures of the add() method.
4 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
7 1.1 Add Option to empty Options
8 PASS select1.options.length is 1
9 PASS select1.selectedIndex is 0
10 PASS select1.options[0].value is '1'
11 PASS select1.options[0].textContent is 'A'
13 1.2 Add Option to non-empty Options
14 PASS select1.options.length is 2
15 PASS select1.selectedIndex is 0
16 PASS select1.options[0].value is '1'
17 PASS select1.options[0].textContent is 'A'
18 PASS select1.options[1].value is '2'
19 PASS select1.options[1].textContent is 'B'
21 1.3 Add Option after setting parameters
22 PASS select1.options.length is 3
23 PASS select1.selectedIndex is 0
24 PASS select1.options[0].value is '1'
25 PASS select1.options[0].textContent is 'A'
26 PASS select1.options[1].value is '2'
27 PASS select1.options[1].textContent is 'B'
28 PASS select1.options[2].value is '3'
29 PASS select1.options[2].textContent is 'C'
31 1.4 Add a non-Option element
32 PASS select1.options.add(option1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
33 PASS select1.options.length is 3
34 PASS select1.selectedIndex is 0
36 1.5 Add a non-element (string)
37 PASS select1.options.add(option1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
38 PASS select1.options.length is 3
39 PASS select1.selectedIndex is 0
41 1.6 Add a non-element (number)
42 PASS select1.options.add(option1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
43 PASS select1.options.length is 3
44 PASS select1.selectedIndex is 0
46 1.7 Add a non-element (boolean)
47 PASS select1.options.add(option1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
48 PASS select1.options.length is 3
49 PASS select1.selectedIndex is 0
52 PASS select1.options.add(option1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
53 PASS select1.options.length is 3
54 PASS select1.selectedIndex is 0
57 PASS select1.options.add(option1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
58 PASS select1.options.length is 3
59 PASS select1.selectedIndex is 0
61 1.10 Add negative infinity
62 PASS select1.options.add(option1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
63 PASS select1.options.length is 3
64 PASS select1.selectedIndex is 0
67 PASS select1.options.add(option1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
68 PASS select1.options.length is 3
69 PASS select1.selectedIndex is 0
71 1.12 Add positive infinity
72 PASS select1.options.add(option1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
73 PASS select1.options.length is 3
74 PASS select1.selectedIndex is 0
76 2.1 Add Option to empty Options
77 PASS select2.options.length is 1
78 PASS select2.selectedIndex is 0
79 PASS select2.options[0].value is '1'
80 PASS select2.options[0].textContent is 'A'
82 2.2 Add Option after setting parameters
83 PASS select2.options.length is 2
84 PASS select2.selectedIndex is 0
85 PASS select2.options[0].value is '1'
86 PASS select2.options[0].textContent is 'A'
87 PASS select2.options[1].value is '2'
88 PASS select2.options[1].textContent is 'B'
90 2.3 Insert Option at beginning of Options
91 PASS select2.options.length is 3
92 PASS select2.selectedIndex is 1
93 PASS select2.options[0].value is '0'
94 PASS select2.options[0].textContent is 'Z'
95 PASS select2.options[1].value is '1'
96 PASS select2.options[1].textContent is 'A'
97 PASS select2.options[2].value is '2'
98 PASS select2.options[2].textContent is 'B'
100 2.4 Insert Option in middle of Options
101 PASS select2.options.length is 4
102 PASS select2.selectedIndex is 1
103 PASS select2.options[0].value is '0'
104 PASS select2.options[0].textContent is 'Z'
105 PASS select2.options[1].value is '1'
106 PASS select2.options[1].textContent is 'A'
107 PASS select2.options[2].value is '1.5'
108 PASS select2.options[2].textContent is 'A.5'
109 PASS select2.options[3].value is '2'
110 PASS select2.options[3].textContent is 'B'
112 2.5 Insert Option at end of Options
113 PASS select2.options.length is 5
114 PASS select2.selectedIndex is 1
115 PASS select2.options[0].value is '0'
116 PASS select2.options[0].textContent is 'Z'
117 PASS select2.options[1].value is '1'
118 PASS select2.options[1].textContent is 'A'
119 PASS select2.options[2].value is '1.5'
120 PASS select2.options[2].textContent is 'A.5'
121 PASS select2.options[3].value is '2'
122 PASS select2.options[3].textContent is 'B'
123 PASS select2.options[4].value is '3'
124 PASS select2.options[4].textContent is 'C'
126 2.6 Insert Option beyond the end of Options
127 PASS select2.options.length is 6
128 PASS select2.selectedIndex is 1
129 PASS select2.options[0].value is '0'
130 PASS select2.options[0].textContent is 'Z'
131 PASS select2.options[1].value is '1'
132 PASS select2.options[1].textContent is 'A'
133 PASS select2.options[2].value is '1.5'
134 PASS select2.options[2].textContent is 'A.5'
135 PASS select2.options[3].value is '2'
136 PASS select2.options[3].textContent is 'B'
137 PASS select2.options[4].value is '3'
138 PASS select2.options[4].textContent is 'C'
139 PASS select2.options[5].value is '4'
140 PASS select2.options[5].textContent is 'D'
142 2.7 Add an Option at index -1
143 PASS select2.options.length is 7
144 PASS select2.selectedIndex is 1
145 PASS select2.options[0].value is '0'
146 PASS select2.options[0].textContent is 'Z'
147 PASS select2.options[1].value is '1'
148 PASS select2.options[1].textContent is 'A'
149 PASS select2.options[2].value is '1.5'
150 PASS select2.options[2].textContent is 'A.5'
151 PASS select2.options[3].value is '2'
152 PASS select2.options[3].textContent is 'B'
153 PASS select2.options[4].value is '3'
154 PASS select2.options[4].textContent is 'C'
155 PASS select2.options[5].value is '4'
156 PASS select2.options[5].textContent is 'D'
157 PASS select2.options[6].value is '5'
158 PASS select2.options[6].textContent is 'E'
160 2.8 Add an Option at index -2
161 PASS select2.options.add(option2, -2) threw exception IndexSizeError: Failed to execute 'add' on 'HTMLOptionsCollection': The index provided (-2) is less than -1..
162 PASS select2.options.length is 7
163 PASS select2.selectedIndex is 1
165 2.9 Add an Option at index -Infinity
166 PASS select2.options.add(option2, -1/0) did not throw exception.
167 PASS select2.options.length is 8
168 PASS select2.selectedIndex is 2
170 2.10 Add an Option at index NaN
171 PASS select2.options.add(option2, 0/0) did not throw exception.
172 PASS select2.options.length is 9
173 PASS select2.selectedIndex is 3
175 2.11 Add an Option at index Infinity
176 PASS select2.options.add(option2, 1/0) did not throw exception.
177 PASS select2.options.length is 10
178 PASS select2.selectedIndex is 4
180 2.12 Add a non-Option element
181 PASS select2.options.add(option2, 1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
182 PASS select2.options.length is 10
183 PASS select2.selectedIndex is 4
185 2.13 Add a non-element (string)
186 PASS select2.options.add(option2, 1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
187 PASS select2.options.length is 10
188 PASS select2.selectedIndex is 4
190 2.14 Add a non-element (number)
191 PASS select2.options.add(option2, 1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
192 PASS select2.options.length is 10
193 PASS select2.selectedIndex is 4
195 2.15 Add a non-element (boolean)
196 PASS select2.options.add(option2, 1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
197 PASS select2.options.length is 10
198 PASS select2.selectedIndex is 4
201 PASS select2.options.add(option2, 1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
202 PASS select2.options.length is 10
203 PASS select2.selectedIndex is 4
206 PASS select2.options.add(option2, 1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
207 PASS select2.options.length is 10
208 PASS select2.selectedIndex is 4
210 2.18 Add negative infinity
211 PASS select2.options.add(option2, 1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
212 PASS select2.options.length is 10
213 PASS select2.selectedIndex is 4
216 PASS select2.options.add(option2, 1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
217 PASS select2.options.length is 10
218 PASS select2.selectedIndex is 4
220 2.20 Add positive infinity
221 PASS select2.options.add(option2, 1) threw exception TypeError: Failed to execute 'add' on 'HTMLOptionsCollection': The element provided was not an HTMLOptionElement..
222 PASS select2.options.length is 10
223 PASS select2.selectedIndex is 4
225 PASS successfullyParsed is true