Changeset 20569 in webkit
- Timestamp:
- Mar 28, 2007, 11:20:38 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r20544 r20569 1 2007-03-28 Jeff Walden <jwalden+code@mit.edu> 2 3 Reviewed by Darin. 4 5 http://bugs.webkit.org/show_bug.cgi?id=12963 6 Fix some inconsistencies in the Mozilla JS Array extras implementations 7 with respect to the Mozilla implementation: 8 9 - holes in arrays should be skipped, not treated as undefined, 10 by all such methods 11 - an element with value undefined is not a hole 12 - Array.prototype.forEach should return undefined 13 14 * kjs/array_object.cpp: 15 (ArrayInstance::getOwnPropertySlot): 16 (ArrayProtoFunc::callAsFunction): 17 1 18 2007-03-27 Anders Carlsson <acarlsson@apple.com> 2 19 -
trunk/JavaScriptCore/kjs/array_object.cpp
r20310 r20569 102 102 if (index < storageLength) { 103 103 JSValue *v = storage[index]; 104 if (!v || v->isUndefined())104 if (!v) 105 105 return false; 106 106 slot.setValueSlot(this, &storage[index]); … … 121 121 if (index < storageLength) { 122 122 JSValue *v = storage[index]; 123 if (!v || v->isUndefined())123 if (!v) 124 124 return false; 125 125 slot.setValueSlot(this, &storage[index]); … … 790 790 if (id == Filter) 791 791 resultArray = static_cast<JSObject *>(exec->lexicalInterpreter()->builtinArray()->construct(exec, List::empty())); 792 else 793 { 792 else { 794 793 List args; 795 794 args.append(jsNumber(length)); … … 840 839 result = jsBoolean(id == Every); 841 840 else 842 result = thisObj;841 result = jsUndefined(); 843 842 844 843 for (unsigned k = 0; k < length && !exec->hadException(); ++k) { … … 887 886 JSValue* e = getProperty(exec, thisObj, index); 888 887 if (!e) 889 e = jsUndefined();888 continue; 890 889 if (strictEqual(exec, searchElement, e)) 891 890 return jsNumber(index); … … 913 912 JSValue* e = getProperty(exec, thisObj, index); 914 913 if (!e) 915 e = jsUndefined();914 continue; 916 915 if (strictEqual(exec, searchElement, e)) 917 916 return jsNumber(index); -
trunk/LayoutTests/ChangeLog
r20565 r20569 1 2007-03-28 Jeff Walden <jwalden+code@mit.edu> 2 3 Reviewed by Darin. 4 5 http://bugs.webkit.org/show_bug.cgi?id=12963 6 Fix some inconsistencies in the Mozilla JS Array extras implementations 7 with respect to the Mozilla implementation: 8 9 - holes in arrays should be skipped, not treated as undefined, 10 by all such methods 11 - an element with value undefined is not a hole 12 - Array.prototype.forEach should return undefined 13 14 * fast/js/array-every-expected.txt: 15 * fast/js/array-filter-expected.txt: Added. 16 * fast/js/array-filter.html: Added. 17 * fast/js/array-foreach-expected.txt: 18 * fast/js/array-foreach.html: 19 * fast/js/array-indexof-expected.txt: 20 * fast/js/array-indexof.html: 21 * fast/js/array-lastIndexOf-expected.txt: 22 * fast/js/array-map-expected.txt: Added. 23 * fast/js/array-map.html: Added. 24 * fast/js/array-some-expected.txt: 25 * fast/js/array-some.html: 26 * fast/js/resources/array-every.js: 27 * fast/js/resources/array-lastIndexOf.js: 28 1 29 2007-03-28 Maciej Stachowiak <mjs@apple.com> 2 30 -
trunk/LayoutTests/fast/js/array-every-expected.txt
r12001 r20569 43 43 PASS [12, 54, 18, 130, 44].every(isBigEnoughShortCircuit) is true 44 44 PASS accumulator.toString() is [12, 54, 18, 130, 44].toString() 45 46 7.0 Behavior for Holes in Arrays 47 PASS arr.every(isNotUndefined) is true 48 PASS arr.every(isNotUndefined) is true 45 49 PASS successfullyParsed is true 46 50 -
trunk/LayoutTests/fast/js/array-foreach-expected.txt
r19397 r20569 52 52 TypeError: Type error 53 53 54 6.0 Behavior for Holes in Arrays 55 This test checks that holes in arrays (indexes which have been deleted or are not present) are not included in enumeration: 56 57 Manually deleted index not enumerated 58 Array created using constructor has no properties, so no indexes enumerated 59 60 7.0 Return Value 61 This test checks that the return value of Array.prototype.forEach is undefined: 62 63 Return value is undefined! 64 -
trunk/LayoutTests/fast/js/array-foreach.html
r19397 r20569 140 140 </script> 141 141 142 <br/> 143 6.0 Behavior for Holes in Arrays<br/> 144 This test checks that holes in arrays (indexes which have been deleted or are not present) are not included in enumeration:<br/><br/> 145 <script> 146 function throwIfUndefined(element, index, array) { 147 if (typeof element === "undefined") 148 throw "undefined element enumerated!"; 149 } 150 151 var arr; 152 try { 153 arr = [5, 5, 5, 5]; 154 delete arr[1]; 155 arr.forEach(throwIfUndefined); 156 print("Manually deleted index not enumerated"); 157 } catch (e) { 158 print(e); 159 } 160 161 try { 162 arr = new Array(20); 163 arr.forEach(throwIfUndefined); 164 print("Array created using constructor has no properties, so no indexes enumerated"); 165 } catch (e) { 166 print(e); 167 } 168 169 </script> 170 171 <br/> 172 7.0 Return Value<br/> 173 This test checks that the return value of Array.prototype.forEach is undefined:<br/><br/> 174 <script> 175 var wasUndefined = typeof ([1, 2, 3].forEach(function(){})) === "undefined"; 176 177 print("Return value is " + (wasUndefined ? "" : "NOT ") + "undefined!"); 178 </script> 179 142 180 </body> 143 181 </html> -
trunk/LayoutTests/fast/js/array-indexof-expected.txt
r12001 r20569 50 50 * The indexOf undefined is 7 51 51 * The indexOf undefined is -1 52 * The indexOf undefined is 3 53 * The indexOf undefined is -1 54 * The indexOf undefined is -1 52 55 53 56 14.0 Object using the Array prototype -
trunk/LayoutTests/fast/js/array-indexof.html
r11995 r20569 15 15 testArray3[5] = 9; 16 16 testArray3.length = 6; 17 var testArray4 = [5, 5, 5, undefined]; 18 delete testArray4[1]; 19 var testArray5 = [5, 5, 5, undefined]; 20 delete testArray5[3]; 21 var testArray6 = new Array(20); 17 22 if (window.layoutTestController) 18 23 layoutTestController.dumpAsText(); … … 24 29 25 30 <p>1.0 Direct Testing, no starting at Parameter<br> 26 27 28 29 30 31 * The indexOf String "Hello" is <script>document.write(testArray.indexOf("Hello"))</script><br> 32 * The indexOf String "Hi" is <script>document.write(testArray.indexOf("Hi"))</script><br> 33 * The indexOf Boolean 'true' is <script>document.write(testArray.indexOf( true ))</script><br> 34 * The indexOf Number '5' is <script>document.write(testArray.indexOf( 5 ))</script><br> 35 * The indexOf Number '9' is <script>document.write(testArray.indexOf( 9 ))</script> 31 36 </p> 32 37 33 38 <p>2.0 A firstIndex parameter of 1 (positive offset test)<br> 34 35 36 37 39 * The indexOf String "Hi" is <script>document.write(testArray.indexOf("Hi",1))</script><br> 40 * The indexOf Boolean 'true' is <script>document.write(testArray.indexOf(true,1))</script><br> 41 * The indexOf Number 5 is <script>document.write(testArray.indexOf(5,1))</script><br> 42 * The indexOf Number 9 is <script>document.write(testArray.indexOf(9,1))</script> 38 43 </p> 39 44 40 45 <p>3.0 A firstIndex parameter of -4 (negative offset test)<br> 41 42 43 44 46 * The indexOf String "Hi" is <script>document.write(testArray.indexOf("Hi",-4))</script><br> 47 * The indexOf Boolean 'true' is <script>document.write(testArray.indexOf(true,-4))</script><br> 48 * The indexOf Number 5 is <script>document.write(testArray.indexOf(5,-4))</script><br> 49 * The indexOf Number 9 is <script>document.write(testArray.indexOf(9,-4))</script> 45 50 </p> 46 51 47 52 <p>4.0 A big positive firstIndex of 1000, to test the firstIndex > length<br> 48 53 * The indexOf Number '9' is <script>document.write(testArray.indexOf(9,1000))</script> 49 54 </p> 50 55 51 56 <p>5.0 A big positive firstIndex of 4294967301, to test when firstIndex > width of int (32-bits)<br> 52 57 * The indexOf Boolean 'true' is <script>document.write(testArray.indexOf(true, 4294967301))</script> 53 58 </p> 54 59 55 60 <p>6.0 No arguments<br> 56 57 61 * No arguments passed: <script>document.write(testArray.indexOf())</script><br> 62 * No arguments passed: <script>document.write(testArray2.indexOf())</script> 58 63 </p> 59 64 60 65 <p>7.0 Looking for null<br> 61 62 66 * The indexOf null is <script>document.write(testArray.indexOf(null))</script><br> 67 * The indexOf null is <script>document.write(testArray2.indexOf(null))</script> 63 68 </p> 64 69 65 70 <p>8.0 Extra arguments<br> 66 71 * The indexOf String "Hello" is <script>document.write(testArray.indexOf("Hello", 0, true))</script> 67 72 </p> 68 73 69 74 <p>9.0 NaN firstIndex<br> 70 75 * The indexOf String "Hi" is <script>document.write(testArray.indexOf("Hello", "Hey"))</script> 71 76 </p> 72 77 73 78 <p>10.0 Small firstIndex<br> 74 79 * The indexOf Boolean 'true' is <script>document.write(testArray.indexOf(true, 0.45))</script> 75 80 </p> 76 81 77 82 <p>11.0 Negative firstIndex bigger than the length of the array<br> 78 83 * The indexOf Boolean 'true' is <script>document.write(testArray.indexOf(true, -1000))</script> 79 84 </p> 80 85 81 86 <p>12.0 Negative firstIndex bigger than 32-bits<br> 82 87 * The indexOf Boolean 'true' is <script>document.write(testArray.indexOf(true, -5294967301))</script> 83 88 </p> 84 89 85 90 <p>13.0 Looking for undefined<br> 86 * The indexOf undefined is <script>document.write(testArray.indexOf(undefined))</script><br> 87 * The indexOf undefined is <script>document.write(testArray2.indexOf(undefined))</script> 91 * The indexOf undefined is <script>document.write(testArray.indexOf(undefined))</script><br> 92 * The indexOf undefined is <script>document.write(testArray2.indexOf(undefined))</script><br> 93 * The indexOf undefined is <script>document.write(testArray4.indexOf(undefined))</script><br> 94 * The indexOf undefined is <script>document.write(testArray5.indexOf(undefined))</script><br> 95 * The indexOf undefined is <script>document.write(testArray6.indexOf(undefined))</script> 88 96 </p> 89 97 90 98 <p>14.0 Object using the Array prototype<br> 91 92 93 94 95 99 * The indexOf String "Hello" is <script>document.write(testArray3.indexOf("Hello"))</script><br> 100 * The indexOf String "Hi" is <script>document.write(testArray3.indexOf("Hi"))</script><br> 101 * The indexOf Boolean 'true' is <script>document.write(testArray3.indexOf(true))</script><br> 102 * The indexOf Number '5' is <script>document.write(testArray3.indexOf(5))</script><br> 103 * The indexOf Number '9' is <script>document.write(testArray3.indexOf(9))</script> 96 104 </p> 97 105 -
trunk/LayoutTests/fast/js/array-lastIndexOf-expected.txt
r15952 r20569 12 12 PASS lastIndex is 0 13 13 PASS lastIndex is 3 14 PASS lastIndex is -1 15 PASS lastIndex is -1 16 PASS lastIndex is -1 17 PASS lastIndex is 19 18 PASS lastIndex is -1 19 PASS lastIndex is -1 14 20 PASS successfullyParsed is true 15 21 -
trunk/LayoutTests/fast/js/array-some-expected.txt
r19397 r20569 59 59 Done with second array. 60 60 61 7.0 Behavior with Holes in Arrays 62 This test checks that the callback function is not invoked for holes in the array. Five arrays are tested: 63 64 Testing element 2... 65 Testing element 8... 66 Testing element 1... 67 Testing element 4... 68 Done with first array. 69 Testing element undefined... 70 Done with second array. 71 Done with third array. 72 Done with fourth array. 73 Testing element undefined... 74 Done with fifth array. 75 -
trunk/LayoutTests/fast/js/array-some.html
r19397 r20569 157 157 [12, 5, 8, 1, 44].some(isBigEnough); 158 158 print("Done with second array."); 159 160 </script> 161 <br/> 162 7.0 Behavior with Holes in Arrays<br/> 163 This test checks that the callback function is not invoked for holes in the array. Five arrays are tested:<br/><br/> 164 <script> 165 function isBigEnough(element, index, array) { 166 print("Testing element " + element + "..."); 167 return (element >= 10); 168 } 169 170 var arr = [2, 5, 8, 1, 4]; 171 delete arr[1]; 172 arr.some(isBigEnough); 173 print("Done with first array."); 174 175 arr = [undefined]; 176 arr.some(isBigEnough); 177 print("Done with second array."); 178 179 delete arr[0]; 180 arr.some(isBigEnough); 181 print("Done with third array."); 182 183 arr = new Array(20); 184 arr.some(isBigEnough); 185 print("Done with fourth array."); 186 187 arr[17] = undefined; 188 arr.some(isBigEnough); 189 print("Done with fifth array."); 190 159 191 </script> 160 192 </body> -
trunk/LayoutTests/fast/js/resources/array-every.js
r11995 r20569 81 81 shouldBeTrue("[12, 54, 18, 130, 44].every(isBigEnoughShortCircuit)"); 82 82 shouldBe("accumulator.toString()", "[12, 54, 18, 130, 44].toString()"); 83 debug(""); 84 85 debug('7.0 Behavior for Holes in Arrays'); 86 var arr = [5, 5, 5, 5]; 87 delete arr[1]; 88 function isNotUndefined(element, index, array) { 89 return typeof element !== "undefined"; 90 } 91 shouldBeTrue("arr.every(isNotUndefined)"); 92 arr = new Array(20); 93 shouldBeTrue("arr.every(isNotUndefined)"); 83 94 84 95 successfullyParsed = true; -
trunk/LayoutTests/fast/js/resources/array-lastIndexOf.js
r15952 r20569 24 24 shouldBe('lastIndex', '3'); 25 25 26 delete testArray[1]; 27 28 lastIndex = testArray.lastIndexOf(undefined); 29 shouldBe('lastIndex', '-1'); 30 31 delete testArray[3]; 32 33 lastIndex = testArray.lastIndexOf(undefined); 34 shouldBe('lastIndex', '-1'); 35 36 testArray = new Array(20); 37 38 lastIndex = testArray.lastIndexOf(undefined); 39 shouldBe('lastIndex', '-1'); 40 41 testArray[19] = undefined; 42 43 lastIndex = testArray.lastIndexOf(undefined); 44 shouldBe('lastIndex', '19'); 45 46 lastIndex = testArray.lastIndexOf(undefined, 18); 47 shouldBe('lastIndex', '-1'); 48 49 delete testArray[19]; 50 51 lastIndex = testArray.lastIndexOf(undefined); 52 shouldBe('lastIndex', '-1'); 53 26 54 var successfullyParsed = true;
Note:
See TracChangeset
for help on using the changeset viewer.