diff --git a/CHANGELOG.md b/CHANGELOG.md index 731199a3a990..af1571d516dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Changelog ##### Unreleased -- Nothing +- Dropped `ToLength` detection from array methods feature detection which could cause hanging FF11-21 and some versions of old WebKit, [#764](https://github.com/zloirock/core-js/issues/764) +- Minified bundle from `core-js-bundle` uses `terser` instead of `uglify-js` ##### 3.8.3 - 2021.01.19 - Fixed some more issues related to FF44- legacy `Iterator`, [#906](https://github.com/zloirock/core-js/issues/906) diff --git a/packages/core-js-compat/src/data.js b/packages/core-js-compat/src/data.js index f474df3c817e..e316e085de87 100644 --- a/packages/core-js-compat/src/data.js +++ b/packages/core-js-compat/src/data.js @@ -101,10 +101,10 @@ const data = { safari: '9.0', }, 'es.array.every': { - chrome: '48', - edge: '15', - firefox: '50', - safari: '9.0', + chrome: '26', + firefox: '4', + ie: '9', + safari: '8.0', }, 'es.array.fill': { chrome: '45', @@ -141,10 +141,10 @@ const data = { safari: '12.0', }, 'es.array.for-each': { - chrome: '48', - edge: '15', - firefox: '50', - safari: '9.0', + chrome: '26', + firefox: '4', + ie: '9', + safari: '8.0', }, 'es.array.from': { chrome: '51', @@ -154,15 +154,15 @@ const data = { }, 'es.array.includes': { chrome: '53', - edge: '15', + edge: '14', firefox: '48', safari: '10.0', }, 'es.array.index-of': { chrome: '51', - edge: '15', - firefox: '50', - safari: '11.0', + firefox: '4', + ie: '9', + safari: '8.0', }, 'es.array.is-array': { chrome: '5', @@ -185,9 +185,9 @@ const data = { }, 'es.array.last-index-of': { chrome: '51', - edge: '13', - firefox: '50', - safari: '11.0', + firefox: '4', + ie: '9', + safari: '8.0', }, 'es.array.map': { chrome: '51', @@ -203,17 +203,17 @@ const data = { }, 'es.array.reduce': { chrome: '83', // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982 - edge: '15', - firefox: '50', + firefox: '4', + ie: '9', node: '6.0', // ^^^ - safari: '9.0', + safari: '8.0', }, 'es.array.reduce-right': { chrome: '83', // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982 - edge: '15', - firefox: '50', + firefox: '4', + ie: '9', node: '6.0', // ^^^ - safari: '9.0', + safari: '8.0', }, 'es.array.reverse': { chrome: '1', @@ -225,15 +225,15 @@ const data = { }, 'es.array.slice': { chrome: '51', - edge: '15', + edge: '13', firefox: '48', - safari: '11.0', + safari: '10.0', }, 'es.array.some': { - chrome: '48', - edge: '15', - firefox: '50', - safari: '9.0', + chrome: '26', + firefox: '4', + ie: '9', + safari: '8.0', }, 'es.array.sort': { chrome: '63', @@ -249,9 +249,9 @@ const data = { }, 'es.array.splice': { chrome: '51', - edge: '15', + edge: '13', firefox: '49', - safari: '11.0', + safari: '10.0', }, 'es.array.unscopables.flat': { chrome: '73', diff --git a/packages/core-js/internals/array-for-each.js b/packages/core-js/internals/array-for-each.js index 0e2dc90c710a..fe805876363f 100644 --- a/packages/core-js/internals/array-for-each.js +++ b/packages/core-js/internals/array-for-each.js @@ -1,13 +1,11 @@ 'use strict'; var $forEach = require('../internals/array-iteration').forEach; var arrayMethodIsStrict = require('../internals/array-method-is-strict'); -var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length'); var STRICT_METHOD = arrayMethodIsStrict('forEach'); -var USES_TO_LENGTH = arrayMethodUsesToLength('forEach'); // `Array.prototype.forEach` method implementation // https://tc39.es/ecma262/#sec-array.prototype.foreach -module.exports = (!STRICT_METHOD || !USES_TO_LENGTH) ? function forEach(callbackfn /* , thisArg */) { +module.exports = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) { return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); } : [].forEach; diff --git a/packages/core-js/internals/array-last-index-of.js b/packages/core-js/internals/array-last-index-of.js index a1bf9c6d13c4..b6ead9f4d98b 100644 --- a/packages/core-js/internals/array-last-index-of.js +++ b/packages/core-js/internals/array-last-index-of.js @@ -3,15 +3,12 @@ var toIndexedObject = require('../internals/to-indexed-object'); var toInteger = require('../internals/to-integer'); var toLength = require('../internals/to-length'); var arrayMethodIsStrict = require('../internals/array-method-is-strict'); -var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length'); var min = Math.min; var nativeLastIndexOf = [].lastIndexOf; var NEGATIVE_ZERO = !!nativeLastIndexOf && 1 / [1].lastIndexOf(1, -0) < 0; var STRICT_METHOD = arrayMethodIsStrict('lastIndexOf'); -// For preventing possible almost infinite loop in non-standard implementations, test the forward version of the method -var USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 }); -var FORCED = NEGATIVE_ZERO || !STRICT_METHOD || !USES_TO_LENGTH; +var FORCED = NEGATIVE_ZERO || !STRICT_METHOD; // `Array.prototype.lastIndexOf` method implementation // https://tc39.es/ecma262/#sec-array.prototype.lastindexof diff --git a/packages/core-js/internals/array-method-uses-to-length.js b/packages/core-js/internals/array-method-uses-to-length.js deleted file mode 100644 index 9863b6f4c004..000000000000 --- a/packages/core-js/internals/array-method-uses-to-length.js +++ /dev/null @@ -1,27 +0,0 @@ -var DESCRIPTORS = require('../internals/descriptors'); -var fails = require('../internals/fails'); -var has = require('../internals/has'); - -var defineProperty = Object.defineProperty; -var cache = {}; - -var thrower = function (it) { throw it; }; - -module.exports = function (METHOD_NAME, options) { - if (has(cache, METHOD_NAME)) return cache[METHOD_NAME]; - if (!options) options = {}; - var method = [][METHOD_NAME]; - var ACCESSORS = has(options, 'ACCESSORS') ? options.ACCESSORS : false; - var argument0 = has(options, 0) ? options[0] : thrower; - var argument1 = has(options, 1) ? options[1] : undefined; - - return cache[METHOD_NAME] = !!method && !fails(function () { - if (ACCESSORS && !DESCRIPTORS) return true; - var O = { length: -1 }; - - if (ACCESSORS) defineProperty(O, 1, { enumerable: true, get: thrower }); - else O[1] = 1; - - method.call(O, argument0, argument1); - }); -}; diff --git a/packages/core-js/modules/es.array.every.js b/packages/core-js/modules/es.array.every.js index 137a53763d4b..61b526e1d4ab 100644 --- a/packages/core-js/modules/es.array.every.js +++ b/packages/core-js/modules/es.array.every.js @@ -2,14 +2,12 @@ var $ = require('../internals/export'); var $every = require('../internals/array-iteration').every; var arrayMethodIsStrict = require('../internals/array-method-is-strict'); -var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length'); var STRICT_METHOD = arrayMethodIsStrict('every'); -var USES_TO_LENGTH = arrayMethodUsesToLength('every'); // `Array.prototype.every` method // https://tc39.es/ecma262/#sec-array.prototype.every -$({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH }, { +$({ target: 'Array', proto: true, forced: !STRICT_METHOD }, { every: function every(callbackfn /* , thisArg */) { return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); } diff --git a/packages/core-js/modules/es.array.filter.js b/packages/core-js/modules/es.array.filter.js index 24b963244f0c..beb43a5d3386 100644 --- a/packages/core-js/modules/es.array.filter.js +++ b/packages/core-js/modules/es.array.filter.js @@ -2,16 +2,13 @@ var $ = require('../internals/export'); var $filter = require('../internals/array-iteration').filter; var arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support'); -var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length'); var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter'); -// Edge 14- issue -var USES_TO_LENGTH = arrayMethodUsesToLength('filter'); // `Array.prototype.filter` method // https://tc39.es/ecma262/#sec-array.prototype.filter // with adding support of @@species -$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, { +$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { filter: function filter(callbackfn /* , thisArg */) { return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); } diff --git a/packages/core-js/modules/es.array.find-index.js b/packages/core-js/modules/es.array.find-index.js index fb00efcfe731..f3e086299900 100644 --- a/packages/core-js/modules/es.array.find-index.js +++ b/packages/core-js/modules/es.array.find-index.js @@ -2,19 +2,16 @@ var $ = require('../internals/export'); var $findIndex = require('../internals/array-iteration').findIndex; var addToUnscopables = require('../internals/add-to-unscopables'); -var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length'); var FIND_INDEX = 'findIndex'; var SKIPS_HOLES = true; -var USES_TO_LENGTH = arrayMethodUsesToLength(FIND_INDEX); - // Shouldn't skip holes if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES = false; }); // `Array.prototype.findIndex` method // https://tc39.es/ecma262/#sec-array.prototype.findindex -$({ target: 'Array', proto: true, forced: SKIPS_HOLES || !USES_TO_LENGTH }, { +$({ target: 'Array', proto: true, forced: SKIPS_HOLES }, { findIndex: function findIndex(callbackfn /* , that = undefined */) { return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); } diff --git a/packages/core-js/modules/es.array.find.js b/packages/core-js/modules/es.array.find.js index 7cf504db7d89..87ac94da849b 100644 --- a/packages/core-js/modules/es.array.find.js +++ b/packages/core-js/modules/es.array.find.js @@ -2,19 +2,16 @@ var $ = require('../internals/export'); var $find = require('../internals/array-iteration').find; var addToUnscopables = require('../internals/add-to-unscopables'); -var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length'); var FIND = 'find'; var SKIPS_HOLES = true; -var USES_TO_LENGTH = arrayMethodUsesToLength(FIND); - // Shouldn't skip holes if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; }); // `Array.prototype.find` method // https://tc39.es/ecma262/#sec-array.prototype.find -$({ target: 'Array', proto: true, forced: SKIPS_HOLES || !USES_TO_LENGTH }, { +$({ target: 'Array', proto: true, forced: SKIPS_HOLES }, { find: function find(callbackfn /* , that = undefined */) { return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); } diff --git a/packages/core-js/modules/es.array.includes.js b/packages/core-js/modules/es.array.includes.js index ef53a1c6b7f7..01288c2edbd7 100644 --- a/packages/core-js/modules/es.array.includes.js +++ b/packages/core-js/modules/es.array.includes.js @@ -2,13 +2,10 @@ var $ = require('../internals/export'); var $includes = require('../internals/array-includes').includes; var addToUnscopables = require('../internals/add-to-unscopables'); -var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length'); - -var USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 }); // `Array.prototype.includes` method // https://tc39.es/ecma262/#sec-array.prototype.includes -$({ target: 'Array', proto: true, forced: !USES_TO_LENGTH }, { +$({ target: 'Array', proto: true }, { includes: function includes(el /* , fromIndex = 0 */) { return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined); } diff --git a/packages/core-js/modules/es.array.index-of.js b/packages/core-js/modules/es.array.index-of.js index 50c0a4d88d4e..acd76131995b 100644 --- a/packages/core-js/modules/es.array.index-of.js +++ b/packages/core-js/modules/es.array.index-of.js @@ -2,17 +2,15 @@ var $ = require('../internals/export'); var $indexOf = require('../internals/array-includes').indexOf; var arrayMethodIsStrict = require('../internals/array-method-is-strict'); -var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length'); var nativeIndexOf = [].indexOf; var NEGATIVE_ZERO = !!nativeIndexOf && 1 / [1].indexOf(1, -0) < 0; var STRICT_METHOD = arrayMethodIsStrict('indexOf'); -var USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 }); // `Array.prototype.indexOf` method // https://tc39.es/ecma262/#sec-array.prototype.indexof -$({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD || !USES_TO_LENGTH }, { +$({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD }, { indexOf: function indexOf(searchElement /* , fromIndex = 0 */) { return NEGATIVE_ZERO // convert -0 to +0 diff --git a/packages/core-js/modules/es.array.map.js b/packages/core-js/modules/es.array.map.js index 5b58c33f8d75..4419a0b7e0fe 100644 --- a/packages/core-js/modules/es.array.map.js +++ b/packages/core-js/modules/es.array.map.js @@ -2,16 +2,13 @@ var $ = require('../internals/export'); var $map = require('../internals/array-iteration').map; var arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support'); -var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length'); var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map'); -// FF49- issue -var USES_TO_LENGTH = arrayMethodUsesToLength('map'); // `Array.prototype.map` method // https://tc39.es/ecma262/#sec-array.prototype.map // with adding support of @@species -$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, { +$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { map: function map(callbackfn /* , thisArg */) { return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); } diff --git a/packages/core-js/modules/es.array.reduce-right.js b/packages/core-js/modules/es.array.reduce-right.js index 56a9572ee9e6..79af2d8c6fc4 100644 --- a/packages/core-js/modules/es.array.reduce-right.js +++ b/packages/core-js/modules/es.array.reduce-right.js @@ -2,20 +2,17 @@ var $ = require('../internals/export'); var $reduceRight = require('../internals/array-reduce').right; var arrayMethodIsStrict = require('../internals/array-method-is-strict'); -var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length'); var CHROME_VERSION = require('../internals/engine-v8-version'); var IS_NODE = require('../internals/engine-is-node'); var STRICT_METHOD = arrayMethodIsStrict('reduceRight'); -// For preventing possible almost infinite loop in non-standard implementations, test the forward version of the method -var USES_TO_LENGTH = arrayMethodUsesToLength('reduce', { 1: 0 }); // Chrome 80-82 has a critical bug // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982 var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83; // `Array.prototype.reduceRight` method // https://tc39.es/ecma262/#sec-array.prototype.reduceright -$({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH || CHROME_BUG }, { +$({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, { reduceRight: function reduceRight(callbackfn /* , initialValue */) { return $reduceRight(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined); } diff --git a/packages/core-js/modules/es.array.reduce.js b/packages/core-js/modules/es.array.reduce.js index d820dd51a6e2..7ef15ddf2473 100644 --- a/packages/core-js/modules/es.array.reduce.js +++ b/packages/core-js/modules/es.array.reduce.js @@ -2,19 +2,17 @@ var $ = require('../internals/export'); var $reduce = require('../internals/array-reduce').left; var arrayMethodIsStrict = require('../internals/array-method-is-strict'); -var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length'); var CHROME_VERSION = require('../internals/engine-v8-version'); var IS_NODE = require('../internals/engine-is-node'); var STRICT_METHOD = arrayMethodIsStrict('reduce'); -var USES_TO_LENGTH = arrayMethodUsesToLength('reduce', { 1: 0 }); // Chrome 80-82 has a critical bug // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982 var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83; // `Array.prototype.reduce` method // https://tc39.es/ecma262/#sec-array.prototype.reduce -$({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH || CHROME_BUG }, { +$({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, { reduce: function reduce(callbackfn /* , initialValue */) { return $reduce(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined); } diff --git a/packages/core-js/modules/es.array.slice.js b/packages/core-js/modules/es.array.slice.js index 504030fe61ab..3cf306a8ec83 100644 --- a/packages/core-js/modules/es.array.slice.js +++ b/packages/core-js/modules/es.array.slice.js @@ -8,10 +8,8 @@ var toIndexedObject = require('../internals/to-indexed-object'); var createProperty = require('../internals/create-property'); var wellKnownSymbol = require('../internals/well-known-symbol'); var arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support'); -var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length'); var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice'); -var USES_TO_LENGTH = arrayMethodUsesToLength('slice', { ACCESSORS: true, 0: 0, 1: 2 }); var SPECIES = wellKnownSymbol('species'); var nativeSlice = [].slice; @@ -20,7 +18,7 @@ var max = Math.max; // `Array.prototype.slice` method // https://tc39.es/ecma262/#sec-array.prototype.slice // fallback for not array-like ES3 strings and DOM objects -$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, { +$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { slice: function slice(start, end) { var O = toIndexedObject(this); var length = toLength(O.length); diff --git a/packages/core-js/modules/es.array.some.js b/packages/core-js/modules/es.array.some.js index b557b637f322..f1b4462dd72f 100644 --- a/packages/core-js/modules/es.array.some.js +++ b/packages/core-js/modules/es.array.some.js @@ -2,14 +2,12 @@ var $ = require('../internals/export'); var $some = require('../internals/array-iteration').some; var arrayMethodIsStrict = require('../internals/array-method-is-strict'); -var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length'); var STRICT_METHOD = arrayMethodIsStrict('some'); -var USES_TO_LENGTH = arrayMethodUsesToLength('some'); // `Array.prototype.some` method // https://tc39.es/ecma262/#sec-array.prototype.some -$({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH }, { +$({ target: 'Array', proto: true, forced: !STRICT_METHOD }, { some: function some(callbackfn /* , thisArg */) { return $some(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); } diff --git a/packages/core-js/modules/es.array.splice.js b/packages/core-js/modules/es.array.splice.js index 5712f65c173d..5895e2512ef2 100644 --- a/packages/core-js/modules/es.array.splice.js +++ b/packages/core-js/modules/es.array.splice.js @@ -7,10 +7,8 @@ var toObject = require('../internals/to-object'); var arraySpeciesCreate = require('../internals/array-species-create'); var createProperty = require('../internals/create-property'); var arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support'); -var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length'); var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice'); -var USES_TO_LENGTH = arrayMethodUsesToLength('splice', { ACCESSORS: true, 0: 0, 1: 2 }); var max = Math.max; var min = Math.min; @@ -20,7 +18,7 @@ var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded'; // `Array.prototype.splice` method // https://tc39.es/ecma262/#sec-array.prototype.splice // with adding support of @@species -$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, { +$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { splice: function splice(start, deleteCount /* , ...items */) { var O = toObject(this); var len = toLength(O.length); diff --git a/tests/compat/tests.js b/tests/compat/tests.js index 9a8cded1617e..ab8460070fe9 100644 --- a/tests/compat/tests.js +++ b/tests/compat/tests.js @@ -235,7 +235,6 @@ GLOBAL.tests = { return Array.prototype.copyWithin && Array.prototype[Symbol.unscopables].copyWithin; }, 'es.array.every': function () { - [].every.call({ length: -1, 0: 1 }, function (it) { throw it; }); try { Array.prototype.every.call(null, function () { /* empty */ }); return false; @@ -246,7 +245,6 @@ GLOBAL.tests = { return Array.prototype.fill && Array.prototype[Symbol.unscopables].fill; }, 'es.array.filter': function () { - [].filter.call({ length: -1, 0: 1 }, function (it) { throw it; }); var array = []; var constructor = array.constructor = {}; constructor[Symbol.species] = function () { @@ -255,13 +253,11 @@ GLOBAL.tests = { return array.filter(Boolean).foo === 1; }, 'es.array.find': function () { - [].find.call({ length: -1, 0: 1 }, function (it) { throw it; }); var SKIPS_HOLES = true; Array(1).find(function () { return SKIPS_HOLES = false; }); return !SKIPS_HOLES && Array.prototype[Symbol.unscopables].find; }, 'es.array.find-index': function () { - [].findIndex.call({ length: -1, 0: 1 }, function (it) { throw it; }); var SKIPS_HOLES = true; Array(1).findIndex(function () { return SKIPS_HOLES = false; }); return !SKIPS_HOLES && Array.prototype[Symbol.unscopables].findIndex; @@ -273,7 +269,6 @@ GLOBAL.tests = { return Array.prototype.flatMap; }, 'es.array.for-each': function () { - [].forEach.call({ length: -1, 0: 1 }, function (it) { throw it; }); try { Array.prototype.forEach.call(null, function () { /* empty */ }); return false; @@ -282,17 +277,9 @@ GLOBAL.tests = { }, 'es.array.from': SAFE_ITERATION_CLOSING_SUPPORT, 'es.array.includes': function () { - [].includes.call(Object.defineProperty({ length: -1 }, 0, { - enumerable: true, - get: function (it) { throw it; } - }), 0); return Array.prototype[Symbol.unscopables].includes; }, 'es.array.index-of': function () { - [].indexOf.call(Object.defineProperty({ length: -1 }, 0, { - enumerable: true, - get: function (it) { throw it; } - }), 0); try { [].indexOf.call(null); } catch (error) { @@ -324,10 +311,6 @@ GLOBAL.tests = { return true; }, 'es.array.last-index-of': function () { - [].indexOf.call(Object.defineProperty({ length: -1 }, 0, { - enumerable: true, - get: function (it) { throw it; } - }), 0); try { [].lastIndexOf.call(null); } catch (error) { @@ -335,7 +318,6 @@ GLOBAL.tests = { } }, 'es.array.map': function () { - [].map.call({ length: -1, 0: 1 }, function (it) { throw it; }); var array = []; var constructor = array.constructor = {}; constructor[Symbol.species] = function () { @@ -348,7 +330,6 @@ GLOBAL.tests = { return Array.of.call(F) instanceof F; }, 'es.array.reduce': function () { - [].reduce.call({ length: -1, 0: 1 }, function (it) { throw it; }, 1); try { Array.prototype.reduce.call(null, function () { /* empty */ }, 1); } catch (error) { @@ -356,7 +337,6 @@ GLOBAL.tests = { } }, 'es.array.reduce-right': function () { - [].reduce.call({ length: -1, 0: 1 }, function (it) { throw it; }, 0); try { Array.prototype.reduceRight.call(null, function () { /* empty */ }, 1); } catch (error) { @@ -368,7 +348,6 @@ GLOBAL.tests = { return String(test) !== String(test.reverse()); }, 'es.array.slice': function () { - if ([].slice.call({ length: -1, 0: 1 }, 0, 1).length) return false; var array = []; var constructor = array.constructor = {}; constructor[Symbol.species] = function () { @@ -377,7 +356,6 @@ GLOBAL.tests = { return array.slice().foo === 1; }, 'es.array.some': function () { - [].some.call({ length: -1, 0: 1 }, function (it) { throw it; }); try { Array.prototype.some.call(null, function () { /* empty */ }); } catch (error) { diff --git a/tests/pure/es.array.splice.js b/tests/pure/es.array.splice.js index 2e6327c32773..1f62318e9a0e 100644 --- a/tests/pure/es.array.splice.js +++ b/tests/pure/es.array.splice.js @@ -24,10 +24,6 @@ QUnit.test('Array#splice', assert => { assert.throws(() => splice(null), TypeError); assert.throws(() => splice(undefined), TypeError); } - assert.deepEqual(splice({ - length: -1, - 0: 1, - }), [], 'uses ToLength'); array = []; array.constructor = { [Symbol.species]: function () { // eslint-disable-line object-shorthand return { foo: 1 }; diff --git a/tests/tests/es.array.every.js b/tests/tests/es.array.every.js index 51e6c3f2ddd8..0ca09bc18d85 100644 --- a/tests/tests/es.array.every.js +++ b/tests/tests/es.array.every.js @@ -32,10 +32,4 @@ QUnit.test('Array#every', assert => { assert.throws(() => every.call(null, () => { /* empty */ }), TypeError); assert.throws(() => every.call(undefined, () => { /* empty */ }), TypeError); } - assert.notThrows(() => every.call({ - length: -1, - 0: 1, - }, () => { - throw new Error(); - }), 'uses ToLength'); }); diff --git a/tests/tests/es.array.for-each.js b/tests/tests/es.array.for-each.js index 1de5ff1b0dd9..1e0ba5a2f8ff 100644 --- a/tests/tests/es.array.for-each.js +++ b/tests/tests/es.array.for-each.js @@ -51,10 +51,4 @@ QUnit.test('Array#forEach', assert => { forEach.call(undefined, () => { /* empty */ }); }, TypeError); } - assert.notThrows(() => forEach.call({ - length: -1, - 0: 1, - }, () => { - throw new Error(); - }) === undefined, 'uses ToLength'); }); diff --git a/tests/tests/es.array.includes.js b/tests/tests/es.array.includes.js index dd255b81e3e1..274b214a1056 100644 --- a/tests/tests/es.array.includes.js +++ b/tests/tests/es.array.includes.js @@ -1,4 +1,4 @@ -import { DESCRIPTORS, STRICT } from '../helpers/constants'; +import { STRICT } from '../helpers/constants'; QUnit.test('Array#includes', assert => { const { includes } = Array.prototype; @@ -22,15 +22,5 @@ QUnit.test('Array#includes', assert => { assert.throws(() => includes.call(null, 0), TypeError); assert.throws(() => includes.call(undefined, 0), TypeError); } - if (DESCRIPTORS) { - assert.notThrows(() => includes.call(Object.defineProperty({ - length: -1, - }, 0, { - enumerable: true, - get() { - throw new Error(); - }, - }), 1) === false, 'uses ToLength'); - } assert.ok('includes' in Array.prototype[Symbol.unscopables], 'In Array#@@unscopables'); }); diff --git a/tests/tests/es.array.index-of.js b/tests/tests/es.array.index-of.js index 2f0945d189fc..69a909188eaa 100644 --- a/tests/tests/es.array.index-of.js +++ b/tests/tests/es.array.index-of.js @@ -1,4 +1,4 @@ -import { DESCRIPTORS, STRICT } from '../helpers/constants'; +import { STRICT } from '../helpers/constants'; QUnit.test('Array#indexOf', assert => { const { indexOf } = Array.prototype; @@ -20,14 +20,4 @@ QUnit.test('Array#indexOf', assert => { assert.throws(() => indexOf.call(null, 0), TypeError); assert.throws(() => indexOf.call(undefined, 0), TypeError); } - if (DESCRIPTORS) { - assert.notThrows(() => indexOf.call(Object.defineProperty({ - length: -1, - }, 0, { - enumerable: true, - get() { - throw new Error(); - }, - }), 0) === -1, 'uses ToLength'); - } }); diff --git a/tests/tests/es.array.last-index-of.js b/tests/tests/es.array.last-index-of.js index 0d827423e690..19fb61df6e56 100644 --- a/tests/tests/es.array.last-index-of.js +++ b/tests/tests/es.array.last-index-of.js @@ -1,4 +1,4 @@ -import { DESCRIPTORS, STRICT } from '../helpers/constants'; +import { STRICT } from '../helpers/constants'; QUnit.test('Array#lastIndexOf', assert => { const { lastIndexOf } = Array.prototype; @@ -20,22 +20,4 @@ QUnit.test('Array#lastIndexOf', assert => { assert.throws(() => lastIndexOf.call(null, 0), TypeError); assert.throws(() => lastIndexOf.call(undefined, 0), TypeError); } - if (DESCRIPTORS) { - assert.notThrows(() => lastIndexOf.call(Object.defineProperties({ - length: -1, - }, { - 2147483646: { - enumerable: true, - get() { - throw new Error(); - }, - }, - 4294967294: { - enumerable: true, - get() { - throw new Error(); - }, - }, - }), 2147483647) === -1, 'uses ToLength'); - } }); diff --git a/tests/tests/es.array.reduce-right.js b/tests/tests/es.array.reduce-right.js index 943b10911d1b..c52333ce822a 100644 --- a/tests/tests/es.array.reduce-right.js +++ b/tests/tests/es.array.reduce-right.js @@ -40,11 +40,4 @@ QUnit.test('Array#reduceRight', assert => { assert.throws(() => reduceRight.call(null, () => { /* empty */ }, 1), TypeError); assert.throws(() => reduceRight.call(undefined, () => { /* empty */ }, 1), TypeError); } - assert.notThrows(() => reduceRight.call({ - length: -1, - 2147483646: 1, - 4294967294: 1, - }, () => { - throw new Error(); - }, 1) === 1, 'uses ToLength'); }); diff --git a/tests/tests/es.array.reduce.js b/tests/tests/es.array.reduce.js index 2299d3383c08..e7d7699ced1d 100644 --- a/tests/tests/es.array.reduce.js +++ b/tests/tests/es.array.reduce.js @@ -40,10 +40,4 @@ QUnit.test('Array#reduce', assert => { assert.throws(() => reduce.call(null, () => { /* empty */ }, 1), TypeError); assert.throws(() => reduce.call(undefined, () => { /* empty */ }, 1), TypeError); } - assert.notThrows(() => reduce.call({ - length: -1, - 0: 1, - }, () => { - throw new Error(); - }, 1) === 1, 'uses ToLength'); }); diff --git a/tests/tests/es.array.slice.js b/tests/tests/es.array.slice.js index 297d9e53acea..ecd14bb852ca 100644 --- a/tests/tests/es.array.slice.js +++ b/tests/tests/es.array.slice.js @@ -30,10 +30,6 @@ QUnit.test('Array#slice', assert => { assert.throws(() => slice.call(null), TypeError); assert.throws(() => slice.call(undefined), TypeError); } - assert.deepEqual(slice.call({ - length: -1, - 0: 1, - }, 0, 1), [], 'uses ToLength'); array = []; array.constructor = { [Symbol.species]: function () { // eslint-disable-line object-shorthand return { foo: 1 }; diff --git a/tests/tests/es.array.some.js b/tests/tests/es.array.some.js index 52f62aa36351..a56ad46fe36c 100644 --- a/tests/tests/es.array.some.js +++ b/tests/tests/es.array.some.js @@ -35,10 +35,4 @@ QUnit.test('Array#some', assert => { assert.throws(() => some.call(null, () => { /* empty */ }), TypeError); assert.throws(() => some.call(undefined, () => { /* empty */ }), TypeError); } - assert.notThrows(() => some.call({ - length: -1, - 0: 1, - }, () => { - throw new Error(); - }) === false, 'uses ToLength'); }); diff --git a/tests/tests/es.array.splice.js b/tests/tests/es.array.splice.js index d17916b15fc0..801686b89ff5 100644 --- a/tests/tests/es.array.splice.js +++ b/tests/tests/es.array.splice.js @@ -1,4 +1,4 @@ -import { DESCRIPTORS, STRICT } from '../helpers/constants'; +import { STRICT } from '../helpers/constants'; QUnit.test('Array#splice', assert => { const { splice } = Array.prototype; @@ -26,23 +26,9 @@ QUnit.test('Array#splice', assert => { assert.throws(() => splice.call(null), TypeError); assert.throws(() => splice.call(undefined), TypeError); } - assert.deepEqual(splice.call({ - length: -1, - 0: 1, - }), [], 'uses ToLength'); array = []; array.constructor = { [Symbol.species]: function () { // eslint-disable-line object-shorthand return { foo: 1 }; } }; assert.same(array.splice().foo, 1, '@@species'); - if (DESCRIPTORS) { - assert.notThrows(() => splice.call(Object.defineProperty({ - length: -1, - }, 0, { - enumerable: true, - get() { - throw new Error(); - }, - }), 0, 2).length === 0, 'uses ToLength'); - } });