 Chromium Code Reviews
 Chromium Code Reviews Issue 213773003:
  select.add() should support optgroup adding and before index  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk
    
  
    Issue 213773003:
  select.add() should support optgroup adding and before index  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../../resources/js-test.js"></script> | |
| 5 </head> | |
| 6 <body> | |
| 7 <script> | |
| 8 description('Test select.add() method'); | |
| 9 | |
| 10 debug('Test select'); | |
| 11 test(false); | |
| 12 debug('Test select multiple'); | |
| 13 test(true); | |
| 14 | |
| 15 var select; | |
| 16 function test(multiple) { | |
| 17 select = document.createElement('select'); | |
| 18 select.multiple = multiple; | |
| 19 shouldBe('select.length', '0'); | |
| 20 | |
| 21 select.add(new Option('1', '1', false, false), 100); | |
| 22 shouldBe('select.length', '1'); | |
| 23 shouldBeEqualToString('select.options[0].value', '1'); | |
| 24 | |
| 25 select.add(new Option('2', '2', false, false), 0); | |
| 26 shouldBe('select.length', '2'); | |
| 27 shouldBeEqualToString('select.options[0].value', '2'); | |
| 28 shouldBeEqualToString('select.options[1].value', '1'); | |
| 29 | |
| 30 select.add(new Option('3', '3', false, false), 1); | |
| 31 shouldBe('select.length', '3'); | |
| 32 shouldBeEqualToString('select.options[0].value', '2'); | |
| 33 shouldBeEqualToString('select.options[1].value', '3'); | |
| 34 shouldBeEqualToString('select.options[2].value', '1'); | |
| 35 | |
| 36 select.add(new Option('4', '4', false, false), 2); | |
| 37 shouldBe('select.length', '4'); | |
| 38 shouldBeEqualToString('select.options[0].value', '2'); | |
| 39 shouldBeEqualToString('select.options[1].value', '3'); | |
| 40 shouldBeEqualToString('select.options[2].value', '4'); | |
| 41 shouldBeEqualToString('select.options[3].value', '1'); | |
| 42 | |
| 43 var group = document.createElement('optgroup'); | |
| 44 group.appendChild(new Option('5', '5', false, false)); | |
| 45 group.appendChild(new Option('6', '6', false, false)); | |
| 46 select.add(group, 3); | |
| 47 shouldBe('select.length', '6'); | |
| 48 shouldBeEqualToString('select.options[0].value', '2'); | |
| 49 shouldBeEqualToString('select.options[1].value', '3'); | |
| 50 shouldBeEqualToString('select.options[2].value', '4'); | |
| 51 shouldBeEqualToString('select.options[3].value', '5'); | |
| 52 shouldBeEqualToString('select.options[4].value', '6'); | |
| 53 shouldBeEqualToString('select.options[5].value', '1'); | |
| 54 } | |
| 
tkent
2014/03/27 01:18:53
Needs more tests.
- Omit the second argument
- Pa
 
keishi
2014/03/27 06:06:53
Done.
 | |
| 55 </script> | |
| 56 </body> | |
| 57 </html> | |
| OLD | NEW |