Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: LayoutTests/fast/js/script-tests/select-options-add.js

Issue 716773002: Use union types for HTMLSelectElement.add()'s arguments (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: added FIXME Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 description( 1 description(
2 "This test checks the behavior of the add() method on the select.options object. <br>" + 2 "This test checks the behavior of the add() method on the select.options object. <br>" +
3 "It covers both the the one-argument (1.x) and two-argument (2.x) signatures of the add() method." 3 "It covers both the the one-argument (1.x) and two-argument (2.x) signatures of the add() method."
4 ); 4 );
5 5
6 div = document.createElement("div"); 6 div = document.createElement("div");
7 sel = document.createElement("select"); 7 sel = document.createElement("select");
8 sel.setAttribute("id", "select1"); 8 sel.setAttribute("id", "select1");
9 div.appendChild(sel); 9 div.appendChild(sel);
10 sel = document.createElement("select"); 10 sel = document.createElement("select");
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 shouldBe("select2.options[4].value", "'3'"); 230 shouldBe("select2.options[4].value", "'3'");
231 shouldBe("select2.options[4].textContent", "'C'"); 231 shouldBe("select2.options[4].textContent", "'C'");
232 shouldBe("select2.options[5].value", "'4'"); 232 shouldBe("select2.options[5].value", "'4'");
233 shouldBe("select2.options[5].textContent", "'D'"); 233 shouldBe("select2.options[5].textContent", "'D'");
234 shouldBe("select2.options[6].value", "'5'"); 234 shouldBe("select2.options[6].value", "'5'");
235 shouldBe("select2.options[6].textContent", "'E'"); 235 shouldBe("select2.options[6].textContent", "'E'");
236 debug(""); 236 debug("");
237 237
238 debug("2.8 Add an Option at index -2"); 238 debug("2.8 Add an Option at index -2");
239 option2 = document.createElement("OPTION"); 239 option2 = document.createElement("OPTION");
240 shouldThrow("select2.options.add(option2, -2)"); 240 shouldNotThrow("select2.options.add(option2, -2)");
241 shouldBe("select2.options.length", "7"); 241 shouldBe("select2.options.length", "8");
242 shouldBe("select2.selectedIndex", "1"); 242 shouldBe("select2.selectedIndex", "1");
243 debug(""); 243 debug("");
244 244
245 debug("2.9 Add an Option at index -Infinity"); 245 debug("2.9 Add an Option at index -Infinity");
246 option2 = document.createElement("OPTION"); 246 option2 = document.createElement("OPTION");
247 shouldNotThrow("select2.options.add(option2, -1/0)"); 247 shouldNotThrow("select2.options.add(option2, -1/0)");
248 shouldBe("select2.options.length", "8"); 248 shouldBe("select2.options.length", "9");
249 shouldBe("select2.selectedIndex", "2"); 249 shouldBe("select2.selectedIndex", "2");
250 debug(""); 250 debug("");
251 251
252 debug("2.10 Add an Option at index NaN"); 252 debug("2.10 Add an Option at index NaN");
253 option2 = document.createElement("OPTION"); 253 option2 = document.createElement("OPTION");
254 shouldNotThrow("select2.options.add(option2, 0/0)"); 254 shouldNotThrow("select2.options.add(option2, 0/0)");
255 shouldBe("select2.options.length", "9"); 255 shouldBe("select2.options.length", "10");
256 shouldBe("select2.selectedIndex", "3"); 256 shouldBe("select2.selectedIndex", "3");
257 debug(""); 257 debug("");
258 258
259 debug("2.11 Add an Option at index Infinity"); 259 debug("2.11 Add an Option at index Infinity");
260 option2 = document.createElement("OPTION"); 260 option2 = document.createElement("OPTION");
261 shouldNotThrow("select2.options.add(option2, 1/0)"); 261 shouldNotThrow("select2.options.add(option2, 1/0)");
262 shouldBe("select2.options.length", "10"); 262 shouldBe("select2.options.length", "11");
263 shouldBe("select2.selectedIndex", "4"); 263 shouldBe("select2.selectedIndex", "4");
264 debug(""); 264 debug("");
265 265
266 debug("2.12 Add a non-Option element"); 266 debug("2.12 Add a non-Option element");
267 option2 = document.createElement("DIV"); 267 option2 = document.createElement("DIV");
268 shouldThrow("select2.options.add(option2, 1)"); 268 shouldThrow("select2.options.add(option2, 1)");
269 shouldBe("select2.options.length", "10"); 269 shouldBe("select2.options.length", "11");
270 shouldBe("select2.selectedIndex", "4"); 270 shouldBe("select2.selectedIndex", "4");
271 debug(""); 271 debug("");
272 272
273 debug("2.13 Add a non-element (string)"); 273 debug("2.13 Add a non-element (string)");
274 option2 = "o"; 274 option2 = "o";
275 shouldThrow("select2.options.add(option2, 1)"); 275 shouldThrow("select2.options.add(option2, 1)");
276 shouldBe("select2.options.length", "10"); 276 shouldBe("select2.options.length", "11");
277 shouldBe("select2.selectedIndex", "4"); 277 shouldBe("select2.selectedIndex", "4");
278 debug(""); 278 debug("");
279 279
280 debug("2.14 Add a non-element (number)"); 280 debug("2.14 Add a non-element (number)");
281 option2 = 3.14; 281 option2 = 3.14;
282 shouldThrow("select2.options.add(option2, 1)"); 282 shouldThrow("select2.options.add(option2, 1)");
283 shouldBe("select2.options.length", "10"); 283 shouldBe("select2.options.length", "11");
284 shouldBe("select2.selectedIndex", "4"); 284 shouldBe("select2.selectedIndex", "4");
285 debug(""); 285 debug("");
286 286
287 debug("2.15 Add a non-element (boolean)"); 287 debug("2.15 Add a non-element (boolean)");
288 option2 = true; 288 option2 = true;
289 shouldThrow("select2.options.add(option2, 1)"); 289 shouldThrow("select2.options.add(option2, 1)");
290 shouldBe("select2.options.length", "10"); 290 shouldBe("select2.options.length", "11");
291 shouldBe("select2.selectedIndex", "4"); 291 shouldBe("select2.selectedIndex", "4");
292 debug(""); 292 debug("");
293 293
294 debug("2.16 Add undefined"); 294 debug("2.16 Add undefined");
295 option2 = undefined; 295 option2 = undefined;
296 shouldThrow("select2.options.add(option2, 1)"); 296 shouldThrow("select2.options.add(option2, 1)");
297 shouldBe("select2.options.length", "10"); 297 shouldBe("select2.options.length", "11");
298 shouldBe("select2.selectedIndex", "4"); 298 shouldBe("select2.selectedIndex", "4");
299 debug(""); 299 debug("");
300 300
301 debug("2.17 Add null"); 301 debug("2.17 Add null");
302 option2 = null; 302 option2 = null;
303 shouldThrow("select2.options.add(option2, 1)"); 303 shouldThrow("select2.options.add(option2, 1)");
304 shouldBe("select2.options.length", "10"); 304 shouldBe("select2.options.length", "11");
305 shouldBe("select2.selectedIndex", "4"); 305 shouldBe("select2.selectedIndex", "4");
306 debug(""); 306 debug("");
307 307
308 debug("2.18 Add negative infinity"); 308 debug("2.18 Add negative infinity");
309 option2 = -1/0; 309 option2 = -1/0;
310 shouldThrow("select2.options.add(option2, 1)"); 310 shouldThrow("select2.options.add(option2, 1)");
311 shouldBe("select2.options.length", "10"); 311 shouldBe("select2.options.length", "11");
312 shouldBe("select2.selectedIndex", "4"); 312 shouldBe("select2.selectedIndex", "4");
313 debug(""); 313 debug("");
314 314
315 debug("2.19 Add NaN"); 315 debug("2.19 Add NaN");
316 option2 = 0/0; 316 option2 = 0/0;
317 shouldThrow("select2.options.add(option2, 1)"); 317 shouldThrow("select2.options.add(option2, 1)");
318 shouldBe("select2.options.length", "10"); 318 shouldBe("select2.options.length", "11");
319 shouldBe("select2.selectedIndex", "4"); 319 shouldBe("select2.selectedIndex", "4");
320 debug(""); 320 debug("");
321 321
322 debug("2.20 Add positive infinity"); 322 debug("2.20 Add positive infinity");
323 option2 = 1/0; 323 option2 = 1/0;
324 shouldThrow("select2.options.add(option2, 1)"); 324 shouldThrow("select2.options.add(option2, 1)");
325 shouldBe("select2.options.length", "10"); 325 shouldBe("select2.options.length", "11");
326 shouldBe("select2.selectedIndex", "4"); 326 shouldBe("select2.selectedIndex", "4");
327 debug(""); 327 debug("");
OLDNEW
« no previous file with comments | « LayoutTests/fast/forms/select/select-add-expected.txt ('k') | LayoutTests/fast/js/select-options-add-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698