Changeset 202966 in webkit
- Timestamp:
- Jul 7, 2016, 11:25:34 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 8 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/js/script-tests/string-padend.js (added)
-
LayoutTests/js/script-tests/string-padstart.js (added)
-
LayoutTests/js/string-padend-expected.txt (added)
-
LayoutTests/js/string-padend.html (added)
-
LayoutTests/js/string-padstart-expected.txt (added)
-
LayoutTests/js/string-padstart.html (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/builtins/GlobalOperations.js (modified) (1 diff)
-
Source/JavaScriptCore/builtins/StringPrototype.js (modified) (3 diffs)
-
Source/JavaScriptCore/tests/es6/Object_static_methods_Object.getOwnPropertyDescriptors-proxy.js (modified) (1 diff)
-
Source/JavaScriptCore/tests/es6/Object_static_methods_Object.getOwnPropertyDescriptors.js (modified) (2 diffs)
-
Source/JavaScriptCore/tests/es6/String.prototype_methods_String.prototype.padEnd.js (modified) (4 diffs)
-
Source/JavaScriptCore/tests/es6/String.prototype_methods_String.prototype.padStart.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r202962 r202966 1 2016-07-07 Joseph Pecoraro <pecoraro@apple.com> 2 3 padStart/padEnd with Infinity produces unexpected result 4 https://bugs.webkit.org/show_bug.cgi?id=159543 5 6 Reviewed by Benjamin Poulain. 7 8 * js/script-tests/string-padend.js: Added. 9 (thisObject.toString): 10 (lengthObject.valueOf): 11 (fillObject.toString): 12 * js/script-tests/string-padstart.js: Added. 13 (thisObject.toString): 14 (lengthObject.valueOf): 15 (fillObject.toString): 16 * js/string-padend-expected.txt: Added. 17 * js/string-padend.html: Added. 18 * js/string-padstart-expected.txt: Added. 19 * js/string-padstart.html: Added. 20 Add some basic String.prototype.padStart/padEnd test coverage 21 that is not just in the JavaScriptCore/tests/es6 directory. 22 1 23 2016-07-07 Frederic Wang <fwang@igalia.com> 2 24 -
trunk/Source/JavaScriptCore/ChangeLog
r202956 r202966 1 2016-07-07 Joseph Pecoraro <pecoraro@apple.com> 2 3 padStart/padEnd with Infinity produces unexpected result 4 https://bugs.webkit.org/show_bug.cgi?id=159543 5 6 Reviewed by Benjamin Poulain. 7 8 * builtins/GlobalOperations.js: 9 (globalPrivate.toLength): 10 Fix style. 11 12 * builtins/StringPrototype.js: 13 (padStart): 14 (padEnd): 15 After all observable operations, and after empty string has been handled, 16 throw an out of memory error if the resulting string would be greater 17 than the maximum string size. 18 19 * tests/es6/Object_static_methods_Object.getOwnPropertyDescriptors-proxy.js: 20 (shouldThrow): Deleted. 21 * tests/es6/Object_static_methods_Object.getOwnPropertyDescriptors.js: 22 (shouldThrow): 23 (testMeta): 24 * tests/es6/String.prototype_methods_String.prototype.padEnd.js: 25 (shouldThrow): 26 (TestToLength): 27 (TestMemoryLimits): 28 (TestMeta): Deleted. 29 * tests/es6/String.prototype_methods_String.prototype.padStart.js: 30 (shouldThrow): 31 (TestToLength): 32 (TestMemoryLimits): 33 Replace incorrect shouldThrow(..., errorType) with explicit shouldThrow(..., errorMessage). 34 The old shouldThrow would incorrectly succeed if the expected error type was just "Error". 35 Now we explicitly check the error message. 36 1 37 2016-07-07 Benjamin Poulain <benjamin@webkit.org> 2 38 -
trunk/Source/JavaScriptCore/builtins/GlobalOperations.js
r202680 r202966 46 46 var length = @toInteger(target); 47 47 // originally Math.min(Math.max(length, 0), maxSafeInteger)); 48 return length > 0 ? (length < @MAX_SAFE_INTEGER? length : @MAX_SAFE_INTEGER) : 0; 49 48 return length > 0 ? (length < @MAX_SAFE_INTEGER ? length : @MAX_SAFE_INTEGER) : 0; 50 49 } 51 50 -
trunk/Source/JavaScriptCore/builtins/StringPrototype.js
r202954 r202966 139 139 var string = @toString(this); 140 140 maxLength = @toLength(maxLength); 141 var fillString = arguments[1];142 141 143 142 var stringLength = string.length; … … 146 145 147 146 var filler; 148 if (arguments[1] === @undefined) 147 var fillString = arguments[1]; 148 if (fillString === @undefined) 149 149 filler = " "; 150 150 else { 151 filler = @toString( arguments[1]);151 filler = @toString(fillString); 152 152 if (filler === "") 153 153 return string; 154 154 } 155 156 if (maxLength > @MAX_STRING_LENGTH) 157 throw new @Error("Out of memory"); 155 158 156 159 var fillLength = maxLength - stringLength; … … 182 185 183 186 var filler; 184 if (arguments[1] === @undefined) 187 var fillString = arguments[1]; 188 if (fillString === @undefined) 185 189 filler = " "; 186 190 else { 187 filler = @toString( arguments[1]);191 filler = @toString(fillString); 188 192 if (filler === "") 189 193 return string; 190 194 } 195 196 if (maxLength > @MAX_STRING_LENGTH) 197 throw new @Error("Out of memory"); 191 198 192 199 var fillLength = maxLength - stringLength; -
trunk/Source/JavaScriptCore/tests/es6/Object_static_methods_Object.getOwnPropertyDescriptors-proxy.js
r196040 r202966 6 6 if (actual !== expected) 7 7 throw new Error('bad value' + msg + ': ' + actual + '. Expected ' + expected); 8 }9 10 function shouldThrow(func, errorType) {11 try {12 func();13 throw new Error('Expected ' + func + '() to throw ' + errorType.name + ', but did not throw.');14 } catch (e) {15 if (e instanceof errorType) return;16 throw new Error('Expected ' + func + '() to throw ' + errorType.name + ', but threw ' + e);17 }18 8 } 19 9 -
trunk/Source/JavaScriptCore/tests/es6/Object_static_methods_Object.getOwnPropertyDescriptors.js
r198572 r202966 8 8 } 9 9 10 function shouldThrow(func, errorType) { 10 function shouldThrow(func, errorMessage) { 11 var errorThrown = false; 12 var error = null; 11 13 try { 12 14 func(); 13 throw new Error('Expected ' + func + '() to throw ' + errorType.name + ', but did not throw.');14 15 } catch (e) { 15 if (e instanceof errorType) return;16 throw new Error('Expected ' + func + '() to throw ' + errorType.name + ', but threw ' + e);16 errorThrown = true; 17 error = e; 17 18 } 19 if (!errorThrown) 20 throw new Error('not thrown'); 21 if (String(error) !== errorMessage) 22 throw new Error(`bad error: ${String(error)}`); 18 23 } 19 24 … … 39 44 shouldBe(true, propertyDescriptor.configurable); 40 45 41 shouldThrow(() => new Object.getOwnPropertyDescriptors({}), TypeError);46 shouldThrow(() => new Object.getOwnPropertyDescriptors({}), "TypeError: function is not a constructor (evaluating 'new Object.getOwnPropertyDescriptors({})')"); 42 47 })(); 43 48 44 49 (function testToObject() { 45 shouldThrow(() => Object.getOwnPropertyDescriptors(null), TypeError);46 shouldThrow(() => Object.getOwnPropertyDescriptors(undefined), TypeError);47 shouldThrow(() => Object.getOwnPropertyDescriptors(), TypeError);50 shouldThrow(() => Object.getOwnPropertyDescriptors(null), "TypeError: null is not an object (evaluating 'Object.getOwnPropertyDescriptors(null)')"); 51 shouldThrow(() => Object.getOwnPropertyDescriptors(undefined), "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptors(undefined)')"); 52 shouldThrow(() => Object.getOwnPropertyDescriptors(), "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptors()')"); 48 53 })(); 49 54 -
trunk/Source/JavaScriptCore/tests/es6/String.prototype_methods_String.prototype.padEnd.js
r200194 r202966 8 8 } 9 9 10 function shouldThrow(func, errorType) { 10 function shouldThrow(func, errorMessage) { 11 var errorThrown = false; 12 var error = null; 11 13 try { 12 14 func(); 13 throw new Error('Expected ' + func + '() to throw ' + errorType.name + ', but did not throw.');14 15 } catch (e) { 15 if (e instanceof errorType) return;16 throw new Error('Expected ' + func + '() to throw ' + errorType.name + ', but threw ' + e);16 errorThrown = true; 17 error = e; 17 18 } 19 if (!errorThrown) 20 throw new Error('not thrown'); 21 if (String(error) !== errorMessage) 22 throw new Error(`bad error: ${String(error)}`); 18 23 } 19 24 … … 32 37 shouldBe(String.prototype.padEnd, descriptor.value); 33 38 34 shouldThrow(() => new Function(`${String.prototype.padEnd}`), SyntaxError);39 shouldThrow(() => new Function(`${String.prototype.padEnd}`), "SyntaxError: Unexpected identifier 'code'. Expected either a closing ']' or a ',' following an array element."); 35 40 })(); 36 41 37 42 (function TestRequireObjectCoercible() { 38 43 var padEnd = String.prototype.padEnd; 39 shouldThrow(() => padEnd.call(null, 4, "test"), TypeError);40 shouldThrow(() => padEnd.call(undefined, 4, "test"), TypeError);44 shouldThrow(() => padEnd.call(null, 4, "test"), "TypeError: String.prototype.padEnd requires that |this| not be null"); 45 shouldThrow(() => padEnd.call(undefined, 4, "test"), "TypeError: String.prototype.padEnd requires that |this| not be undefined"); 41 46 shouldBe("123 ", padEnd.call({ 42 47 __proto__: null, … … 64 69 65 70 (function TestToLength() { 66 shouldThrow(() => "123".padEnd(Symbol("16")), TypeError);71 shouldThrow(() => "123".padEnd(Symbol("16")), "TypeError: Cannot convert a symbol to a number"); 67 72 shouldBe("123", "123".padEnd(-1)); 68 73 shouldBe("123", "123".padEnd({ toString() { return -1; } })); … … 97 102 98 103 (function TestMemoryLimits() { 99 shouldThrow(() => ".".padEnd(0x80000000, "o"), Error);100 shouldThrow(() => ".".padEnd({ valueOf() { return 0x80000000; } }, "o"), Error);101 shouldThrow(() => ".".padEnd("0x80000000", "o"), Error);104 shouldThrow(() => ".".padEnd(0x80000000, "o"), "Error: Out of memory"); 105 shouldThrow(() => ".".padEnd({ valueOf() { return 0x80000000; } }, "o"), "Error: Out of memory"); 106 shouldThrow(() => ".".padEnd("0x80000000", "o"), "Error: Out of memory"); 102 107 })(); 103 108 -
trunk/Source/JavaScriptCore/tests/es6/String.prototype_methods_String.prototype.padStart.js
r200194 r202966 8 8 } 9 9 10 function shouldThrow(func, errorType) { 10 function shouldThrow(func, errorMessage) { 11 var errorThrown = false; 12 var error = null; 11 13 try { 12 14 func(); 13 throw new Error('Expected ' + func + '() to throw ' + errorType.name + ', but did not throw.');14 15 } catch (e) { 15 if (e instanceof errorType) return;16 throw new Error('Expected ' + func + '() to throw ' + errorType.name + ', but threw ' + e);16 errorThrown = true; 17 error = e; 17 18 } 19 if (!errorThrown) 20 throw new Error('not thrown'); 21 if (String(error) !== errorMessage) 22 throw new Error(`bad error: ${String(error)}`); 18 23 } 19 24 … … 32 37 shouldBe(String.prototype.padStart, descriptor.value); 33 38 34 shouldThrow(() => new Function(`${String.prototype.padStart}`), SyntaxError);39 shouldThrow(() => new Function(`${String.prototype.padStart}`), "SyntaxError: Unexpected identifier 'code'. Expected either a closing ']' or a ',' following an array element."); 35 40 })(); 36 41 37 42 (function TestRequireObjectCoercible() { 38 43 var padStart = String.prototype.padStart; 39 shouldThrow(() => padStart.call(null, 4, "test"), TypeError);40 shouldThrow(() => padStart.call(undefined, 4, "test"), TypeError);44 shouldThrow(() => padStart.call(null, 4, "test"), "TypeError: String.prototype.padStart requires that |this| not be null"); 45 shouldThrow(() => padStart.call(undefined, 4, "test"), "TypeError: String.prototype.padStart requires that |this| not be undefined"); 41 46 shouldBe(" 123", padStart.call({ 42 47 __proto__: null, … … 64 69 65 70 (function TestToLength() { 66 shouldThrow(() => "123".padStart(Symbol("16")), TypeError);71 shouldThrow(() => "123".padStart(Symbol("16")), "TypeError: Cannot convert a symbol to a number"); 67 72 shouldBe("123", "123".padStart(-1)); 68 73 shouldBe("123", "123".padStart({ toString() { return -1; } })); … … 97 102 98 103 (function TestMemoryLimits() { 99 shouldThrow(() => ".".padStart(0x80000000, "o"), Error);100 shouldThrow(() => ".".padStart({ valueOf() { return 0x80000000; } }, "o"), Error);101 shouldThrow(() => ".".padStart("0x80000000", "o"), Error);104 shouldThrow(() => ".".padStart(0x80000000, "o"), "Error: Out of memory"); 105 shouldThrow(() => ".".padStart({ valueOf() { return 0x80000000; } }, "o"), "Error: Out of memory"); 106 shouldThrow(() => ".".padStart("0x80000000", "o"), "Error: Out of memory"); 102 107 })(); 103 108
Note:
See TracChangeset
for help on using the changeset viewer.