 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| Index: LayoutTests/fast/forms/select/select-add.html | 
| diff --git a/LayoutTests/fast/forms/select/select-add.html b/LayoutTests/fast/forms/select/select-add.html | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..a3b8c30f4f34057d89a42fe7e0870a2fadbf90bc | 
| --- /dev/null | 
| +++ b/LayoutTests/fast/forms/select/select-add.html | 
| @@ -0,0 +1,57 @@ | 
| +<!DOCTYPE html> | 
| +<html> | 
| +<head> | 
| +<script src="../../../resources/js-test.js"></script> | 
| +</head> | 
| +<body> | 
| +<script> | 
| +description('Test select.add() method'); | 
| + | 
| +debug('Test select'); | 
| +test(false); | 
| +debug('Test select multiple'); | 
| +test(true); | 
| + | 
| +var select; | 
| +function test(multiple) { | 
| + select = document.createElement('select'); | 
| + select.multiple = multiple; | 
| + shouldBe('select.length', '0'); | 
| + | 
| + select.add(new Option('1', '1', false, false), 100); | 
| + shouldBe('select.length', '1'); | 
| + shouldBeEqualToString('select.options[0].value', '1'); | 
| + | 
| + select.add(new Option('2', '2', false, false), 0); | 
| + shouldBe('select.length', '2'); | 
| + shouldBeEqualToString('select.options[0].value', '2'); | 
| + shouldBeEqualToString('select.options[1].value', '1'); | 
| + | 
| + select.add(new Option('3', '3', false, false), 1); | 
| + shouldBe('select.length', '3'); | 
| + shouldBeEqualToString('select.options[0].value', '2'); | 
| + shouldBeEqualToString('select.options[1].value', '3'); | 
| + shouldBeEqualToString('select.options[2].value', '1'); | 
| + | 
| + select.add(new Option('4', '4', false, false), 2); | 
| + shouldBe('select.length', '4'); | 
| + shouldBeEqualToString('select.options[0].value', '2'); | 
| + shouldBeEqualToString('select.options[1].value', '3'); | 
| + shouldBeEqualToString('select.options[2].value', '4'); | 
| + shouldBeEqualToString('select.options[3].value', '1'); | 
| + | 
| + var group = document.createElement('optgroup'); | 
| + group.appendChild(new Option('5', '5', false, false)); | 
| + group.appendChild(new Option('6', '6', false, false)); | 
| + select.add(group, 3); | 
| + shouldBe('select.length', '6'); | 
| + shouldBeEqualToString('select.options[0].value', '2'); | 
| + shouldBeEqualToString('select.options[1].value', '3'); | 
| + shouldBeEqualToString('select.options[2].value', '4'); | 
| + shouldBeEqualToString('select.options[3].value', '5'); | 
| + shouldBeEqualToString('select.options[4].value', '6'); | 
| + shouldBeEqualToString('select.options[5].value', '1'); | 
| +} | 
| 
tkent
2014/03/27 01:18:53
Needs more tests.
- Omit the second argument
- Pa
 
keishi
2014/03/27 06:06:53
Done.
 | 
| +</script> | 
| +</body> | 
| +</html> |