Changeset 202926 in webkit
- Timestamp:
- Jul 7, 2016, 12:03:27 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/js/array-includes-expected.txt (modified) (1 diff)
-
LayoutTests/js/script-tests/array-includes.js (modified) (1 diff)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/builtins/ArrayPrototype.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r202916 r202926 1 2016-07-07 Benjamin Poulain <benjamin@webkit.org> 2 3 [JSC] Array.prototype.includes uses ToInt32 instead of ToInteger on the index argument 4 https://bugs.webkit.org/show_bug.cgi?id=159505 5 6 Reviewed by Mark Lam. 7 8 * js/array-includes-expected.txt: 9 * js/script-tests/array-includes.js: 10 1 11 2016-07-07 Benjamin Poulain <benjamin@webkit.org> 2 12 -
trunk/LayoutTests/js/array-includes-expected.txt
r184582 r202926 35 35 PASS var obj = { 0: 1, 1: 1, 2: 1, length: -0 }; Array.prototype.includes.call(obj, 1) is false 36 36 PASS var obj = { 0: 1, 1: 1, 2: 1, length: -3 }; Array.prototype.includes.call(obj, 1) is false 37 The index is converted to integer 38 PASS [2, 3, 5, 7, 11, 13, 17].includes(2, NaN) is true 39 PASS [2, 3, 5, 7, 11, 13, 17].includes(7, NaN) is true 40 PASS [2, 3, 5, 7, 11, 13, 17].includes(17, NaN) is true 41 PASS [2, 3, 5, 7, 11, 13, 17].includes(2, Infinity) is false 42 PASS [2, 3, 5, 7, 11, 13, 17].includes(7, Infinity) is false 43 PASS [2, 3, 5, 7, 11, 13, 17].includes(17, Infinity) is false 44 PASS [2, 3, 5, 7, 11, 13, 17].includes(2, -Infinity) is true 45 PASS [2, 3, 5, 7, 11, 13, 17].includes(7, -Infinity) is true 46 PASS [2, 3, 5, 7, 11, 13, 17].includes(17, -Infinity) is true 47 PASS [2, 3, 5, 7, 11, 13, 17].includes(2, Number.MAX_SAFE_INTEGER) is false 48 PASS [2, 3, 5, 7, 11, 13, 17].includes(7, Number.MAX_SAFE_INTEGER) is false 49 PASS [2, 3, 5, 7, 11, 13, 17].includes(17, Number.MAX_SAFE_INTEGER) is false 50 PASS [2, 3, 5, 7, 11, 13, 17].includes(2, Number.MAX_SAFE_INTEGER + 1) is false 51 PASS [2, 3, 5, 7, 11, 13, 17].includes(7, Number.MAX_SAFE_INTEGER + 1) is false 52 PASS [2, 3, 5, 7, 11, 13, 17].includes(17, Number.MAX_SAFE_INTEGER + 1) is false 53 PASS [2, 3, 5, 7, 11, 13, 17].includes(2, Number.MIN_SAFE_INTEGER) is true 54 PASS [2, 3, 5, 7, 11, 13, 17].includes(7, Number.MIN_SAFE_INTEGER) is true 55 PASS [2, 3, 5, 7, 11, 13, 17].includes(17, Number.MIN_SAFE_INTEGER) is true 56 PASS [2, 3, 5, 7, 11, 13, 17].includes(2, Number.MIN_SAFE_INTEGER - 1) is true 57 PASS [2, 3, 5, 7, 11, 13, 17].includes(7, Number.MIN_SAFE_INTEGER - 1) is true 58 PASS [2, 3, 5, 7, 11, 13, 17].includes(17, Number.MIN_SAFE_INTEGER - 1) is true 59 PASS [2, 3, 5, 7, 11, 13, 17].includes(2, { valueOf: () => { return 1; } }) is false 60 PASS [2, 3, 5, 7, 11, 13, 17].includes(7, { valueOf: () => { return 1; } }) is true 61 PASS [2, 3, 5, 7, 11, 13, 17].includes(17, { valueOf: () => { return 1; } }) is true 62 PASS [2, 3, 5, 7, 11, 13, 17].includes(2, { toString: () => { return '1'; } }) is false 63 PASS [2, 3, 5, 7, 11, 13, 17].includes(7, { toString: () => { return '1'; } }) is true 64 PASS [2, 3, 5, 7, 11, 13, 17].includes(17, { toString: () => { return '1'; } }) is true 65 PASS [2, 3, 5, 7, 11, 13, 17].includes(2, '1') is false 66 PASS [2, 3, 5, 7, 11, 13, 17].includes(7, '1') is true 67 PASS [2, 3, 5, 7, 11, 13, 17].includes(17, '1') is true 37 68 PASS successfullyParsed is true 38 69 -
trunk/LayoutTests/js/script-tests/array-includes.js
r184582 r202926 48 48 shouldBeFalse("var obj = { 0: 1, 1: 1, 2: 1, length: -0 }; Array.prototype.includes.call(obj, 1)"); 49 49 shouldBeFalse("var obj = { 0: 1, 1: 1, 2: 1, length: -3 }; Array.prototype.includes.call(obj, 1)"); 50 51 debug("The index is converted to integer"); 52 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(2, NaN)"); 53 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(7, NaN)"); 54 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(17, NaN)"); 55 shouldBeFalse("[2, 3, 5, 7, 11, 13, 17].includes(2, Infinity)"); 56 shouldBeFalse("[2, 3, 5, 7, 11, 13, 17].includes(7, Infinity)"); 57 shouldBeFalse("[2, 3, 5, 7, 11, 13, 17].includes(17, Infinity)"); 58 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(2, -Infinity)"); 59 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(7, -Infinity)"); 60 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(17, -Infinity)"); 61 shouldBeFalse("[2, 3, 5, 7, 11, 13, 17].includes(2, Number.MAX_SAFE_INTEGER)"); 62 shouldBeFalse("[2, 3, 5, 7, 11, 13, 17].includes(7, Number.MAX_SAFE_INTEGER)"); 63 shouldBeFalse("[2, 3, 5, 7, 11, 13, 17].includes(17, Number.MAX_SAFE_INTEGER)"); 64 shouldBeFalse("[2, 3, 5, 7, 11, 13, 17].includes(2, Number.MAX_SAFE_INTEGER + 1)"); 65 shouldBeFalse("[2, 3, 5, 7, 11, 13, 17].includes(7, Number.MAX_SAFE_INTEGER + 1)"); 66 shouldBeFalse("[2, 3, 5, 7, 11, 13, 17].includes(17, Number.MAX_SAFE_INTEGER + 1)"); 67 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(2, Number.MIN_SAFE_INTEGER)"); 68 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(7, Number.MIN_SAFE_INTEGER)"); 69 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(17, Number.MIN_SAFE_INTEGER)"); 70 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(2, Number.MIN_SAFE_INTEGER - 1)"); 71 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(7, Number.MIN_SAFE_INTEGER - 1)"); 72 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(17, Number.MIN_SAFE_INTEGER - 1)"); 73 74 shouldBeFalse("[2, 3, 5, 7, 11, 13, 17].includes(2, { valueOf: () => { return 1; } })"); 75 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(7, { valueOf: () => { return 1; } })"); 76 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(17, { valueOf: () => { return 1; } })"); 77 78 shouldBeFalse("[2, 3, 5, 7, 11, 13, 17].includes(2, { toString: () => { return '1'; } })"); 79 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(7, { toString: () => { return '1'; } })"); 80 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(17, { toString: () => { return '1'; } })"); 81 82 shouldBeFalse("[2, 3, 5, 7, 11, 13, 17].includes(2, '1')"); 83 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(7, '1')"); 84 shouldBeTrue("[2, 3, 5, 7, 11, 13, 17].includes(17, '1')"); -
trunk/Source/JavaScriptCore/ChangeLog
r202916 r202926 1 2016-07-07 Benjamin Poulain <benjamin@webkit.org> 2 3 [JSC] Array.prototype.includes uses ToInt32 instead of ToInteger on the index argument 4 https://bugs.webkit.org/show_bug.cgi?id=159505 5 6 Reviewed by Mark Lam. 7 8 The code was using (value)|0 which is effectively a ToInt32. 9 This fails on large integers and +-Infinity. 10 11 Spec: https://tc39.github.io/ecma262/#sec-array.prototype.includes 12 13 * builtins/ArrayPrototype.js: 14 (includes): 15 1 16 2016-07-07 Benjamin Poulain <benjamin@webkit.org> 2 17 -
trunk/Source/JavaScriptCore/builtins/ArrayPrototype.js
r202280 r202926 435 435 var fromIndex = 0; 436 436 if (arguments.length > 1 && arguments[1] !== @undefined) 437 fromIndex = arguments[1] | 0;437 fromIndex = @toInteger(arguments[1]); 438 438 439 439 var index;
Note:
See TracChangeset
for help on using the changeset viewer.