Changeset 178097 in webkit
- Timestamp:
- Jan 7, 2015 8:55:45 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r178078 r178097 1 2015-01-07 Shivakumar JM <shiva.jm@samsung.com> 2 3 HTMLSelectElement and HTMLOptionsCollection add() method should support index as second argument. 4 https://bugs.webkit.org/show_bug.cgi?id=139179 5 6 Reviewed by Darin Adler. 7 8 * fast/dom/HTMLSelectElement/add-expected.txt: Added. 9 * fast/dom/HTMLSelectElement/add.html: Added. 10 * fast/dom/HTMLSelectElement/options-collection-add-expected.txt: Added. 11 * fast/dom/HTMLSelectElement/options-collection-add.html: Added. 12 * fast/dom/HTMLSelectElement/select-add-optgroup-expected.txt: 13 * fast/dom/HTMLSelectElement/select-add-optgroup.html: 14 * fast/dom/incompatible-operations-expected.txt: 15 * fast/dom/incompatible-operations.html: 16 * js/dom/script-tests/select-options-add.js: 17 * js/dom/select-options-add-expected.txt: 18 1 19 2015-01-07 Said Abou-Hallawa <sabouhallawa@apple.com> 2 20 -
trunk/LayoutTests/fast/dom/HTMLSelectElement/select-add-optgroup-expected.txt
r177629 r178097 4 4 5 5 6 PASS deepCopy() is "0,1,2,Y1" 7 PASS deepCopy() is "0,1,2,Y2,Y1" 8 PASS deepCopy() is "0,1,2,Y3,Y2,Y1" 9 PASS deepCopy() is "0,1,2,Y4,Y3,Y2,Y1" 10 PASS deepCopy() is "0,1,2,X,Y" 11 PASS deepCopy() is "0,1,X,Y,2" 12 PASS deepCopy() is "0,1,X,Y,X,Y,2" 13 PASS deepCopy() is "0,1,2,Y" 14 PASS deepCopy() is "0,1,2,Y" 15 PASS deepCopy() is "0,1,2,Y" 16 PASS deepCopy() is "0,1,2,Y" 17 PASS deepCopy() is "0,1,2,Y" 18 PASS deepCopy() is "0,1,2,Y" 19 PASS deepCopy() is "0,1,2,Y" 20 PASS deepCopy() is "0,1,2,Y" 21 PASS deepCopy() is "0,1,2,Y" 22 PASS deepCopy() is "0,1,2,Y" 23 PASS deepCopy() is "0,1,2,Y" 24 PASS deepCopy() is "0,1,2,Y" 25 PASS deepCopy() is "0,1,2,Y" 26 PASS deepCopy() is "0,1,2,Y" 27 PASS deepCopy() is "0,1,2,Y" 28 PASS deepCopy() is "0,1,2,Y" 29 PASS deepCopy() is "0,1,2,Y" 30 PASS deepCopy() is "0,1,2,Y" 31 PASS deepCopy() is "0,1,2,Y" 32 PASS deepCopy() is "0,1,2,Y" 33 PASS deepCopy() is "0,1,2,Y" 34 PASS deepCopy() is "0,1,2,Y" 35 PASS mySelect.add("foo") is undefined. 36 PASS mySelect.add("foo", 0) is undefined. 37 PASS mySelect.add(undefined) is undefined. 38 PASS mySelect.add(undefined, 0) is undefined. 39 PASS mySelect.add(null) is undefined. 40 PASS mySelect.add(null, 0) is undefined. 6 list elements are = 0,1,2 7 PASS testAdd3(createGroup("Y1", "Y2"), null) is "0,1,2,Y1,Y2" 8 PASS testAdd3(createGroup("Y3", "Y4"), 0) is "Y3,Y4,0,1,2" 9 PASS testAdd3(createGroup("Y5", "Y6"), 2) is "0,1,Y5,Y6,2" 10 PASS testAdd1(createGroup("Y7", "Y8")) is "0,1,2,Y7,Y8" 11 PASS testAdd1(createOption("Y9")) is "0,1,2,Y9" 12 list elements are = 0,1,2 13 PASS testAdd2(createOption("Y10"), mySelect.options[2]) is "0,1,Y10,2" 14 PASS testAdd2(createOption("Y11"), mySelect.options[1]) is "0,Y11,1,Y10,2" 15 list elements are = 0,1,2 16 PASS testAdd2(createGroup("Y12", "Y13"), mySelect.options[1]) is "0,Y12,Y13,1,2" 17 PASS testAdd2(createGroup("Y14", "Y15"), mySelect.options[3]) is "0,Y12,Y13,Y14,Y15,1,2" 18 list elements are = 0,1,2 19 PASS testAdd2(createOption("Y16"), createOption("Y17")) threw exception Error: NotFoundError: DOM Exception 8. 41 20 PASS successfullyParsed is true 42 21 -
trunk/LayoutTests/fast/dom/HTMLSelectElement/select-add-optgroup.html
r177629 r178097 9 9 10 10 var mySelect; 11 var selectedOptions;12 11 13 12 function resetSelection() { … … 19 18 20 19 function deepCopy() { 21 var copy =[];22 for(var i =0;i<mySelect.options.length; ++i)20 var copy = []; 21 for(var i = 0; i < mySelect.options.length; ++i) 23 22 copy.push(mySelect.options[i].value); 24 23 return copy.join(","); 25 24 } 26 25 27 resetSelection(); 28 var option1 = document.createElement("option"); 29 option1.text = "X1"; 30 option1.value = "Y1"; 31 mySelect.add(option1); 32 shouldBeEqualToString('deepCopy()', '0,1,2,Y1'); 26 function createOption(value) { 27 return new Option(value + "X", value, false, false); 28 } 33 29 34 var option2 = document.createElement("option"); 35 option2.text = "X2"; 36 option2.value = "Y2"; 37 mySelect.add(option2, option1); 38 shouldBeEqualToString('deepCopy()', '0,1,2,Y2,Y1'); 30 function createGroup(value1, value2) { 31 var group = document.createElement('optgroup'); 32 group.appendChild(new Option(value1 + "X", value1, false, false)); 33 group.appendChild(new Option(value2 + "Y", value2, false, false)); 34 return group; 35 } 39 36 40 var option3 = document.createElement("option"); 41 option3.text = "X3";42 option3.value = "Y3";43 mySelect.add(option3, option2);44 shouldBeEqualToString('deepCopy()', '0,1,2,Y3,Y2,Y1'); 37 function testAdd1(element) { 38 resetSelection(); 39 mySelect.add(element); 40 return deepCopy(); 41 } 45 42 46 var option4 = document.createElement("option"); 47 option4.text = "X4"; 48 option4.value = "Y4"; 49 mySelect.add(option4, mySelect.options[3]); 50 shouldBeEqualToString('deepCopy()', '0,1,2,Y4,Y3,Y2,Y1'); 43 function testAdd2(newelement, element) { 44 mySelect.add(newelement, element); 45 return deepCopy(); 46 } 51 47 52 resetSelection(); 53 var group1 = document.createElement('optgroup'); 54 group1.appendChild(new Option('X', 'X', false, false)); 55 group1.appendChild(new Option('Y', 'Y', false, false)); 56 mySelect.add(group1); 57 shouldBeEqualToString('deepCopy()', '0,1,2,X,Y'); 58 59 resetSelection(); 60 var group2 = document.createElement('optgroup'); 61 group2.appendChild(new Option('X', 'X', false, false)); 62 group2.appendChild(new Option('Y', 'Y', false, false)); 63 mySelect.add(group2,mySelect.options[2]); 64 shouldBeEqualToString('deepCopy()', '0,1,X,Y,2'); 65 66 var group3 = document.createElement('optgroup'); 67 group3.appendChild(new Option('X', 'X', false, false)); 68 group3.appendChild(new Option('Y', 'Y', false, false)); 69 mySelect.add(group3,group2); 70 shouldBeEqualToString('deepCopy()', '0,1,X,Y,X,Y,2'); 48 function testAdd3(newelement, index) { 49 resetSelection(); 50 mySelect.add(newelement, index); 51 return deepCopy(); 52 } 71 53 72 54 resetSelection(); 73 mySelect.add(new Option("X", "Y", false, false), null); 74 shouldBeEqualToString('deepCopy()', '0,1,2,Y'); 55 debug('list elements are = ' + deepCopy()); 56 shouldBeEqualToString('testAdd3(createGroup("Y1", "Y2"), null)', '0,1,2,Y1,Y2'); 57 shouldBeEqualToString('testAdd3(createGroup("Y3", "Y4"), 0)', 'Y3,Y4,0,1,2'); 58 shouldBeEqualToString('testAdd3(createGroup("Y5", "Y6"), 2)', '0,1,Y5,Y6,2'); 59 shouldBeEqualToString('testAdd1(createGroup("Y7", "Y8"))', '0,1,2,Y7,Y8'); 60 shouldBeEqualToString('testAdd1(createOption("Y9"))', '0,1,2,Y9'); 61 resetSelection(); 62 debug('list elements are = ' + deepCopy()); 63 shouldBeEqualToString('testAdd2(createOption("Y10"), mySelect.options[2])', '0,1,Y10,2'); 64 shouldBeEqualToString('testAdd2(createOption("Y11"), mySelect.options[1])', '0,Y11,1,Y10,2'); 65 resetSelection(); 66 debug('list elements are = ' + deepCopy()); 67 shouldBeEqualToString('testAdd2(createGroup("Y12", "Y13"), mySelect.options[1])', '0,Y12,Y13,1,2'); 68 shouldBeEqualToString('testAdd2(createGroup("Y14", "Y15"), mySelect.options[3])', '0,Y12,Y13,Y14,Y15,1,2'); 69 resetSelection(); 70 debug('list elements are = ' + deepCopy()); 71 shouldThrow('testAdd2(createOption("Y16"), createOption("Y17"))'); 75 72 76 resetSelection();77 mySelect.add(new Option("X", "Y", false, false));78 shouldBeEqualToString('deepCopy()', '0,1,2,Y');79 80 resetSelection();81 mySelect.add(new Option("X", "Y", false, false), 0);82 shouldBeEqualToString('deepCopy()', '0,1,2,Y');83 84 resetSelection();85 mySelect.add(new Option("X", "Y", false, false), 1);86 shouldBeEqualToString('deepCopy()', '0,1,2,Y');87 88 resetSelection();89 mySelect.add(new Option("X", "Y", false, false), 2);90 shouldBeEqualToString('deepCopy()', '0,1,2,Y');91 92 resetSelection();93 mySelect.add(new Option("X", "Y", false, false), 100);94 shouldBeEqualToString('deepCopy()', '0,1,2,Y');95 96 resetSelection();97 mySelect.add(new Option("X", "Y", false, false), -100);98 shouldBeEqualToString('deepCopy()', '0,1,2,Y');99 100 resetSelection();101 mySelect.add(new Option("X", "Y", false, false), "2");102 shouldBeEqualToString('deepCopy()', '0,1,2,Y');103 104 resetSelection();105 mySelect.add(new Option("X", "Y", false, false), "1");106 shouldBeEqualToString('deepCopy()', '0,1,2,Y');107 108 resetSelection();109 mySelect.add(new Option("X", "Y", false, false), "0");110 shouldBeEqualToString('deepCopy()', '0,1,2,Y');111 112 resetSelection();113 mySelect.add(new Option("X", "Y", false, false), 2147483647);114 shouldBeEqualToString('deepCopy()', '0,1,2,Y');115 116 resetSelection();117 mySelect.add(new Option("X", "Y", false, false), 2147483648);118 shouldBeEqualToString('deepCopy()', '0,1,2,Y');119 120 resetSelection();121 mySelect.add(new Option("X", "Y", false, false), -2147483647);122 shouldBeEqualToString('deepCopy()', '0,1,2,Y');123 124 resetSelection();125 mySelect.add(new Option("X", "Y", false, false), -2147483648);126 shouldBeEqualToString('deepCopy()', '0,1,2,Y');127 128 resetSelection();129 mySelect.add(new Option("X", "Y", false, false), -2147483649);130 shouldBeEqualToString('deepCopy()', '0,1,2,Y');131 132 resetSelection();133 mySelect.add(new Option("X", "Y", false, false), true);134 shouldBeEqualToString('deepCopy()', '0,1,2,Y');135 136 resetSelection();137 mySelect.add(new Option("X", "Y", false, false), false);138 shouldBeEqualToString('deepCopy()', '0,1,2,Y');139 140 resetSelection();141 mySelect.add(new Option("X", "Y", false, false), undefined);142 shouldBeEqualToString('deepCopy()', '0,1,2,Y');143 144 resetSelection();145 mySelect.add(new Option("X", "Y", false, false), Infinity);146 shouldBeEqualToString('deepCopy()', '0,1,2,Y');147 148 resetSelection();149 mySelect.add(new Option("X", "Y", false, false), -Infinity);150 shouldBeEqualToString('deepCopy()', '0,1,2,Y');151 152 resetSelection();153 mySelect.add(new Option("X", "Y", false, false), "foo");154 shouldBeEqualToString('deepCopy()', '0,1,2,Y');155 156 resetSelection();157 mySelect.add(new Option("X", "Y", false, false), NaN);158 shouldBeEqualToString('deepCopy()', '0,1,2,Y');159 160 resetSelection();161 shouldBeUndefined('mySelect.add("foo")');162 shouldBeUndefined('mySelect.add("foo", 0)');163 shouldBeUndefined('mySelect.add(undefined)');164 shouldBeUndefined('mySelect.add(undefined, 0)');165 shouldBeUndefined('mySelect.add(null)');166 shouldBeUndefined('mySelect.add(null, 0)');167 168 73 </script> 169 74 </body> -
trunk/LayoutTests/fast/dom/incompatible-operations-expected.txt
r134618 r178097 13 13 PASS aNode.lookupPrefix(void 0) is null 14 14 PASS aNode.cloneNode(aDOMImplementation) instanceof HTMLDivElement is true 15 PASS aSelect.add(aDOMImplementation, aDOMImplementation) is undefined.16 PASS aSelect.add(aDOMImplementation, anOption) is undefined.15 PASS aSelect.add(aDOMImplementation, aDOMImplementation) threw exception TypeError: Type error. 16 PASS aSelect.add(aDOMImplementation, anOption) threw exception TypeError: Type error. 17 17 PASS aSelect.add(anOption, aDOMImplementation) is undefined. 18 PASS aSelect.add(void 0, void 0) is undefined.19 PASS aSelect.add(void 0, anOption) is undefined.18 PASS aSelect.add(void 0, void 0) threw exception TypeError: Type error. 19 PASS aSelect.add(void 0, anOption) threw exception TypeError: Type error. 20 20 PASS aSelect.add(anOption, void 0) is undefined. 21 21 PASS successfullyParsed is true -
trunk/LayoutTests/fast/dom/incompatible-operations.html
r155265 r178097 41 41 shouldBe("aNode.lookupPrefix(void 0)", "null"); 42 42 shouldBeTrue("aNode.cloneNode(aDOMImplementation) instanceof HTMLDivElement"); 43 should BeUndefined("aSelect.add(aDOMImplementation, aDOMImplementation)");44 should BeUndefined("aSelect.add(aDOMImplementation, anOption)");43 shouldThrow("aSelect.add(aDOMImplementation, aDOMImplementation)"); 44 shouldThrow("aSelect.add(aDOMImplementation, anOption)"); 45 45 shouldBeUndefined("aSelect.add(anOption, aDOMImplementation)"); 46 should BeUndefined("aSelect.add(void 0, void 0)");47 should BeUndefined("aSelect.add(void 0, anOption)");46 shouldThrow("aSelect.add(void 0, void 0)"); 47 shouldThrow("aSelect.add(void 0, anOption)"); 48 48 shouldBeUndefined("aSelect.add(anOption, void 0)"); 49 49 </script> -
trunk/LayoutTests/js/dom/script-tests/select-options-add.js
r156066 r178097 55 55 debug("1.4 Add a non-Option element"); 56 56 option1 = document.createElement("DIV"); 57 should Throw("select1.options.add(option1)");57 shouldBeUndefined("select1.options.add(option1)"); 58 58 shouldBe("select1.options.length", "3"); 59 59 shouldBe("select1.selectedIndex", "0"); … … 238 238 debug("2.8 Add an Option at index -2"); 239 239 option2 = document.createElement("OPTION"); 240 should Throw("select2.options.add(option2, -2)");241 shouldBe("select2.options.length", " 7");240 shouldNotThrow("select2.options.add(option2, -2)"); 241 shouldBe("select2.options.length", "8"); 242 242 shouldBe("select2.selectedIndex", "1"); 243 243 debug(""); … … 246 246 option2 = document.createElement("OPTION"); 247 247 shouldNotThrow("select2.options.add(option2, -1/0)"); 248 shouldBe("select2.options.length", " 8");248 shouldBe("select2.options.length", "9"); 249 249 shouldBe("select2.selectedIndex", "2"); 250 250 debug(""); … … 253 253 option2 = document.createElement("OPTION"); 254 254 shouldNotThrow("select2.options.add(option2, 0/0)"); 255 shouldBe("select2.options.length", " 9");255 shouldBe("select2.options.length", "10"); 256 256 shouldBe("select2.selectedIndex", "3"); 257 257 debug(""); … … 260 260 option2 = document.createElement("OPTION"); 261 261 shouldNotThrow("select2.options.add(option2, 1/0)"); 262 shouldBe("select2.options.length", "1 0");262 shouldBe("select2.options.length", "11"); 263 263 shouldBe("select2.selectedIndex", "4"); 264 264 debug(""); … … 266 266 debug("2.12 Add a non-Option element"); 267 267 option2 = document.createElement("DIV"); 268 should Throw("select2.options.add(option2, 1)");269 shouldBe("select2.options.length", "1 0");268 shouldBeUndefined("select2.options.add(option2, 1)"); 269 shouldBe("select2.options.length", "11"); 270 270 shouldBe("select2.selectedIndex", "4"); 271 271 debug(""); … … 274 274 option2 = "o"; 275 275 shouldThrow("select2.options.add(option2, 1)"); 276 shouldBe("select2.options.length", "1 0");276 shouldBe("select2.options.length", "11"); 277 277 shouldBe("select2.selectedIndex", "4"); 278 278 debug(""); … … 281 281 option2 = 3.14; 282 282 shouldThrow("select2.options.add(option2, 1)"); 283 shouldBe("select2.options.length", "1 0");283 shouldBe("select2.options.length", "11"); 284 284 shouldBe("select2.selectedIndex", "4"); 285 285 debug(""); … … 288 288 option2 = true; 289 289 shouldThrow("select2.options.add(option2, 1)"); 290 shouldBe("select2.options.length", "1 0");290 shouldBe("select2.options.length", "11"); 291 291 shouldBe("select2.selectedIndex", "4"); 292 292 debug(""); … … 295 295 option2 = undefined; 296 296 shouldThrow("select2.options.add(option2, 1)"); 297 shouldBe("select2.options.length", "1 0");297 shouldBe("select2.options.length", "11"); 298 298 shouldBe("select2.selectedIndex", "4"); 299 299 debug(""); … … 302 302 option2 = null; 303 303 shouldThrow("select2.options.add(option2, 1)"); 304 shouldBe("select2.options.length", "1 0");304 shouldBe("select2.options.length", "11"); 305 305 shouldBe("select2.selectedIndex", "4"); 306 306 debug(""); … … 309 309 option2 = -1/0; 310 310 shouldThrow("select2.options.add(option2, 1)"); 311 shouldBe("select2.options.length", "1 0");311 shouldBe("select2.options.length", "11"); 312 312 shouldBe("select2.selectedIndex", "4"); 313 313 debug(""); … … 316 316 option2 = 0/0; 317 317 shouldThrow("select2.options.add(option2, 1)"); 318 shouldBe("select2.options.length", "1 0");318 shouldBe("select2.options.length", "11"); 319 319 shouldBe("select2.selectedIndex", "4"); 320 320 debug(""); … … 323 323 option2 = 1/0; 324 324 shouldThrow("select2.options.add(option2, 1)"); 325 shouldBe("select2.options.length", "1 0");326 shouldBe("select2.selectedIndex", "4"); 327 debug(""); 325 shouldBe("select2.options.length", "11"); 326 shouldBe("select2.selectedIndex", "4"); 327 debug(""); -
trunk/LayoutTests/js/dom/select-options-add-expected.txt
r156066 r178097 30 30 31 31 1.4 Add a non-Option element 32 PASS select1.options.add(option1) threw exception Error: TypeMismatchError: DOM Exception 17.32 PASS select1.options.add(option1) is undefined. 33 33 PASS select1.options.length is 3 34 34 PASS select1.selectedIndex is 0 35 35 36 36 1.5 Add a non-element (string) 37 PASS select1.options.add(option1) threw exception Error: TypeMismatchError: DOM Exception 17.37 PASS select1.options.add(option1) threw exception TypeError: Type error. 38 38 PASS select1.options.length is 3 39 39 PASS select1.selectedIndex is 0 40 40 41 41 1.6 Add a non-element (number) 42 PASS select1.options.add(option1) threw exception Error: TypeMismatchError: DOM Exception 17.42 PASS select1.options.add(option1) threw exception TypeError: Type error. 43 43 PASS select1.options.length is 3 44 44 PASS select1.selectedIndex is 0 45 45 46 46 1.7 Add a non-element (boolean) 47 PASS select1.options.add(option1) threw exception Error: TypeMismatchError: DOM Exception 17.47 PASS select1.options.add(option1) threw exception TypeError: Type error. 48 48 PASS select1.options.length is 3 49 49 PASS select1.selectedIndex is 0 50 50 51 51 1.8 Add undefined 52 PASS select1.options.add(option1) threw exception Error: TypeMismatchError: DOM Exception 17.52 PASS select1.options.add(option1) threw exception TypeError: Type error. 53 53 PASS select1.options.length is 3 54 54 PASS select1.selectedIndex is 0 55 55 56 56 1.9 Add null 57 PASS select1.options.add(option1) threw exception Error: TypeMismatchError: DOM Exception 17.57 PASS select1.options.add(option1) threw exception TypeError: Type error. 58 58 PASS select1.options.length is 3 59 59 PASS select1.selectedIndex is 0 60 60 61 61 1.10 Add negative infinity 62 PASS select1.options.add(option1) threw exception Error: TypeMismatchError: DOM Exception 17.62 PASS select1.options.add(option1) threw exception TypeError: Type error. 63 63 PASS select1.options.length is 3 64 64 PASS select1.selectedIndex is 0 65 65 66 66 1.11 Add NaN 67 PASS select1.options.add(option1) threw exception Error: TypeMismatchError: DOM Exception 17.67 PASS select1.options.add(option1) threw exception TypeError: Type error. 68 68 PASS select1.options.length is 3 69 69 PASS select1.selectedIndex is 0 70 70 71 71 1.12 Add positive infinity 72 PASS select1.options.add(option1) threw exception Error: TypeMismatchError: DOM Exception 17.72 PASS select1.options.add(option1) threw exception TypeError: Type error. 73 73 PASS select1.options.length is 3 74 74 PASS select1.selectedIndex is 0 … … 159 159 160 160 2.8 Add an Option at index -2 161 PASS select2.options.add(option2, -2) threw exception Error: IndexSizeError: DOM Exception 1.162 PASS select2.options.length is 7161 PASS select2.options.add(option2, -2) did not throw exception. 162 PASS select2.options.length is 8 163 163 PASS select2.selectedIndex is 1 164 164 165 165 2.9 Add an Option at index -Infinity 166 166 PASS select2.options.add(option2, -1/0) did not throw exception. 167 PASS select2.options.length is 8167 PASS select2.options.length is 9 168 168 PASS select2.selectedIndex is 2 169 169 170 170 2.10 Add an Option at index NaN 171 171 PASS select2.options.add(option2, 0/0) did not throw exception. 172 PASS select2.options.length is 9172 PASS select2.options.length is 10 173 173 PASS select2.selectedIndex is 3 174 174 175 175 2.11 Add an Option at index Infinity 176 176 PASS select2.options.add(option2, 1/0) did not throw exception. 177 PASS select2.options.length is 1 0177 PASS select2.options.length is 11 178 178 PASS select2.selectedIndex is 4 179 179 180 180 2.12 Add a non-Option element 181 PASS select2.options.add(option2, 1) threw exception Error: TypeMismatchError: DOM Exception 17.182 PASS select2.options.length is 1 0181 PASS select2.options.add(option2, 1) is undefined. 182 PASS select2.options.length is 11 183 183 PASS select2.selectedIndex is 4 184 184 185 185 2.13 Add a non-element (string) 186 PASS select2.options.add(option2, 1) threw exception Error: TypeMismatchError: DOM Exception 17.187 PASS select2.options.length is 1 0186 PASS select2.options.add(option2, 1) threw exception TypeError: Type error. 187 PASS select2.options.length is 11 188 188 PASS select2.selectedIndex is 4 189 189 190 190 2.14 Add a non-element (number) 191 PASS select2.options.add(option2, 1) threw exception Error: TypeMismatchError: DOM Exception 17.192 PASS select2.options.length is 1 0191 PASS select2.options.add(option2, 1) threw exception TypeError: Type error. 192 PASS select2.options.length is 11 193 193 PASS select2.selectedIndex is 4 194 194 195 195 2.15 Add a non-element (boolean) 196 PASS select2.options.add(option2, 1) threw exception Error: TypeMismatchError: DOM Exception 17.197 PASS select2.options.length is 1 0196 PASS select2.options.add(option2, 1) threw exception TypeError: Type error. 197 PASS select2.options.length is 11 198 198 PASS select2.selectedIndex is 4 199 199 200 200 2.16 Add undefined 201 PASS select2.options.add(option2, 1) threw exception Error: TypeMismatchError: DOM Exception 17.202 PASS select2.options.length is 1 0201 PASS select2.options.add(option2, 1) threw exception TypeError: Type error. 202 PASS select2.options.length is 11 203 203 PASS select2.selectedIndex is 4 204 204 205 205 2.17 Add null 206 PASS select2.options.add(option2, 1) threw exception Error: TypeMismatchError: DOM Exception 17.207 PASS select2.options.length is 1 0206 PASS select2.options.add(option2, 1) threw exception TypeError: Type error. 207 PASS select2.options.length is 11 208 208 PASS select2.selectedIndex is 4 209 209 210 210 2.18 Add negative infinity 211 PASS select2.options.add(option2, 1) threw exception Error: TypeMismatchError: DOM Exception 17.212 PASS select2.options.length is 1 0211 PASS select2.options.add(option2, 1) threw exception TypeError: Type error. 212 PASS select2.options.length is 11 213 213 PASS select2.selectedIndex is 4 214 214 215 215 2.19 Add NaN 216 PASS select2.options.add(option2, 1) threw exception Error: TypeMismatchError: DOM Exception 17.217 PASS select2.options.length is 1 0216 PASS select2.options.add(option2, 1) threw exception TypeError: Type error. 217 PASS select2.options.length is 11 218 218 PASS select2.selectedIndex is 4 219 219 220 220 2.20 Add positive infinity 221 PASS select2.options.add(option2, 1) threw exception Error: TypeMismatchError: DOM Exception 17.222 PASS select2.options.length is 1 0221 PASS select2.options.add(option2, 1) threw exception TypeError: Type error. 222 PASS select2.options.length is 11 223 223 PASS select2.selectedIndex is 4 224 224 -
trunk/Source/WebCore/ChangeLog
r178095 r178097 1 2015-01-07 Shivakumar JM <shiva.jm@samsung.com> 2 3 HTMLSelectElement and HTMLOptionsCollection add() method should support index as second argument. 4 https://bugs.webkit.org/show_bug.cgi?id=139179 5 6 Reviewed by Darin Adler. 7 8 HTMLSelectElement and HTMLOptionsCollection add() method should support index as second argument as per specification 9 http://www.w3.org/html/wg/drafts/html/master/forms.html#the-select-element. 10 Also this matches the behavior of Chrome and FireFox. 11 12 Tests: fast/dom/HTMLSelectElement/add.html 13 fast/dom/HTMLSelectElement/options-collection-add.html 14 15 * bindings/js/JSHTMLOptionsCollectionCustom.cpp: 16 (WebCore::JSHTMLOptionsCollection::add): Deleted. 17 * html/HTMLOptionsCollection.cpp: 18 (WebCore::HTMLOptionsCollection::add): 19 * html/HTMLOptionsCollection.h: 20 * html/HTMLOptionsCollection.idl: 21 * html/HTMLSelectElement.cpp: 22 (WebCore::HTMLSelectElement::add): 23 * html/HTMLSelectElement.h: 24 * html/HTMLSelectElement.idl: 25 1 26 2015-01-07 Gwang Yoon Hwang <yoon@igalia.com> 2 27 -
trunk/Source/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp
r173804 r178097 61 61 } 62 62 63 JSValue JSHTMLOptionsCollection::add(ExecState* exec)64 {65 HTMLOptionsCollection& imp = impl();66 HTMLOptionElement* option = JSHTMLOptionElement::toWrapped(exec->argument(0));67 ExceptionCode ec = 0;68 if (exec->argumentCount() < 2)69 imp.add(option, ec);70 else {71 int index = exec->argument(1).toInt32(exec);72 if (exec->hadException())73 return jsUndefined();74 imp.add(option, index, ec);75 }76 setDOMException(exec, ec);77 return jsUndefined();78 }79 80 63 JSValue JSHTMLOptionsCollection::remove(ExecState* exec) 81 64 { -
trunk/Source/WebCore/html/HTMLOptionsCollection.cpp
r177259 r178097 37 37 } 38 38 39 void HTMLOptionsCollection::add( PassRefPtr<HTMLOptionElement> element, ExceptionCode& ec)39 void HTMLOptionsCollection::add(HTMLElement* element, HTMLElement* beforeElement, ExceptionCode& ec) 40 40 { 41 add(element, length(), ec);41 selectElement().add(element, beforeElement, ec); 42 42 } 43 43 44 void HTMLOptionsCollection::add( PassRefPtr<HTMLOptionElement> element, int index, ExceptionCode& ec)44 void HTMLOptionsCollection::add(HTMLElement* element, int beforeIndex, ExceptionCode& ec) 45 45 { 46 HTMLOptionElement* newOption = element.get(); 47 48 if (!newOption) { 49 ec = TYPE_MISMATCH_ERR; 50 return; 51 } 52 53 if (index < -1) { 54 ec = INDEX_SIZE_ERR; 55 return; 56 } 57 58 ec = 0; 59 60 if (index == -1 || unsigned(index) >= length()) 61 selectElement().add(newOption, nullptr, ec); 62 else 63 selectElement().add(newOption, downcast<HTMLOptionElement>(item(index)), ec); 64 65 ASSERT(!ec); 46 add(element, downcast<HTMLElement>(item(beforeIndex)), ec); 66 47 } 67 48 -
trunk/Source/WebCore/html/HTMLOptionsCollection.h
r177259 r178097 41 41 const HTMLSelectElement& selectElement() const { return downcast<HTMLSelectElement>(ownerNode()); } 42 42 43 void add( PassRefPtr<HTMLOptionElement>, ExceptionCode&);44 void add( PassRefPtr<HTMLOptionElement>, int index, ExceptionCode&);43 void add(HTMLElement*, HTMLElement* beforeElement, ExceptionCode&); 44 void add(HTMLElement*, int beforeIndex, ExceptionCode&); 45 45 void remove(int index); 46 46 void remove(HTMLOptionElement*); -
trunk/Source/WebCore/html/HTMLOptionsCollection.idl
r159061 r178097 29 29 Node namedItem([Default=Undefined] optional DOMString name); 30 30 31 [Custom, RaisesException] void add([Default=Undefined] optional HTMLOptionElement option, 32 optional unsigned long index); 31 #if (!defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C) && (!defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT) 32 [RaisesException] void add(HTMLElement element, [Default=Undefined] optional HTMLElement? before); 33 [RaisesException] void add(HTMLElement element, [Default=Undefined] optional long index); 34 #else 35 [RaisesException] void add(HTMLOptionElement option, unsigned long index); 36 #endif 33 37 [Custom] void remove([Default=Undefined] optional unsigned long index); 34 38 -
trunk/Source/WebCore/html/HTMLSelectElement.cpp
r177996 r178097 219 219 } 220 220 221 void HTMLSelectElement::add(HTMLElement* element, HTMLElement* before , ExceptionCode& ec)221 void HTMLSelectElement::add(HTMLElement* element, HTMLElement* beforeElement, ExceptionCode& ec) 222 222 { 223 223 if (!element || !(is<HTMLOptionElement>(*element) || element->hasTagName(hrTag) || is<HTMLOptGroupElement>(*element))) … … 227 227 Ref<HTMLElement> protectNewChild(*element); 228 228 229 insertBefore(element, before , ec);229 insertBefore(element, beforeElement, ec); 230 230 updateValidity(); 231 } 232 233 void HTMLSelectElement::add(HTMLElement* element, int beforeIndex, ExceptionCode& ec) 234 { 235 add(element, item(beforeIndex), ec); 231 236 } 232 237 -
trunk/Source/WebCore/html/HTMLSelectElement.h
r177996 r178097 58 58 59 59 void add(HTMLElement*, HTMLElement* beforeElement, ExceptionCode&); 60 void add(HTMLElement*, int beforeIndex, ExceptionCode&); 60 61 61 62 using Node::remove; -
trunk/Source/WebCore/html/HTMLSelectElement.idl
r159061 r178097 42 42 getter Node item(unsigned long index); 43 43 Node namedItem([Default=Undefined] optional DOMString name); 44 [ObjCLegacyUnnamedParameters, RaisesException] void add([Default=Undefined] optional HTMLElement element, 45 [Default=Undefined] optional HTMLElement before); 44 [ObjCLegacyUnnamedParameters, RaisesException] void add(HTMLElement element, [Default=Undefined] optional HTMLElement? before); 46 45 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT 46 [RaisesException] void add(HTMLElement element, [Default=Undefined] optional long index); 47 47 // In JavaScript, we support both option index and option object parameters. 48 48 // As of this writing this cannot be auto-generated.
Note: See TracChangeset
for help on using the changeset viewer.