diff --git a/third_party/test262/harness/assert.js b/third_party/test262/harness/assert.js index 7ced0cd0b4129f..b4827d2f5ac096 100644 --- a/third_party/test262/harness/assert.js +++ b/third_party/test262/harness/assert.js @@ -3,10 +3,52 @@ /*--- description: | Collection of assertion functions used throughout test262 -defines: [assert] +defines: + - assert + - formatIdentityFreeValue + - formatSimpleValue + - isNegativeZero + - isPrimitive ---*/ +function isNegativeZero(value) { + return value === 0 && 1 / value === -Infinity; +} + +function isPrimitive(value) { + return !value || (typeof value !== 'object' && typeof value !== 'function'); +} + +function formatIdentityFreeValue(value) { + switch (value === null ? 'null' : typeof value) { + case 'string': + return typeof JSON !== "undefined" ? JSON.stringify(value) : '"' + value + '"'; + case 'bigint': + return String(value) + "n"; + case 'number': + if (isNegativeZero(value)) return '-0'; + // falls through + case 'boolean': + case 'undefined': + case 'null': + return String(value); + } +} + +function formatSimpleValue(value) { + var basic = formatIdentityFreeValue(value); + if (basic) return basic; + try { + return String(value); + } catch (err) { + if (err.name === 'TypeError') { + return Object.prototype.toString.call(value); + } + throw err; + } +} + function assert(mustBeTrue, message) { if (mustBeTrue === true) { return; @@ -101,10 +143,6 @@ assert.throws = function (expectedErrorConstructor, func, message) { throw new Test262Error(message); }; -function isPrimitive(value) { - return !value || (typeof value !== 'object' && typeof value !== 'function'); -} - assert.compareArray = function (actual, expected, message) { message = message === undefined ? '' : message; @@ -113,15 +151,15 @@ assert.compareArray = function (actual, expected, message) { } if (isPrimitive(actual)) { - assert(false, `Actual argument [${actual}] shouldn't be primitive. ${message}`); + assert(false, "Actual argument [" + actual + "] shouldn't be primitive. " + String(message)); } else if (isPrimitive(expected)) { - assert(false, `Expected argument [${expected}] shouldn't be primitive. ${message}`); + assert(false, "Expected argument [" + expected + "] shouldn't be primitive. " + String(message)); } var result = compareArray(actual, expected); if (result) return; var format = compareArray.format; - assert(false, `Actual ${format(actual)} and expected ${format(expected)} should have the same contents. ${message}`); + assert(false, "Actual " + format(actual) + " and expected " + format(expected) + " should have the same contents. " + String(message)); }; function compareArray(a, b) { @@ -137,34 +175,9 @@ function compareArray(a, b) { } compareArray.format = function (arrayLike) { - return `[${Array.prototype.map.call(arrayLike, String).join(', ')}]`; + return "[" + Array.prototype.map.call(arrayLike, String).join(", ") + "]"; }; -assert._formatIdentityFreeValue = function formatIdentityFreeValue(value) { - switch (value === null ? 'null' : typeof value) { - case 'string': - return typeof JSON !== "undefined" ? JSON.stringify(value) : `"${value}"`; - case 'bigint': - return `${value}n`; - case 'number': - if (value === 0 && 1 / value === -Infinity) return '-0'; - // falls through - case 'boolean': - case 'undefined': - case 'null': - return String(value); - } -}; +assert._formatIdentityFreeValue = formatIdentityFreeValue; -assert._toString = function (value) { - var basic = assert._formatIdentityFreeValue(value); - if (basic) return basic; - try { - return String(value); - } catch (err) { - if (err.name === 'TypeError') { - return Object.prototype.toString.call(value); - } - throw err; - } -}; +assert._toString = formatSimpleValue; diff --git a/third_party/test262/harness/nativeErrors.js b/third_party/test262/harness/nativeErrors.js new file mode 100644 index 00000000000000..dab13c329fc243 --- /dev/null +++ b/third_party/test262/harness/nativeErrors.js @@ -0,0 +1,52 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Arrays of language-specified Error constructors, plus a helper that + constructs a sample instance with appropriate arguments for the + constructor's signature. + + `nativeErrors` contains every Error constructor whose first argument + is a `message` string: %Error% and the six NativeErrors. + + `allErrorConstructors` additionally includes %AggregateError% and + %SuppressedError% when present in the host. Their constructors have + different signatures (`(errors, message)` and + `(error, suppressed, message)` respectively), so tests that just + iterate as `new Ctor(message)` should prefer `nativeErrors`; tests + that need to cover every Error-like constructor should use + `allErrorConstructors` together with `makeNativeError`. +defines: [nativeErrors, allErrorConstructors, makeNativeError] +---*/ + +var nativeErrors = [ + Error, + EvalError, + RangeError, + ReferenceError, + SyntaxError, + TypeError, + URIError +]; + +var allErrorConstructors = nativeErrors.slice(); +if (typeof AggregateError !== 'undefined') { + allErrorConstructors.push(AggregateError); +} +if (typeof SuppressedError !== 'undefined') { + allErrorConstructors.push(SuppressedError); +} + +function makeNativeError(Ctor, useNew) { + if (typeof AggregateError !== 'undefined' && Ctor === AggregateError) { + return useNew + ? new AggregateError([new Error('inner')], 'msg') + : AggregateError([new Error('inner')], 'msg'); + } + if (typeof SuppressedError !== 'undefined' && Ctor === SuppressedError) { + return useNew + ? new SuppressedError(new Error('inner'), new Error('suppressed'), 'msg') + : SuppressedError(new Error('inner'), new Error('suppressed'), 'msg'); + } + return useNew ? new Ctor('msg') : Ctor('msg'); +} diff --git a/third_party/test262/harness/propertyHelper.js b/third_party/test262/harness/propertyHelper.js index 51cc80c8808966..0acccfe87f0c40 100644 --- a/third_party/test262/harness/propertyHelper.js +++ b/third_party/test262/harness/propertyHelper.js @@ -7,6 +7,7 @@ description: | defines: - verifyProperty - verifyCallableProperty + - verifyAccessorProperty - verifyEqualTo # deprecated - verifyWritable # deprecated - verifyNotWritable # deprecated @@ -16,6 +17,7 @@ defines: - verifyNotConfigurable # deprecated - verifyPrimordialProperty - verifyPrimordialCallableProperty + - verifyPrimordialAccessorProperty ---*/ // @ts-check @@ -37,6 +39,7 @@ var nonIndexNumericPropertyName = Math.pow(2, 32) - 1; * @param {string|symbol} name * @param {PropertyDescriptor|undefined} desc * @param {object} [options] + * @param {boolean} [options.label] * @param {boolean} [options.restore] revert mutations from verifying writable/configurable */ function verifyProperty(obj, name, desc, options) { @@ -44,26 +47,23 @@ function verifyProperty(obj, name, desc, options) { arguments.length > 2, 'verifyProperty should receive at least 3 arguments: obj, name, and descriptor' ); + var label = options && options.label || String(name); var originalDesc = __getOwnPropertyDescriptor(obj, name); - var nameStr = String(name); // Allows checking for undefined descriptor if it's explicitly given. if (desc === undefined) { assert.sameValue( originalDesc, undefined, - "obj['" + nameStr + "'] descriptor should be undefined" + label + " descriptor should be undefined" ); // desc and originalDesc are both undefined, problem solved; return true; } - assert( - __hasOwnProperty(obj, name), - "obj should have an own property " + nameStr - ); + assert(__hasOwnProperty(obj, name), label + " should be an own property"); assert.notSameValue( desc, @@ -86,7 +86,7 @@ function verifyProperty(obj, name, desc, options) { names[i] === "configurable" || names[i] === "get" || names[i] === "set", - "Invalid descriptor field: " + names[i], + "Invalid descriptor field: " + names[i] ); } @@ -94,17 +94,17 @@ function verifyProperty(obj, name, desc, options) { if (__hasOwnProperty(desc, 'value')) { if (!isSameValue(desc.value, originalDesc.value)) { - __push(failures, "obj['" + nameStr + "'] descriptor value should be " + desc.value); + __push(failures, label + " descriptor value should be " + String(desc.value)); } if (!isSameValue(desc.value, obj[name])) { - __push(failures, "obj['" + nameStr + "'] value should be " + desc.value); + __push(failures, label + " value should be " + String(desc.value)); } } if (__hasOwnProperty(desc, 'enumerable') && desc.enumerable !== undefined) { if (desc.enumerable !== originalDesc.enumerable || desc.enumerable !== isEnumerable(obj, name)) { - __push(failures, "obj['" + nameStr + "'] descriptor should " + (desc.enumerable ? '' : 'not ') + "be enumerable"); + __push(failures, label + " descriptor should " + (desc.enumerable ? '' : 'not ') + "be enumerable"); } } @@ -113,14 +113,14 @@ function verifyProperty(obj, name, desc, options) { if (__hasOwnProperty(desc, 'writable') && desc.writable !== undefined) { if (desc.writable !== originalDesc.writable || desc.writable !== isWritable(obj, name)) { - __push(failures, "obj['" + nameStr + "'] descriptor should " + (desc.writable ? '' : 'not ') + "be writable"); + __push(failures, label + " descriptor should " + (desc.writable ? '' : 'not ') + "be writable"); } } if (__hasOwnProperty(desc, 'configurable') && desc.configurable !== undefined) { if (desc.configurable !== originalDesc.configurable || desc.configurable !== isConfigurable(obj, name)) { - __push(failures, "obj['" + nameStr + "'] descriptor should " + (desc.configurable ? '' : 'not ') + "be configurable"); + __push(failures, label + " descriptor should " + (desc.configurable ? '' : 'not ') + "be configurable"); } } @@ -219,13 +219,17 @@ function isWritable(obj, name, verifyProp, value) { * @param {number} functionLength * @param {PropertyDescriptor} [desc] defaults to data property conventions (writable, non-enumerable, configurable) * @param {object} [options] + * @param {boolean} [options.label] + * @param {typeof verifyProperty} [options.verifyProperty] * @param {boolean} [options.restore] revert mutations from verifying writable/configurable */ function verifyCallableProperty(obj, name, functionName, functionLength, desc, options) { - var value = obj[name]; + var label = options && options.label || String(name); + var propertyVerifier = options && options.verifyProperty || verifyProperty; + + var value = obj && obj[name]; - assert.sameValue(typeof value, "function", - "obj['" + String(name) + "'] descriptor should be a function"); + assert.sameValue(typeof value, "function", label + " should be a function"); // Every other data property described in clauses 19 through 28 and in // Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, @@ -242,7 +246,7 @@ function verifyCallableProperty(obj, name, functionName, functionLength, desc, o desc.value = value; } - verifyProperty(obj, name, desc, options); + propertyVerifier(obj, name, desc, options); if (functionName === undefined) { if (typeof name === "symbol") { @@ -256,24 +260,125 @@ function verifyCallableProperty(obj, name, functionName, functionLength, desc, o // [[Configurable]]: true }. // https://tc39.es/ecma262/multipage/ecmascript-standard-built-in-objects.html#sec-ecmascript-standard-built-in-objects // https://tc39.es/ecma262/multipage/ordinary-and-exotic-objects-behaviours.html#sec-setfunctionname - verifyProperty(value, "name", { + propertyVerifier(value, "name", { value: functionName, writable: false, enumerable: false, configurable: desc.configurable - }, options); + }, { label: label + " name", restore: options && options.restore }); // Unless otherwise specified, the "length" property of a built-in function // object has the attributes { [[Writable]]: false, [[Enumerable]]: false, // [[Configurable]]: true }. // https://tc39.es/ecma262/multipage/ecmascript-standard-built-in-objects.html#sec-ecmascript-standard-built-in-objects // https://tc39.es/ecma262/multipage/ordinary-and-exotic-objects-behaviours.html#sec-setfunctionlength - verifyProperty(value, "length", { + propertyVerifier(value, "length", { value: functionLength, writable: false, enumerable: false, configurable: desc.configurable - }, options); + }, { label: label + " length", restore: options && options.restore }); +} + +/** + * Verify that there is an accessor property associated with `obj[name]` and + * following the conventions for built-in objects. + * + * @param {object} obj + * @param {string|symbol} name + * @param {object} desc + * @param {boolean} [desc.enumerable] defaults to accessor property conventions (non-enumerable) + * @param {boolean} [desc.configurable] defaults to accessor property conventions (configurable) + * @param {undefined | Function | {name?: string|symbol, length?: number}} [desc.get] if an object, + * absent fields default to getter conventions (name derived from the property key with a "get " + * prefix, length 0) + * @param {undefined | Function | {name?: string|symbol, length?: number}} [desc.set] if an object, + * absent fields default to getter conventions (name derived from the property key with a "set " + * prefix, length 1) + * @param {object} [options] + * @param {boolean} [options.label] + * @param {typeof verifyProperty} [options.verifyProperty] + * @param {typeof verifyCallableProperty} [options.verifyCallableProperty] + * @param {boolean} [options.restore] revert mutations from verifying property attributes + */ +function verifyAccessorProperty(obj, name, desc, options) { + var checkGet = __hasOwnProperty(desc, "get"); + var checkSet = __hasOwnProperty(desc, "set"); + assert( + checkGet || checkSet, + 'verifyAccessorProperty requires at least one of "get" and "set"' + ); + var label = options && options.label || String(name); + var propertyVerifier = options && options.verifyProperty || verifyProperty; + var callabilityVerifier = options && options.verifyCallableProperty || verifyCallableProperty; + + var originalDesc = __getOwnPropertyDescriptor(obj, name); + + // Every built-in function object, including constructors, has a "name" + // property whose value is a String. Unless otherwise specified, this value is + // the name that is given to the function in this specification. Functions + // that are identified as anonymous functions use the empty String as the + // value of the "name" property. For functions that are specified as + // properties of objects, the name value is the property name string used to + // access the function. Functions that are specified as get or set accessor + // functions of built-in properties have "get" or "set" (respectively) passed + // to the prefix parameter when calling CreateBuiltinFunction. + // + // The value of the "name" property is explicitly specified for each built-in + // functions whose property key is a Symbol value. If such an explicitly + // specified value starts with the prefix "get " or "set " and the function + // for which it is specified is a get or set accessor function of a built-in + // property, the value without the prefix is passed to the name parameter, and + // the value "get" or "set" (respectively) is passed to the prefix parameter + // when calling CreateBuiltinFunction. + // https://tc39.es/ecma262/multipage/ecmascript-standard-built-in-objects.html + if (checkGet) { + var expectGetter = desc.get; + var getterLabel = label + " getter"; + if (expectGetter === undefined || typeof expectGetter === "function") { + assert.sameValue(originalDesc.get, expectGetter, getterLabel); + } else { + var getterName = expectGetter.name; + if (getterName === undefined) { + getterName = "get " + (typeof name === "symbol" ? "[" + name.description + "]" : name); + } + var getterLength = expectGetter.length !== undefined ? expectGetter.length : 0; + var getterOptions = { label: getterLabel }; + callabilityVerifier(originalDesc, "get", getterName, getterLength, {}, getterOptions); + } + } + if (checkSet) { + var expectSetter = desc.set; + var setterLabel = label + " setter"; + if (expectSetter === undefined || typeof expectSetter === "function") { + assert.sameValue(originalDesc.set, expectSetter, setterLabel); + } else { + var setterName = expectSetter.name; + if (setterName === undefined) { + setterName = "set " + (typeof name === "symbol" ? "[" + name.description + "]" : name); + } + var setterLength = expectSetter.length !== undefined ? expectSetter.length : 1; + var setterOptions = { label: setterLabel }; + callabilityVerifier(originalDesc, "set", setterName, setterLength, {}, setterOptions); + } + } + + // Every accessor property described in clauses 19 through 28 and in Annex B.2 + // has the attributes { [[Enumerable]]: false, [[Configurable]]: true } unless + // otherwise specified. + // https://tc39.es/ecma262/multipage/ecmascript-standard-built-in-objects.html + var resolvedDesc = { get: originalDesc.get, set: originalDesc.set }; + if (!__hasOwnProperty(desc, "enumerable")) { + resolvedDesc.enumerable = false; + } else if (desc.enumerable !== undefined) { + resolvedDesc.enumerable = desc.enumerable; + } + if (!__hasOwnProperty(desc, "configurable")) { + resolvedDesc.configurable = true; + } else if (desc.configurable !== undefined) { + resolvedDesc.configurable = desc.configurable; + } + propertyVerifier(obj, name, resolvedDesc, options); } /** @@ -367,5 +472,39 @@ var verifyPrimordialProperty = verifyProperty; * Use this function to verify the primordial function-valued properties. * For non-primordial functions, use verifyCallableProperty. * See: https://github.com/tc39/how-we-work/blob/main/terminology.md#primordial + * + * @type {typeof verifyCallableProperty} */ -var verifyPrimordialCallableProperty = verifyCallableProperty; +function verifyPrimordialCallableProperty(obj, name, functionName, functionLength, desc, options) { + var resolvedOptions = { + verifyProperty: options && options.verifyProperty !== undefined + ? options.verifyProperty + : verifyPrimordialProperty + }; + if (options && options.label !== undefined) resolvedOptions.label = options.label; + if (options && options.restore !== undefined) resolvedOptions.restore = options.restore; + + return verifyCallableProperty(obj, name, functionName, functionLength, desc, resolvedOptions); +} + +/** + * Use this function to verify the primordial accessor properties. + * For non-primordial functions, use verifyAccessorProperty. + * See: https://github.com/tc39/how-we-work/blob/main/terminology.md#primordial + * + * @type {typeof verifyAccessorProperty} + */ +function verifyPrimordialAccessorProperty(obj, name, desc, options) { + var resolvedOptions = { + verifyProperty: options && options.verifyProperty !== undefined + ? options.verifyProperty + : verifyPrimordialProperty, + verifyCallableProperty: options && options.verifyCallableProperty !== undefined + ? options.verifyCallableProperty + : verifyPrimordialCallableProperty + }; + if (options && options.label !== undefined) resolvedOptions.label = options.label; + if (options && options.restore !== undefined) resolvedOptions.restore = options.restore; + + return verifyAccessorProperty(obj, name, desc, resolvedOptions); +} diff --git a/third_party/test262/harness/proxyTrapsHelper.js b/third_party/test262/harness/proxyTrapsHelper.js index 3bd0256b07a338..5fa3501dcccbad 100644 --- a/third_party/test262/harness/proxyTrapsHelper.js +++ b/third_party/test262/harness/proxyTrapsHelper.js @@ -7,9 +7,10 @@ description: | defines: [allowProxyTraps] ---*/ -function allowProxyTraps(overrides) { +function allowProxyTraps(overrides, label) { + var prefix = typeof label === 'string' && label.length > 0 ? label + ': ' : ''; function throwTest262Error(msg) { - return function () { throw new Test262Error(msg); }; + return function () { Test262Error.thrower(prefix + msg); }; } if (!overrides) { overrides = {}; } return { diff --git a/third_party/test262/harness/sta.js b/third_party/test262/harness/sta.js index c95ed7a264c550..d291a94f462349 100644 --- a/third_party/test262/harness/sta.js +++ b/third_party/test262/harness/sta.js @@ -11,6 +11,7 @@ defines: [Test262Error, $DONOTEVALUATE] function Test262Error(message) { + if (!(this instanceof Test262Error)) return new Test262Error(message); this.message = message || ""; } diff --git a/third_party/test262/harness/temporalHelpers.js b/third_party/test262/harness/temporalHelpers.js index fb2d3a3fb910ad..7216cc551fc16b 100644 --- a/third_party/test262/harness/temporalHelpers.js +++ b/third_party/test262/harness/temporalHelpers.js @@ -113,6 +113,23 @@ var TemporalHelpers = { ], }, + + /** + * Apple's fork of ICU contains code for these calendars, but they are not yet + * allowed to be supported in AvailableCalendars. See + * https://github.com/tc39/ecma402/blob/main/meetings/notes-2025-12-04.md#datetimeformatconstructor-options-calendar-islamic-fallbackjs-should-allow-other-fallback-values-4677 + */ + NotYetSupportedCalendars: [ + "bangla", + "gujarati", + "kannada", + "marathi", + "odia", + "tamil", + "telugu", + "vikram", + ], + /* * Return the canonical era code. */ diff --git a/third_party/test262/harness/testTypedArray.js b/third_party/test262/harness/testTypedArray.js index e55e626213b945..a6418c2f70bf62 100644 --- a/third_party/test262/harness/testTypedArray.js +++ b/third_party/test262/harness/testTypedArray.js @@ -63,10 +63,6 @@ var allTypedArrayConstructors = typedArrayConstructors.concat(bigIntArrayConstru */ var TypedArray = Object.getPrototypeOf(Int8Array); -function isPrimitive(val) { - return !val || (typeof val !== "object" && typeof val !== "function"); -} - function makePassthrough(TA, primitiveOrIterable) { return primitiveOrIterable; } @@ -106,7 +102,7 @@ function makeArrayBuffer(TA, primitiveOrIterable) { return new TA(arr).buffer; } -var makeResizableArrayBuffer, makeGrownArrayBuffer, makeShrunkArrayBuffer; +var makeResizableArrayBuffer, makeGrownArrayBuffer, makeShrunkArrayBuffer, makeImmutableArrayBuffer; if (ArrayBuffer.prototype.resize) { var copyIntoArrayBuffer = function(destBuffer, srcBuffer) { var destView = new Uint8Array(destBuffer); @@ -156,6 +152,17 @@ if (ArrayBuffer.prototype.resize) { return shrunk; }; } +if (ArrayBuffer.prototype.transferToImmutable) { + makeImmutableArrayBuffer = function makeImmutableArrayBuffer(TA, primitiveOrIterable) { + if (isPrimitive(primitiveOrIterable)) { + var n = Number(primitiveOrIterable) * TA.BYTES_PER_ELEMENT; + if (!(n >= 0 && n < 9007199254740992)) return primitiveOrIterable; + return (new ArrayBuffer(n)).transferToImmutable(); + } + var mutable = makeArrayBuffer(TA, primitiveOrIterable); + return mutable.transferToImmutable(); + }; +} var typedArrayCtorArgFactories = [makePassthrough, makeArray, makeArrayLike]; if (makeIterable) typedArrayCtorArgFactories.push(makeIterable); @@ -163,9 +170,10 @@ typedArrayCtorArgFactories.push(makeArrayBuffer); if (makeResizableArrayBuffer) typedArrayCtorArgFactories.push(makeResizableArrayBuffer); if (makeGrownArrayBuffer) typedArrayCtorArgFactories.push(makeGrownArrayBuffer); if (makeShrunkArrayBuffer) typedArrayCtorArgFactories.push(makeShrunkArrayBuffer); +if (makeImmutableArrayBuffer) typedArrayCtorArgFactories.push(makeImmutableArrayBuffer); /** - * @typedef {"passthrough" | "arraylike" | "iterable" | "arraybuffer" | "resizable"} typedArrayArgFactoryFeature + * @typedef {"passthrough" | "arraylike" | "iterable" | "arraybuffer" | "resizable" | "immutable"} typedArrayArgFactoryFeature */ /** @@ -193,7 +201,8 @@ function ctorArgFactoryMatchesSome(argFactory, features) { argFactory === makeArrayBuffer || argFactory === makeResizableArrayBuffer || argFactory === makeGrownArrayBuffer || - argFactory === makeShrunkArrayBuffer + argFactory === makeShrunkArrayBuffer || + argFactory === makeImmutableArrayBuffer ) { return true; } @@ -207,6 +216,9 @@ function ctorArgFactoryMatchesSome(argFactory, features) { return true; } break; + case "immutable": + if (argFactory === makeImmutableArrayBuffer) return true; + break; default: throw Test262Error("unknown feature: " + features[i]); } @@ -321,9 +333,19 @@ var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Ui * * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. * @param {Array} selected - An optional Array with filtered typed arrays + * @param {typedArrayArgFactoryFeature[]} [includeArgFactories] - for selecting + * initial constructor argument factory functions, rather than starting with + * all argument factories + * @param {typedArrayArgFactoryFeature[]} [excludeArgFactories] - for excluding + * constructor argument factory functions, after an initial selection */ -function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { - testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors); +function testWithNonAtomicsFriendlyTypedArrayConstructors(f, includeArgFactories, excludeArgFactories) { + testWithAllTypedArrayConstructors( + f, + nonAtomicsFriendlyTypedArrayConstructors, + includeArgFactories, + excludeArgFactories + ); } /** @@ -331,16 +353,26 @@ function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { * * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. * @param {Array} selected - An optional Array with filtered typed arrays + * @param {typedArrayArgFactoryFeature[]} [includeArgFactories] - for selecting + * initial constructor argument factory functions, rather than starting with + * all argument factories + * @param {typedArrayArgFactoryFeature[]} [excludeArgFactories] - for excluding + * constructor argument factory functions, after an initial selection */ -function testWithAtomicsFriendlyTypedArrayConstructors(f) { - testWithTypedArrayConstructors(f, [ - Int32Array, - Int16Array, - Int8Array, - Uint32Array, - Uint16Array, - Uint8Array, - ]); +function testWithAtomicsFriendlyTypedArrayConstructors(f, includeArgFactories, excludeArgFactories) { + testWithAllTypedArrayConstructors( + f, + [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ], + includeArgFactories, + excludeArgFactories + ); } /** @@ -367,7 +399,7 @@ function testTypedArrayConversions(byteConversionValues, fn) { } fn(TA, value, exp, initial); }); - }); + }, null, ["passthrough"]); } /** diff --git a/third_party/test262/test/built-ins/ArrayBuffer/isView/arg-is-typedarray-buffer.js b/third_party/test262/test/built-ins/ArrayBuffer/isView/arg-is-typedarray-buffer.js index 8222634cc461de..884d43dbef345d 100644 --- a/third_party/test262/test/built-ins/ArrayBuffer/isView/arg-is-typedarray-buffer.js +++ b/third_party/test262/test/built-ins/ArrayBuffer/isView/arg-is-typedarray-buffer.js @@ -15,8 +15,8 @@ features: [TypedArray] includes: [testTypedArray.js] ---*/ -testWithTypedArrayConstructors(function(ctor) { - var sample = new ctor().buffer; +testWithAllTypedArrayConstructors(function(ctor, makeCtorArg) { + var sample = new ctor(makeCtorArg(0)).buffer; assert.sameValue(ArrayBuffer.isView(sample), false); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/isView/arg-is-typedarray-constructor.js b/third_party/test262/test/built-ins/ArrayBuffer/isView/arg-is-typedarray-constructor.js index edad6efeb7afab..f04ce6a05f6956 100644 --- a/third_party/test262/test/built-ins/ArrayBuffer/isView/arg-is-typedarray-constructor.js +++ b/third_party/test262/test/built-ins/ArrayBuffer/isView/arg-is-typedarray-constructor.js @@ -15,6 +15,6 @@ features: [TypedArray] includes: [testTypedArray.js] ---*/ -testWithTypedArrayConstructors(function(ctor) { +testWithAllTypedArrayConstructors(function(ctor) { assert.sameValue(ArrayBuffer.isView(ctor), false); }, null, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js b/third_party/test262/test/built-ins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js index 9c280b12397e15..4341f83421e0f4 100644 --- a/third_party/test262/test/built-ins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js +++ b/third_party/test262/test/built-ins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js @@ -15,10 +15,10 @@ features: [class, TypedArray] includes: [testTypedArray.js] ---*/ -testWithTypedArrayConstructors(function(ctor) { +testWithAllTypedArrayConstructors(function(ctor, makeCtorArg) { class TA extends ctor {} - var sample = new TA(); + var sample = new TA(makeCtorArg(0)); assert(ArrayBuffer.isView(sample)); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/isView/arg-is-typedarray.js b/third_party/test262/test/built-ins/ArrayBuffer/isView/arg-is-typedarray.js index 713d51f07e6549..4d6d1e6919063b 100644 --- a/third_party/test262/test/built-ins/ArrayBuffer/isView/arg-is-typedarray.js +++ b/third_party/test262/test/built-ins/ArrayBuffer/isView/arg-is-typedarray.js @@ -15,8 +15,8 @@ features: [TypedArray] includes: [testTypedArray.js] ---*/ -testWithTypedArrayConstructors(function(ctor) { - var sample = new ctor(); +testWithAllTypedArrayConstructors(function(ctor, makeCtorArg) { + var sample = new ctor(makeCtorArg(0)); assert.sameValue(ArrayBuffer.isView(sample), true); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/isView/invoked-as-a-fn.js b/third_party/test262/test/built-ins/ArrayBuffer/isView/invoked-as-a-fn.js index 4024087f045f1a..d8678e9b3889c3 100644 --- a/third_party/test262/test/built-ins/ArrayBuffer/isView/invoked-as-a-fn.js +++ b/third_party/test262/test/built-ins/ArrayBuffer/isView/invoked-as-a-fn.js @@ -17,10 +17,10 @@ includes: [testTypedArray.js] var isView = ArrayBuffer.isView; -testWithTypedArrayConstructors(function(ctor) { - var sample = new ctor(); +testWithAllTypedArrayConstructors(function(ctor, makeCtorArg) { + var sample = new ctor(makeCtorArg(0)); assert.sameValue(isView(sample), true, "instance of TypedArray"); -}, null, ["passthrough"]); +}); var dv = new DataView(new ArrayBuffer(1), 0, 0); assert.sameValue(isView(dv), true, "instance of DataView"); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/immutable/prop-desc.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/immutable/prop-desc.js new file mode 100644 index 00000000000000..dcdb5fb90c41ef --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/immutable/prop-desc.js @@ -0,0 +1,30 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-arraybuffer.prototype.immutable +description: Checks the "immutable" property of ArrayBuffer.prototype. +info: | + ArrayBuffer.prototype.immutable is an accessor property whose set accessor + function is undefined. + + ECMAScript Standard Built-in Objects + ... + For functions that are specified as properties of objects, the name value is + the property name string used to access the function. Functions that are + specified as get or set accessor functions of built-in properties have "get" + or "set" (respectively) passed to the prefix parameter when calling + CreateBuiltinFunction. + ... + Every accessor property described in clauses 19 through 28 and in Annex B.2 + has the attributes { [[Enumerable]]: false, [[Configurable]]: true } unless + otherwise specified. If only a get accessor function is described, the set + accessor function is the default value, undefined. +features: [immutable-arraybuffer] +includes: [propertyHelper.js] +---*/ + +verifyPrimordialAccessorProperty(ArrayBuffer.prototype, "immutable", { + get: { name: "get immutable", length: 0 }, + set: undefined, +}, { label: "ArrayBuffer.prototype.immutable" }); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/immutable/return-immutable.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/immutable/return-immutable.js new file mode 100644 index 00000000000000..04abdc0b534f90 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/immutable/return-immutable.js @@ -0,0 +1,28 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-arraybuffer.prototype.immutable +description: Return value according to the [[ArrayBufferIsImmutable]] internal slot. +info: | + get ArrayBuffer.prototype.immutable + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. + 4. Return IsImmutableBuffer(O). + + IsImmutableBuffer ( arrayBuffer ) + 1. If arrayBuffer has an [[ArrayBufferIsImmutable]] internal slot, return true. + 2. Return false. +features: [ArrayBuffer, immutable-arraybuffer] +includes: [detachArrayBuffer.js] +---*/ + +var ab = new ArrayBuffer(1); +assert.sameValue(ab.immutable, false); + +var iab = ab.transferToImmutable(); +assert.sameValue(iab.immutable, true); + +$DETACHBUFFER(ab); +assert.sameValue(ab.immutable, false); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/immutable/this-has-no-arraybufferdata-internal.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/immutable/this-has-no-arraybufferdata-internal.js new file mode 100644 index 00000000000000..e6d6d41844632d --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/immutable/this-has-no-arraybufferdata-internal.js @@ -0,0 +1,45 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-arraybuffer.prototype.immutable +description: > + Throws a TypeError exception when `this` does not have a [[ArrayBufferData]] + internal slot +info: | + get ArrayBuffer.prototype.immutable + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). +features: [DataView, Int8Array, ArrayBuffer, immutable-arraybuffer] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + ArrayBuffer.prototype, "immutable" +).get; + +assert.sameValue(typeof getter, "function", "Getter must exist."); + +var badReceivers = [ + ["plain object", {}], + ["array", []], + ["function", function(){}], + ["ArrayBuffer.prototype", ArrayBuffer.prototype], + ["TypedArray", new Int8Array(8)], + ["DataView", new DataView(new ArrayBuffer(8), 0)] +]; + +for (var i = 0; i < badReceivers.length; i++) { + var label = badReceivers[i][0]; + var value = badReceivers[i][1]; + assert.throws(TypeError, function() { + getter.call(value); + }, label); +} + +assert.throws(TypeError, function() { + ArrayBuffer.prototype.immutable; +}, "invoked as prototype property access"); + +assert.throws(TypeError, function() { + getter(); +}, "invoked as function"); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/immutable/this-is-not-object.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/immutable/this-is-not-object.js new file mode 100644 index 00000000000000..fbc7370e839afc --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/immutable/this-is-not-object.js @@ -0,0 +1,39 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-arraybuffer.prototype.immutable +description: Throws a TypeError exception when `this` is not an object +info: | + get ArrayBuffer.prototype.immutable + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). +features: [ArrayBuffer, immutable-arraybuffer] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + ArrayBuffer.prototype, "immutable" +).get; + +assert.sameValue(typeof getter, "function", "Getter must exist."); + +var badReceivers = [ + ["undefined", undefined], + ["null", null], + ["number", 42], + ["string", "1"], + ["true", true], + ["false", false], + typeof Symbol === "undefined" ? undefined : ["unique symbol", Symbol("s")], + typeof Symbol === "undefined" || !Symbol.for ? undefined : ["registered symbol", Symbol.for("s")], + typeof BigInt === "undefined" ? undefined : ["bigint", BigInt(1)] +]; + +for (var i = 0; i < badReceivers.length; i++) { + if (!badReceivers[i]) continue; + var label = badReceivers[i][0]; + var value = badReceivers[i][1]; + assert.throws(TypeError, function() { + getter.call(value); + }, label); +} diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/immutable/this-is-sharedarraybuffer.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/immutable/this-is-sharedarraybuffer.js new file mode 100644 index 00000000000000..44c33243eaccd9 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/immutable/this-is-sharedarraybuffer.js @@ -0,0 +1,24 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-arraybuffer.prototype.immutable +description: Throws a TypeError exception when `this` is a SharedArrayBuffer +info: | + get ArrayBuffer.prototype.immutable + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. +features: [SharedArrayBuffer, ArrayBuffer, immutable-arraybuffer] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + ArrayBuffer.prototype, "immutable" +).get; + +assert.sameValue(typeof getter, "function", "Getter must exist."); + +var sab = new SharedArrayBuffer(4); +assert.throws(TypeError, function() { + getter.call(sab); +}); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/argument-coercion.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/argument-coercion.js new file mode 100644 index 00000000000000..d860b4073ac25d --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/argument-coercion.js @@ -0,0 +1,373 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.slicetoimmutable +description: > + Requested start and end are coerced to integers and checked for validity, then + (if valid) an immutable ArrayBuffer with the correct length and contents is + returned +info: | + ArrayBuffer.prototype.sliceToImmutable ( start, end ) + ... + 5. Let len be O.[[ArrayBufferByteLength]]. + 6. Let bounds be ? ResolveBounds(len, start, end). + 7. Let first be bounds.[[From]]. + 8. Let final be bounds.[[To]]. + 9. Let newLen be max(final - first, 0). + ... + 12. Let fromBuf be O.[[ArrayBufferData]]. + 13. Let currentLen be O.[[ArrayBufferByteLength]]. + 14. If currentLen < final, throw a RangeError exception. + 15. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen). + 16. Return newBuffer. + + ResolveBounds ( len, start, end ) + 1. Let relativeStart be ? ToIntegerOrInfinity(start). + 2. If relativeStart = -∞, let from be 0. + 3. Else if relativeStart < 0, let from be max(len + relativeStart, 0). + 4. Else, let from be min(relativeStart, len). + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end). + 6. If relativeEnd = -∞, let to be 0. + 7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0). + 8. Else, let to be min(relativeEnd, len). + 9. Return the Record { [[From]]: from, [[To]]: to }. + + ToIntegerOrInfinity ( argument ) + 1. Let number be ? ToNumber(argument). + 2. If number is one of NaN, +0𝔽, or -0𝔽, return 0. + 3. If number is +∞𝔽, return +∞. + 4. If number is -∞𝔽, return -∞. + 5. Return truncate(ℝ(number)). +features: [immutable-arraybuffer] +includes: [compareArray.js] +---*/ + +var ab = new ArrayBuffer(8); +assert.sameValue(ab.sliceToImmutable().byteLength, 8, + "Must default to receiver byteLength."); +ab = new ArrayBuffer(8); +assert.sameValue(ab.sliceToImmutable(undefined, undefined).byteLength, 8, + "Must default (undefined, undefined) to receiver byteLength."); + +function make32ByteArrayBuffer() { + var ab = new ArrayBuffer(32); + var view = new Uint8Array(ab); + for (var i = 0; i < 8; i++) view[i] = i + 1; + return ab; +} + +var goodInputs = [ + // Unmodified non-negative integral numbers + [0, 0], + [1, 1], + [10, 10], + // Truncated non-negative integral numbers + [0.9, 0], + [1.9, 1], + [-0.9, 0], + // Negative integral numbers + [-1, -1], + [-1.9, -1], + [-2.9, -2], + // Coerced to integral numbers + [-0, 0], + [null, 0], + [false, 0], + [true, 1], + ["", 0], + ["8", 8], + ["+9", 9], + ["-9", -9], + ["10e0", 10], + ["+1.1E+1", 11], + ["+.12e2", 12], + ["130e-1", 13], + ["0b1110", 14], + ["0XF", 15], + ["0xf", 15], + ["0o20", 16], + // Coerced to NaN and mapped to 0 + [NaN, 0], + ["7up", 0], + ["1_0", 0], + ["0x00_ff", 0], + // Clamped + [-32, 0], + ["-32", 0], + [-Infinity, 0], + ["-Infinity", 0], + [33, 32], + ["33", 32], + [9007199254740992, 32], // Math.pow(2, 53) = 9007199254740992 + ["9007199254740992", 32], // Math.pow(2, 53) = 9007199254740992 + [Infinity, 32], + ["Infinity", 32] +]; + +for (var i = 0; i < goodInputs.length; i++) { + var rawStart = goodInputs[i][0]; + var intStart = goodInputs[i][1]; + for (var j = 0; j < goodInputs.length; j++) { + var rawEnd = goodInputs[j][0]; + var intEnd = goodInputs[j][1]; + var intLength = Math.max( + 0, + (intEnd >= 0 ? intEnd : 32 + intEnd) - (intStart >= 0 ? intStart : 32 + intStart) + ); + var source = make32ByteArrayBuffer(); + var expectContents = Array.from(new Uint8Array(source)).slice(rawStart, rawEnd); + var dest = source.sliceToImmutable(rawStart, rawEnd); + var label = "sliceToImmutable(" + formatSimpleValue(rawStart) + ", " + formatSimpleValue(rawEnd) + ")"; + assert.sameValue(dest.byteLength, intLength, label + ".byteLength"); + assert.compareArray(new Uint8Array(dest), expectContents, label + " contents"); + assert.sameValue(dest.immutable, true, label + ".immutable"); + } +} + +var whitespace = "\t\v\f\uFEFF\u3000\n\r\u2028\u2029"; +function pad(rawInput) { + if (typeof rawInput === "string") { + return { skip: false, string: whitespace + rawInput + whitespace }; + } else if (typeof rawInput === "number") { + return { + skip: false, + string: whitespace + (isNegativeZero(rawInput) ? "-0" : rawInput) + whitespace + }; + } + return { skip: true }; +} +for (var i = 0; i < goodInputs.length; i++) { + var rawStart = goodInputs[i][0]; + var intStart = goodInputs[i][1]; + var paddedStart = pad(rawStart); + if (paddedStart.skip) continue; + for (var j = 0; j < goodInputs.length; j++) { + var rawEnd = goodInputs[j][0]; + var intEnd = goodInputs[j][1]; + var paddedEnd = pad(rawEnd); + if (paddedEnd.skip) continue; + var intLength = Math.max( + 0, + (intEnd >= 0 ? intEnd : 32 + intEnd) - (intStart >= 0 ? intStart : 32 + intStart) + ); + var source = make32ByteArrayBuffer(); + var expectContents = Array.from(new Uint8Array(source)).slice(rawStart, rawEnd); + var dest = source.sliceToImmutable(paddedStart.string, paddedEnd.string); + var label = "sliceToImmutable(" + formatSimpleValue(paddedStart.string) + ", " + formatSimpleValue(paddedEnd.string) + ")"; + assert.sameValue(dest.byteLength, intLength, label + ".byteLength"); + assert.compareArray(new Uint8Array(dest), expectContents, label + " contents"); + assert.sameValue(dest.immutable, true, label + ".immutable"); + } +} + +for (var i = 0; i < goodInputs.length; i++) { + var rawStart = goodInputs[i][0]; + var intStart = goodInputs[i][1]; + for (var j = 0; j < goodInputs.length; j++) { + var rawEnd = goodInputs[j][0]; + var intEnd = goodInputs[j][1]; + var intLength = Math.max( + 0, + (intEnd >= 0 ? intEnd : 32 + intEnd) - (intStart >= 0 ? intStart : 32 + intStart) + ); + + var calls = []; + + var badStartValueOf = false; + var badStartToString = false; + var objStart = { + valueOf() { + calls.push("start.valueOf"); + return badStartValueOf ? {} : rawStart; + }, + toString() { + calls.push("start.toString"); + return badStartToString ? {} : rawStart; + } + }; + var badEndValueOf = false; + var badEndToString = false; + var objEnd = { + valueOf() { + calls.push("end.valueOf"); + return badEndValueOf ? {} : rawEnd; + }, + toString() { + calls.push("end.toString"); + return badEndToString ? {} : rawEnd; + } + }; + function reprArgs(startMethodName, endMethodName) { + var startRepr = "{ " + startMethodName + ": () => " + formatSimpleValue(rawStart) + " }"; + var endRepr = "{ " + endMethodName + ": () => " + formatSimpleValue(rawEnd) + " }"; + return "(" + startRepr + ", " + endRepr + ")"; + } + + var source = make32ByteArrayBuffer(); + var expectContents = Array.from(new Uint8Array(source)).slice(rawStart, rawEnd); + var dest = source.sliceToImmutable(objStart, objEnd); + assert.sameValue(dest.byteLength, intLength, + "sliceToImmutable" + reprArgs("valueOf", "valueOf") + ".byteLength"); + assert.compareArray(new Uint8Array(dest), expectContents, + "sliceToImmutable" + reprArgs("valueOf", "valueOf") + " contents"); + assert.sameValue(dest.immutable, true, + "sliceToImmutable" + reprArgs("valueOf", "valueOf") + ".immutable"); + assert.compareArray(calls, ["start.valueOf", "end.valueOf"], + "sliceToImmutable" + reprArgs("valueOf", "valueOf") + " calls"); + + badStartValueOf = true; + calls = []; + source = make32ByteArrayBuffer(); + dest = source.sliceToImmutable(objStart, objEnd); + assert.sameValue(dest.byteLength, intLength, + "sliceToImmutable" + reprArgs("toString", "valueOf") + ".byteLength"); + assert.compareArray(new Uint8Array(dest), expectContents, + "sliceToImmutable" + reprArgs("toString", "valueOf") + " contents"); + assert.sameValue(dest.immutable, true, + "sliceToImmutable" + reprArgs("toString", "valueOf") + ".immutable"); + assert.compareArray(calls, ["start.valueOf", "start.toString", "end.valueOf"], + "sliceToImmutable" + reprArgs("toString", "valueOf") + " calls"); + + badEndValueOf = true; + calls = []; + source = make32ByteArrayBuffer(); + dest = source.sliceToImmutable(objStart, objEnd); + assert.sameValue(dest.byteLength, intLength, + "sliceToImmutable" + reprArgs("toString", "toString") + ".byteLength"); + assert.compareArray(new Uint8Array(dest), expectContents, + "sliceToImmutable" + reprArgs("toString", "toString") + " contents"); + assert.sameValue(dest.immutable, true, + "sliceToImmutable" + reprArgs("toString", "toString") + ".immutable"); + assert.compareArray(calls, ["start.valueOf", "start.toString", "end.valueOf", "end.toString"], + "sliceToImmutable" + reprArgs("toString", "toString") + " calls"); + + badEndToString = true; + if (typeof Symbol === undefined || !Symbol.toPrimitive) continue; + calls = []; + objEnd[Symbol.toPrimitive] = function(hint) { + calls.push("end[Symbol.toPrimitive](" + hint + ")"); + return rawEnd; + }; + source = make32ByteArrayBuffer(); + dest = source.sliceToImmutable(objStart, objEnd); + assert.sameValue(dest.byteLength, intLength, + "sliceToImmutable" + reprArgs("toString", "[Symbol.toPrimitive]") + ".byteLength"); + assert.compareArray(new Uint8Array(dest), expectContents, + "sliceToImmutable" + reprArgs("toString", "[Symbol.toPrimitive]") + " contents"); + assert.sameValue(dest.immutable, true, + "sliceToImmutable" + reprArgs("toString", "[Symbol.toPrimitive]") + ".immutable"); + assert.compareArray( + calls, + ["start.valueOf", "start.toString", "end[Symbol.toPrimitive](number)"], + "sliceToImmutable" + reprArgs("toString", "[Symbol.toPrimitive]") + " calls" + ); + + badStartToString = true; + calls = []; + objStart[Symbol.toPrimitive] = function(hint) { + calls.push("start[Symbol.toPrimitive](" + hint + ")"); + return rawStart; + }; + source = make32ByteArrayBuffer(); + dest = source.sliceToImmutable(objStart, objEnd); + assert.sameValue(dest.byteLength, intLength, + "sliceToImmutable" + reprArgs("[Symbol.toPrimitive]", "[Symbol.toPrimitive]") + ".byteLength"); + assert.compareArray(new Uint8Array(dest), expectContents, + "sliceToImmutable" + reprArgs("[Symbol.toPrimitive]", "[Symbol.toPrimitive]") + " contents"); + assert.sameValue(dest.immutable, true, + "sliceToImmutable" + reprArgs("[Symbol.toPrimitive]", "[Symbol.toPrimitive]") + ".immutable"); + assert.compareArray( + calls, + ["start[Symbol.toPrimitive](number)", "end[Symbol.toPrimitive](number)"], + "sliceToImmutable" + reprArgs("[Symbol.toPrimitive]", "[Symbol.toPrimitive]") + " calls"); + } +} + +function CustomError() {} + +var badInputs = [ + // non-numbers + typeof Symbol === undefined ? undefined : [Symbol("1"), TypeError], + typeof Symbol === undefined || !Symbol.for ? undefined : [Symbol.for("1"), TypeError], + typeof BigInt === undefined ? undefined : [BigInt(1), TypeError], + // thrower + [ + { + valueOf() { + throw new CustomError(); + }, + toString() { + return "{ valueOf: throwError }"; + }, + }, + CustomError + ] +]; + +for (var i = 0; i < badInputs.length; i++) { + if (!badInputs[i]) continue; + var rawBad = badInputs[i][0]; + var expectedErr = badInputs[i][1]; + + var ab = make32ByteArrayBuffer(); + var rawGood = goodInputs[i % goodInputs.length][0]; + var calls = []; + var objGood = { + valueOf() { + calls.push("good.valueOf"); + return rawGood; + } + }; + assert.throws( + expectedErr, + function() { + ab.sliceToImmutable(rawBad, objGood); + }, + "sliceToImmutable(" + formatSimpleValue(rawBad) + ", { valueOf: () => " + formatSimpleValue(rawGood) + " })" + ); + assert.compareArray(calls, [], + "sliceToImmutable(" + formatSimpleValue(rawBad) + ", { valueOf: () => " + formatSimpleValue(rawGood) + " }) calls"); + + calls = []; + assert.throws( + expectedErr, + function() { + ab.sliceToImmutable(objGood, rawBad); + }, + "sliceToImmutable({ valueOf: () => " + formatSimpleValue(rawGood) + " }, " + formatSimpleValue(rawBad) + ")" + ); + assert.compareArray(calls, ["good.valueOf"], + "sliceToImmutable({ valueOf: () => " + formatSimpleValue(rawGood) + " }, " + formatSimpleValue(rawBad) + ") calls"); +} + +var calls = []; +var objBad = { + toString() { + calls.push("toString"); + return {}; + }, + valueOf() { + calls.push("valueOf"); + return {}; + } +}; +ab = make32ByteArrayBuffer(); +assert.throws(TypeError, function() { + ab.sliceToImmutable(objBad); +}, "sliceToImmutable(badOrdinaryToPrimitive)"); +assert.compareArray(calls, ["valueOf", "toString"], + "sliceToImmutable(badOrdinaryToPrimitive) calls"); +if (typeof Symbol !== undefined && Symbol.toPrimitive) { + calls = []; + objBad[Symbol.toPrimitive] = function(hint) { + calls.push("Symbol.toPrimitive(" + hint + ")"); + return {}; + }; + ab = make32ByteArrayBuffer(); + assert.throws(TypeError, function() { + ab.sliceToImmutable(objBad); + }, "sliceToImmutable(badExoticToPrimitive)"); + assert.compareArray(calls, ["Symbol.toPrimitive(number)"], + "sliceToImmutable(badExoticToPrimitive) calls"); +} diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/modify-source-after-return.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/modify-source-after-return.js new file mode 100644 index 00000000000000..0268158df47829 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/modify-source-after-return.js @@ -0,0 +1,37 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.slicetoimmutable +description: Unaffected by post-hoc manipulation of the source +info: | + ArrayBuffer.prototype.sliceToImmutable ( start, end ) + ... + 15. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen). + 16. Return newBuffer. +features: [immutable-arraybuffer] +includes: [compareArray.js, detachArrayBuffer.js] +---*/ + +var source = new ArrayBuffer(8, { maxByteLength: 8 }); +var view = new Uint8Array(source); +for (var i = 0; i < 8; i++) view[i] = i + 1; + +var dest = source.sliceToImmutable(); +var expectContents = [1, 2, 3, 4, 5, 6, 7, 8]; +var destView = new Uint8Array(dest); +assert.compareArray(destView, expectContents); + +view[0] = 86; +assert.compareArray(destView, expectContents, "after source overwrite"); +assert.compareArray(new Uint8Array(dest), expectContents, "new view after source overwrite"); + +if (source.resize) { + source.resize(4); + assert.compareArray(destView, expectContents, "after resize"); + assert.compareArray(new Uint8Array(dest), expectContents, "new view after resize"); +} + +$DETACHBUFFER(source); +assert.compareArray(destView, expectContents, "after detach"); +assert.compareArray(new Uint8Array(dest), expectContents, "new view after detach"); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/not-a-constructor.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/not-a-constructor.js new file mode 100644 index 00000000000000..8823ba52399555 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/not-a-constructor.js @@ -0,0 +1,23 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.slicetoimmutable +description: ArrayBuffer.prototype.sliceToImmutable is not a constructor function +info: | + ECMAScript Standard Built-in Objects + ... + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in the + description of a particular function. +features: [Reflect.construct, immutable-arraybuffer] +includes: [isConstructor.js] +---*/ + +assert(!isConstructor(ArrayBuffer.prototype.sliceToImmutable), + "ArrayBuffer.prototype.sliceToImmutable is not a constructor"); + +var arrayBuffer = new ArrayBuffer(8); +assert.throws(TypeError, function() { + new arrayBuffer.sliceToImmutable(); +}); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/prop-desc.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/prop-desc.js new file mode 100644 index 00000000000000..367f292436a1e1 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/prop-desc.js @@ -0,0 +1,27 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.slicetoimmutable +description: Checks the "sliceToImmutable" property of ArrayBuffer.prototype +info: | + ECMAScript Standard Built-in Objects + ... + Every built-in function object, including constructors, has a "length" + property whose value is a non-negative integral Number. Unless otherwise + specified, this value is the number of required parameters shown in the + subclause heading for the function description. Optional parameters and rest + parameters are not included in the parameter count. + ... + For functions that are specified as properties of objects, the name value is + the property name string used to access the function. +features: [immutable-arraybuffer] +includes: [propertyHelper.js] +---*/ + +verifyPrimordialCallableProperty( + ArrayBuffer.prototype, + "sliceToImmutable", + "sliceToImmutable", + 2 +); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-becomes-detached.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-becomes-detached.js new file mode 100644 index 00000000000000..bca411f04fa99c --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-becomes-detached.js @@ -0,0 +1,50 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.slicetoimmutable +description: Throws if receiver is detached by bounds resolution +info: | + ArrayBuffer.prototype.sliceToImmutable ( start, end ) + ... + 6. Let bounds be ? ResolveBounds(len, start, end). + ... + 10. NOTE: Side-effects of the above steps may have detached or resized O. + 11. If IsDetachedBuffer(O) is true, throw a TypeError exception. + + ResolveBounds ( len, start, end ) + 1. Let relativeStart be ? ToIntegerOrInfinity(start). + 2. If relativeStart = -∞, let from be 0. + 3. Else if relativeStart < 0, let from be max(len + relativeStart, 0). + 4. Else, let from be min(relativeStart, len). + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end). + 6. If relativeEnd = -∞, let to be 0. + 7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0). + 8. Else, let to be min(relativeEnd, len). + 9. Return the Record { [[From]]: from, [[To]]: to }. +features: [immutable-arraybuffer] +includes: [compareArray.js, detachArrayBuffer.js] +---*/ + +var fn = ArrayBuffer.prototype.sliceToImmutable; +assert.sameValue(typeof fn, "function", "Method must exist."); + +var ab = new ArrayBuffer(8); +var calls = []; +var objStart = { + valueOf() { + calls.push("start.valueOf"); + return 0; + } +}; +var objEnd = { + valueOf() { + $DETACHBUFFER(ab); + calls.push("end.valueOf"); + return 1; + } +}; +assert.throws(TypeError, function() { + ab.sliceToImmutable(objStart, objEnd); +}); +assert.compareArray(calls, ["start.valueOf", "end.valueOf"]); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-grows.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-grows.js new file mode 100644 index 00000000000000..11a412cb1fe156 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-grows.js @@ -0,0 +1,54 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.slicetoimmutable +description: Calculates bounds from original length if receiver grows. +info: | + ArrayBuffer.prototype.sliceToImmutable ( start, end ) + ... + 5. Let len be O.[[ArrayBufferByteLength]]. + 6. Let bounds be ? ResolveBounds(len, start, end). + 7. Let first be bounds.[[From]]. + 8. Let final be bounds.[[To]]. + 9. Let newLen be max(final - first, 0). + ... + 12. Let fromBuf be O.[[ArrayBufferData]]. + 13. Let currentLen be O.[[ArrayBufferByteLength]]. + 14. If currentLen < final, throw a RangeError exception. + 15. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen). + 16. Return newBuffer. + + ResolveBounds ( len, start, end ) + 1. Let relativeStart be ? ToIntegerOrInfinity(start). + 2. If relativeStart = -∞, let from be 0. + 3. Else if relativeStart < 0, let from be max(len + relativeStart, 0). + 4. Else, let from be min(relativeStart, len). + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end). + 6. If relativeEnd = -∞, let to be 0. + 7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0). + 8. Else, let to be min(relativeEnd, len). + 9. Return the Record { [[From]]: from, [[To]]: to }. +features: [resizable-arraybuffer, immutable-arraybuffer] +includes: [compareArray.js] +---*/ + +var source = new ArrayBuffer(10, { maxByteLength: 12 }); +var view = new Uint8Array(source); +for (var i = 0; i < 10; i++) view[i] = i + 1; + +var start = { + valueOf() { + source.resize(11); + return -7; + } +}; +var end = { + valueOf() { + source.resize(12); + return -4; + } +}; +var dest = source.sliceToImmutable(start, end); +assert.compareArray(new Uint8Array(dest), [4, 5, 6]); +assert.sameValue(source.byteLength, 12); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-has-no-arraybufferdata-internal.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-has-no-arraybufferdata-internal.js new file mode 100644 index 00000000000000..ef4a4fd252656c --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-has-no-arraybufferdata-internal.js @@ -0,0 +1,66 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.slicetoimmutable +description: > + Throws a TypeError exception when `this` does not have a [[ArrayBufferData]] + internal slot +info: | + ArrayBuffer.prototype.sliceToImmutable ( start, end ) + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). +features: [DataView, Int8Array, ArrayBuffer, immutable-arraybuffer] +includes: [compareArray.js] +---*/ + +var fn = ArrayBuffer.prototype.sliceToImmutable; +assert.sameValue(typeof fn, "function", "Method must exist."); + +var calls = []; +var start = { + valueOf() { + calls.push("start.valueOf"); + return 0; + } +}; +var end = { + valueOf() { + calls.push("end.valueOf"); + return 1; + } +}; + +var badReceivers = [ + ["plain object", {}], + ["array", []], + ["function", function(){}], + ["ArrayBuffer.prototype", ArrayBuffer.prototype], + ["TypedArray", new Int8Array(8)], + ["DataView", new DataView(new ArrayBuffer(8), 0)] +]; + +for (var i = 0; i < badReceivers.length; i++) { + var label = badReceivers[i][0]; + var value = badReceivers[i][1]; + calls = []; + assert.throws(TypeError, function() { + fn.call(value, start, end); + }, label); + assert.compareArray(calls, [], + "[" + label + " receiver] Must verify internal slots before reading arguments."); +} + +calls = []; +assert.throws(TypeError, function() { + ArrayBuffer.prototype.sliceToImmutable(start, end); +}, "invoked as prototype method"); +assert.compareArray(calls, [], + "[invoked as prototype method] Must verify internal slots before reading arguments."); + +calls = []; +assert.throws(TypeError, function() { + fn(start, end); +}, "invoked as function"); +assert.compareArray(calls, [], + "[invoked as function] Must verify internal slots before reading arguments."); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-is-not-detached.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-is-not-detached.js new file mode 100644 index 00000000000000..dc8435c1605228 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-is-not-detached.js @@ -0,0 +1,38 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.slicetoimmutable +description: > + Throws a TypeError exception when `this` is already detached +info: | + ArrayBuffer.prototype.sliceToImmutable ( start, end ) + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. +features: [immutable-arraybuffer] +includes: [compareArray.js, detachArrayBuffer.js] +---*/ + +var calls = []; +var start = { + valueOf() { + calls.push("start.valueOf"); + return 0; + } +}; +var end = { + valueOf() { + calls.push("end.valueOf"); + return 1; + } +}; + +var detached = new ArrayBuffer(8); +$DETACHBUFFER(detached); +assert.throws(TypeError, function() { + detached.sliceToImmutable(start, end); +}); +assert.compareArray(calls, [], + "Must verify non-detachment before reading arguments."); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-is-not-object.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-is-not-object.js new file mode 100644 index 00000000000000..c1727076cca514 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-is-not-object.js @@ -0,0 +1,53 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.slicetoimmutable +description: Throws a TypeError exception when `this` is not an object +info: | + ArrayBuffer.prototype.sliceToImmutable ( start, end ) + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). +features: [ArrayBuffer, immutable-arraybuffer] +includes: [compareArray.js] +---*/ + +var fn = ArrayBuffer.prototype.sliceToImmutable; +assert.sameValue(typeof fn, "function", "Method must exist."); + +var calls = []; +var start = { + valueOf() { + calls.push("start.valueOf"); + return 0; + } +}; +var end = { + valueOf() { + calls.push("end.valueOf"); + return 1; + } +}; + +var badReceivers = [ + ["undefined", undefined], + ["null", null], + ["number", 42], + ["string", "1"], + ["true", true], + ["false", false], + typeof Symbol === "undefined" ? undefined : ["unique symbol", Symbol("1")], + typeof Symbol === "undefined" || !Symbol.for ? undefined : ["registered symbol", Symbol.for("1")], + typeof BigInt === "undefined" ? undefined : ["bigint", BigInt(1)] +]; + +for (var i = 0; i < badReceivers.length; i++) { + var label = badReceivers[i][0]; + var value = badReceivers[i][1]; + calls = []; + assert.throws(TypeError, function() { + fn.call(value, start, end); + }, label); + assert.compareArray(calls, [], + "[" + label + " receiver] Must verify internal slots before reading arguments."); +} diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-is-sharedarraybuffer.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-is-sharedarraybuffer.js new file mode 100644 index 00000000000000..13b1e3cdfb71ea --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-is-sharedarraybuffer.js @@ -0,0 +1,38 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.slicetoimmutable +description: Throws a TypeError exception when `this` is a SharedArrayBuffer +info: | + ArrayBuffer.prototype.sliceToImmutable ( start, end ) + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. +features: [SharedArrayBuffer, ArrayBuffer, immutable-arraybuffer] +includes: [compareArray.js] +---*/ + +var fn = ArrayBuffer.prototype.sliceToImmutable; +assert.sameValue(typeof fn, "function", "Method must exist."); + +var calls = []; +var start = { + valueOf() { + calls.push("start.valueOf"); + return 0; + } +}; +var end = { + valueOf() { + calls.push("end.valueOf"); + return 1; + } +}; + +var sab = new SharedArrayBuffer(4); +assert.throws(TypeError, function() { + fn.call(sab, start, end); +}); +assert.compareArray(calls, [], + "Must verify non-SharedArrayBuffer receiver before reading arguments."); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-shrinks.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-shrinks.js new file mode 100644 index 00000000000000..98d7d4906bbfc3 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-shrinks.js @@ -0,0 +1,74 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.slicetoimmutable +description: Calculates bounds from original length if receiver shrinks. +info: | + ArrayBuffer.prototype.sliceToImmutable ( start, end ) + ... + 5. Let len be O.[[ArrayBufferByteLength]]. + 6. Let bounds be ? ResolveBounds(len, start, end). + 7. Let first be bounds.[[From]]. + 8. Let final be bounds.[[To]]. + 9. Let newLen be max(final - first, 0). + ... + 12. Let fromBuf be O.[[ArrayBufferData]]. + 13. Let currentLen be O.[[ArrayBufferByteLength]]. + 14. If currentLen < final, throw a RangeError exception. + 15. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newLen, fromBuf, first, newLen). + 16. Return newBuffer. + + ResolveBounds ( len, start, end ) + 1. Let relativeStart be ? ToIntegerOrInfinity(start). + 2. If relativeStart = -∞, let from be 0. + 3. Else if relativeStart < 0, let from be max(len + relativeStart, 0). + 4. Else, let from be min(relativeStart, len). + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end). + 6. If relativeEnd = -∞, let to be 0. + 7. Else if relativeEnd < 0, let to be max(len + relativeEnd, 0). + 8. Else, let to be min(relativeEnd, len). + 9. Return the Record { [[From]]: from, [[To]]: to }. +features: [resizable-arraybuffer, immutable-arraybuffer] +includes: [compareArray.js, detachArrayBuffer.js] +---*/ + +var source = new ArrayBuffer(10, { maxByteLength: 10 }); +var view = new Uint8Array(source); +for (var i = 0; i < 10; i++) view[i] = i + 1; + +var startResizeTo = 9; +var endResizeTo = 8; +var start = { + valueOf() { + source.resize(startResizeTo); + return -7; + } +}; +var end = { + valueOf() { + source.resize(endResizeTo); + return -4; + } +}; +var dest = source.sliceToImmutable(start, end); +assert.compareArray(new Uint8Array(dest), [4, 5, 6]); +assert.sameValue(source.byteLength, 8); + +source.resize(10); +endResizeTo = 5; +assert.throws(RangeError, function() { + source.sliceToImmutable(start, end); +}, "resize below resolved end"); + +source.resize(10); +end = { + valueOf() { + source.resize(5); + $DETACHBUFFER(source); + return 6; + } +}; +assert.throws(TypeError, function() { + source.sliceToImmutable(0, end); +}, "Must verify non-detachment before final bounds check"); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/new-length-coercion.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/new-length-coercion.js new file mode 100644 index 00000000000000..51d4c035017c62 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/new-length-coercion.js @@ -0,0 +1,254 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.transfertoimmutable +description: Requested length is coerced to an integer and checked for validity +info: | + ArrayBuffer.prototype.transferToImmutable ( [ newLength ] ) + 1. Let O be the this value. + 2. Return ? ArrayBufferCopyAndDetach(O, newLength, ~immutable~). + + ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability ) + 1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]). + 2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception. + 3. If newLength is undefined, then + a. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]]. + 4. Else, + a. Let newByteLength be ? ToIndex(newLength). + + ToIndex ( value ) + 1. Let integer be ? ToIntegerOrInfinity(value). + 2. If integer is not in the inclusive interval from 0 to 2**53 - 1, throw a RangeError exception. + 3. Return integer. + + ToIntegerOrInfinity ( argument ) + 1. Let number be ? ToNumber(argument). + 2. If number is one of NaN, +0𝔽, or -0𝔽, return 0. + 3. If number is +∞𝔽, return +∞. + 4. If number is -∞𝔽, return -∞. + 5. Return truncate(ℝ(number)). +features: [immutable-arraybuffer] +includes: [compareArray.js] +---*/ + +var ab = new ArrayBuffer(8); +assert.sameValue(ab.transferToImmutable().byteLength, 8, + "Must default to receiver byteLength."); +ab = new ArrayBuffer(8); +assert.sameValue(ab.transferToImmutable(undefined).byteLength, 8, + "Must default undefined to receiver byteLength."); + +var goodLengths = [ + // Unmodified integral numbers + [0, 0], + [1, 1], + [10, 10], + // Truncated integral numbers + [0.9, 0], + [1.9, 1], + [-0.9, 0], + // Coerced to integral numbers + [-0, 0], + [null, 0], + [false, 0], + [true, 1], + ["", 0], + ["8", 8], + ["+9", 9], + ["10e0", 10], + ["+1.1E+1", 11], + ["+.12e2", 12], + ["130e-1", 13], + ["0b1110", 14], + ["0XF", 15], + ["0xf", 15], + ["0o20", 16], + // Coerced to NaN and mapped to 0 + [NaN, 0], + ["7up", 0], + ["1_0", 0], + ["0x00_ff", 0] +]; + +for (var i = 0; i < goodLengths.length; i++) { + var rawLength = goodLengths[i][0]; + var intLength = goodLengths[i][1]; + var ab = new ArrayBuffer(8); + assert.sameValue(ab.transferToImmutable(rawLength).byteLength, intLength, + "transferToImmutable(" + formatSimpleValue(rawLength) + ").byteLength"); +} + +var whitespace = "\t\v\f\uFEFF\u3000\n\r\u2028\u2029"; +for (var i = 0; i < goodLengths.length; i++) { + var rawLength = goodLengths[i][0]; + var intLength = goodLengths[i][1]; + if (typeof rawLength === "number") { + rawLength = isNegativeZero(rawLength) ? "-0" : String(rawLength); + } else if (typeof rawLength !== "string") { + continue; + } + var paddedLength = whitespace + rawLength + whitespace; + var ab = new ArrayBuffer(8); + assert.sameValue(ab.transferToImmutable(paddedLength).byteLength, intLength, + "transferToImmutable(" + formatSimpleValue(paddedLength) + ").byteLength"); +} + +for (var i = 0; i < goodLengths.length; i++) { + var rawLength = goodLengths[i][0]; + var intLength = goodLengths[i][1]; + var calls = []; + var badValueOf = false; + var badToString = false; + var objLength = { + valueOf() { + calls.push("valueOf"); + return badValueOf ? {} : rawLength; + }, + toString() { + calls.push("toString"); + return badToString ? {} : rawLength; + } + }; + + var ab = new ArrayBuffer(8); + assert.sameValue(ab.transferToImmutable(objLength).byteLength, intLength, + "transferToImmutable({ valueOf: () => " + formatSimpleValue(rawLength) + " }).byteLength"); + assert.compareArray(calls, ["valueOf"], + "transferToImmutable({ valueOf: () => " + formatSimpleValue(rawLength) + " }) calls"); + + badValueOf = true; + calls = []; + ab = new ArrayBuffer(8); + assert.sameValue(ab.transferToImmutable(objLength).byteLength, intLength, + "transferToImmutable({ toString: () => " + formatSimpleValue(rawLength) + " }).byteLength"); + assert.compareArray(calls, ["valueOf", "toString"], + "transferToImmutable({ toString: () => " + formatSimpleValue(rawLength) + " }) calls"); + + badToString = true; + if (typeof Symbol === undefined || !Symbol.toPrimitive) continue; + calls = []; + objLength[Symbol.toPrimitive] = function(hint) { + calls.push("Symbol.toPrimitive(" + hint + ")"); + return rawLength; + }; + ab = new ArrayBuffer(8); + assert.sameValue(ab.transferToImmutable(objLength).byteLength, intLength, + "transferToImmutable({ [Symbol.toPrimitive]: () => " + formatSimpleValue(rawLength) + " }).byteLength"); + assert.compareArray(calls, ["Symbol.toPrimitive(number)"], + "transferToImmutable({ [Symbol.toPrimitive]: () => " + formatSimpleValue(rawLength) + " }) calls"); +} + +var badLengths = [ + // Out of range numbers + [-1, RangeError], + [9007199254740992, RangeError], // Math.pow(2, 53) = 9007199254740992 + [Infinity, RangeError], + [-Infinity, RangeError], + // non-numbers + typeof Symbol === undefined ? undefined : [Symbol("1"), TypeError], + typeof Symbol === undefined || !Symbol.for ? undefined : [Symbol.for("1"), TypeError], + typeof BigInt === undefined ? undefined : [BigInt(1), TypeError], +]; + +for (var i = 0; i < badLengths.length; i++) { + if (!badLengths[i]) continue; + var rawLength = badLengths[i][0]; + var expectedErr = badLengths[i][1]; + var ab = new ArrayBuffer(8); + assert.throws(expectedErr, function() { + ab.transferToImmutable(rawLength); + }, "transferToImmutable(" + formatSimpleValue(rawLength) + ")"); +} + +for (var i = 0; i < badLengths.length; i++) { + if (!badLengths[i]) continue; + var rawLength = badLengths[i][0]; + var expectedErr = badLengths[i][1]; + if (typeof rawLength !== "number") continue; + var paddedLength = whitespace + rawLength + whitespace; + var ab = new ArrayBuffer(8); + assert.throws(expectedErr, function() { + ab.transferToImmutable(paddedLength); + }, "transferToImmutable(" + formatSimpleValue(paddedLength) + ")"); +} + +for (var i = 0; i < badLengths.length; i++) { + if (!badLengths[i]) continue; + var rawLength = badLengths[i][0]; + var expectedErr = badLengths[i][1]; + var calls = []; + var badValueOf = false; + var badToString = false; + var objLength = { + valueOf() { + calls.push("valueOf"); + return badValueOf ? {} : rawLength; + }, + toString() { + calls.push("toString"); + return badToString ? {} : rawLength; + } + }; + + var ab = new ArrayBuffer(8); + assert.throws(expectedErr, function() { + ab.transferToImmutable(objLength); + }, "transferToImmutable({ valueOf: () => " + formatSimpleValue(rawLength) + " })"); + assert.compareArray(calls, ["valueOf"], + "transferToImmutable({ valueOf: () => " + formatSimpleValue(rawLength) + " }) calls"); + + badValueOf = true; + calls = []; + ab = new ArrayBuffer(8); + assert.throws(expectedErr, function() { + ab.transferToImmutable(objLength); + }, "transferToImmutable({ toString: () => " + formatSimpleValue(rawLength) + " })"); + assert.compareArray(calls, ["valueOf", "toString"], + "transferToImmutable({ toString: () => " + formatSimpleValue(rawLength) + " }) calls"); + + badToString = true; + if (typeof Symbol === undefined || !Symbol.toPrimitive) continue; + calls = []; + objLength[Symbol.toPrimitive] = function(hint) { + calls.push("Symbol.toPrimitive(" + hint + ")"); + return rawLength; + }; + ab = new ArrayBuffer(8); + assert.throws(expectedErr, function() { + ab.transferToImmutable(objLength); + }, "transferToImmutable({ [Symbol.toPrimitive]: () => " + formatSimpleValue(rawLength) + " })"); + assert.compareArray(calls, ["Symbol.toPrimitive(number)"], + "transferToImmutable({ [Symbol.toPrimitive]: () => " + formatSimpleValue(rawLength) + " }) calls"); +} + +var calls = []; +var objLength = { + toString() { + calls.push("toString"); + return {}; + }, + valueOf() { + calls.push("valueOf"); + return {}; + } +}; +ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + ab.transferToImmutable(objLength); +}, "transferToImmutable(badOrdinaryToPrimitive)"); +assert.compareArray(calls, ["valueOf", "toString"], + "transferToImmutable(badOrdinaryToPrimitive) calls"); +if (typeof Symbol !== undefined && Symbol.toPrimitive) { + calls = []; + objLength[Symbol.toPrimitive] = function(hint) { + calls.push("Symbol.toPrimitive(" + hint + ")"); + return {}; + }; + ab = new ArrayBuffer(8); + assert.throws(TypeError, function() { + ab.transferToImmutable(objLength); + }, "transferToImmutable(badExoticToPrimitive)"); + assert.compareArray(calls, ["Symbol.toPrimitive(number)"], + "transferToImmutable(badExoticToPrimitive) calls"); +} diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/not-a-constructor.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/not-a-constructor.js new file mode 100644 index 00000000000000..db701b0049faf8 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/not-a-constructor.js @@ -0,0 +1,23 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.transfertoimmutable +description: ArrayBuffer.prototype.transferToImmutable is not a constructor function +info: | + ECMAScript Standard Built-in Objects + ... + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in the + description of a particular function. +features: [Reflect.construct, immutable-arraybuffer] +includes: [isConstructor.js] +---*/ + +assert(!isConstructor(ArrayBuffer.prototype.transferToImmutable), + "ArrayBuffer.prototype.transferToImmutable is not a constructor"); + +var arrayBuffer = new ArrayBuffer(8); +assert.throws(TypeError, function() { + new arrayBuffer.transferToImmutable(); +}); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/prop-desc.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/prop-desc.js new file mode 100644 index 00000000000000..76dcb3fe4cfa53 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/prop-desc.js @@ -0,0 +1,27 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.transfertoimmutable +description: Checks the "transferToImmutable" property of ArrayBuffer.prototype +info: | + ECMAScript Standard Built-in Objects + ... + Every built-in function object, including constructors, has a "length" + property whose value is a non-negative integral Number. Unless otherwise + specified, this value is the number of required parameters shown in the + subclause heading for the function description. Optional parameters and rest + parameters are not included in the parameter count. + ... + For functions that are specified as properties of objects, the name value is + the property name string used to access the function. +features: [immutable-arraybuffer] +includes: [propertyHelper.js] +---*/ + +verifyPrimordialCallableProperty( + ArrayBuffer.prototype, + "transferToImmutable", + "transferToImmutable", + 0 +); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/this-has-no-arraybufferdata-internal.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/this-has-no-arraybufferdata-internal.js new file mode 100644 index 00000000000000..6d96c348a67808 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/this-has-no-arraybufferdata-internal.js @@ -0,0 +1,63 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.transfertoimmutable +description: > + Throws a TypeError exception when `this` does not have a [[ArrayBufferData]] + internal slot +info: | + ArrayBuffer.prototype.transferToImmutable ( [ newLength ] ) + 1. Let O be the this value. + 2. Return ? ArrayBufferCopyAndDetach(O, newLength, ~immutable~). + + ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability ) + 1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]). +features: [DataView, Int8Array, ArrayBuffer, immutable-arraybuffer] +includes: [compareArray.js] +---*/ + +var fn = ArrayBuffer.prototype.transferToImmutable; +assert.sameValue(typeof fn, "function", "Method must exist."); + +var calls = []; +var newLength = { + valueOf() { + calls.push("newLength.valueOf"); + return 1; + } +}; + +var badReceivers = [ + ["plain object", {}], + ["array", []], + ["function", function(){}], + ["ArrayBuffer.prototype", ArrayBuffer.prototype], + ["TypedArray", new Int8Array(8)], + ["DataView", new DataView(new ArrayBuffer(8), 0)] +]; + +for (var i = 0; i < badReceivers.length; i++) { + var label = badReceivers[i][0]; + var value = badReceivers[i][1]; + calls = []; + assert.throws(TypeError, function() { + fn.call(value, newLength); + }, label); + assert.compareArray(calls, [], + "[" + label + " receiver] Must verify internal slots before reading arguments."); +} + +calls = []; +assert.throws(TypeError, function() { + ArrayBuffer.prototype.transferToImmutable(newLength); +}, "invoked as prototype method"); +assert.compareArray(calls, [], + "[invoked as prototype method] Must verify internal slots before reading arguments."); + +calls = []; +assert.throws(TypeError, function() { + fn(newLength); +}, "invoked as function"); +assert.compareArray(calls, [], + "[invoked as function] Must verify internal slots before reading arguments."); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/this-is-not-detachable.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/this-is-not-detachable.js new file mode 100644 index 00000000000000..2dd1eefa81f620 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/this-is-not-detachable.js @@ -0,0 +1,66 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.transfertoimmutable +description: > + Throws a TypeError exception when `this` is already detached or immutable +info: | + ArrayBuffer.prototype.transferToImmutable ( [ newLength ] ) + 1. Let O be the this value. + 2. Return ? ArrayBufferCopyAndDetach(O, newLength, ~immutable~). + + ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability ) + 1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]). + 2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception. + 3. If newLength is undefined, then + a. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]]. + 4. Else, + a. Let newByteLength be ? ToIndex(newLength). + 5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception. + 6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception. +features: [immutable-arraybuffer] +includes: [compareArray.js, detachArrayBuffer.js] +---*/ + +var calls = []; +var newLength = { + valueOf() { + calls.push("newLength.valueOf"); + return 1; + } +}; + +var detached = new ArrayBuffer(8); +$DETACHBUFFER(detached); +var immutable = (new ArrayBuffer(8)).transferToImmutable(); + +var badReceivers = [ + ["detached ArrayBuffer", detached], + ["immutable ArrayBuffer", immutable] +]; + +for (var i = 0; i < badReceivers.length; i++) { + var label = badReceivers[i][0]; + var value = badReceivers[i][1]; + calls = []; + assert.throws(TypeError, function() { + value.transferToImmutable(newLength); + }, label); + assert.compareArray(calls, ["newLength.valueOf"], + "[" + label + "] Must read arguments before verifying detachability."); +} + +calls = []; +var becomesDetached = new ArrayBuffer(8); +assert.throws(TypeError, function() { + becomesDetached.transferToImmutable({ + valueOf() { + calls.push("newLength.valueOf"); + $DETACHBUFFER(becomesDetached); + return 1; + } + }); +}, "becomes detached"); +assert.compareArray(calls, ["newLength.valueOf"], + "[becomes detached] Must read arguments before verifying detachability."); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/this-is-not-object.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/this-is-not-object.js new file mode 100644 index 00000000000000..3a686ae4a7c7f6 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/this-is-not-object.js @@ -0,0 +1,50 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.transfertoimmutable +description: Throws a TypeError exception when `this` is not an object +info: | + ArrayBuffer.prototype.transferToImmutable ( [ newLength ] ) + 1. Let O be the this value. + 2. Return ? ArrayBufferCopyAndDetach(O, newLength, ~immutable~). + + ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability ) + 1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]). +features: [ArrayBuffer, immutable-arraybuffer] +includes: [compareArray.js] +---*/ + +var fn = ArrayBuffer.prototype.transferToImmutable; +assert.sameValue(typeof fn, "function", "Method must exist."); + +var calls = []; +var newLength = { + valueOf() { + calls.push("newLength.valueOf"); + return 1; + } +}; + +var badReceivers = [ + ["undefined", undefined], + ["null", null], + ["number", 42], + ["string", "1"], + ["true", true], + ["false", false], + typeof Symbol === "undefined" ? undefined : ["unique symbol", Symbol("1")], + typeof Symbol === "undefined" || !Symbol.for ? undefined : ["registered symbol", Symbol.for("1")], + typeof BigInt === "undefined" ? undefined : ["bigint", BigInt(1)] +]; + +for (var i = 0; i < badReceivers.length; i++) { + var label = badReceivers[i][0]; + var value = badReceivers[i][1]; + calls = []; + assert.throws(TypeError, function() { + fn.call(value, newLength); + }, label); + assert.compareArray(calls, [], + "[" + label + " receiver] Must verify internal slots before reading arguments."); +} diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/this-is-sharedarraybuffer.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/this-is-sharedarraybuffer.js new file mode 100644 index 00000000000000..53ab24c4789f61 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/this-is-sharedarraybuffer.js @@ -0,0 +1,34 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.transfertoimmutable +description: Throws a TypeError exception when `this` is a SharedArrayBuffer +info: | + ArrayBuffer.prototype.transferToImmutable ( [ newLength ] ) + 1. Let O be the this value. + 2. Return ? ArrayBufferCopyAndDetach(O, newLength, ~immutable~). + + ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability ) + 1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]). + 2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception. +features: [SharedArrayBuffer, ArrayBuffer, immutable-arraybuffer] +includes: [compareArray.js] +---*/ + +var fn = ArrayBuffer.prototype.transferToImmutable; +assert.sameValue(typeof fn, "function", "Method must exist."); + +var calls = []; + +var sab = new SharedArrayBuffer(4); +assert.throws(TypeError, function() { + fn.call(sab, { + valueOf() { + calls.push("newLength.valueOf"); + return 1; + } + }); +}); +assert.compareArray(calls, [], + "Must verify non-SharedArrayBuffer receiver before reading arguments."); diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/to-larger.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/to-larger.js new file mode 100644 index 00000000000000..a99cf7ca1b1454 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/to-larger.js @@ -0,0 +1,79 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.transfertoimmutable +description: > + `ab.transferToImmutable(largerByteLength)` detaches `ab` and returns an + immutable ArrayBuffer with contents equal to the concatenation of `ab` and + enough zeros to fill the specified length +info: | + ArrayBuffer.prototype.transferToImmutable ( [ newLength ] ) + 1. Let O be the this value. + 2. Return ? ArrayBufferCopyAndDetach(O, newLength, ~immutable~). + + ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability ) + 1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]). + 2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception. + 3. If newLength is undefined, then + a. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]]. + 4. Else, + a. Let newByteLength be ? ToIndex(newLength). + 5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception. + 6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception. + 7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception. + 8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]). + 9. If preserveResizability is immutable, then + a. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength). + 10. Else, ... + 11. Perform ! DetachArrayBuffer(arrayBuffer). +features: [Uint8Array, immutable-arraybuffer] +includes: [compareArray.js] +---*/ + +var byteLength = 4; +var newLengths = [5, 8, 9]; +var sourceMakers = [ + function fixed() { + return new ArrayBuffer(byteLength); + }, + ArrayBuffer.prototype.resize && function resizable() { + return new ArrayBuffer(byteLength, { maxByteLength: byteLength * 2 }); + }, + ArrayBuffer.prototype.resize && function shrunk() { + var ab = new ArrayBuffer(byteLength * 2, { maxByteLength: byteLength * 2 }); + ab.resize(byteLength); + return ab; + }, + ArrayBuffer.prototype.resize && function grown() { + var ab = new ArrayBuffer(byteLength / 2, { maxByteLength: byteLength }); + ab.resize(byteLength); + return ab; + } +]; + +for (var i = 0; i < sourceMakers.length; i++) { + if (!sourceMakers[i]) continue; + var name = sourceMakers[i].name; + for (var j = 0; j < newLengths.length; j++) { + var newLength = newLengths[j]; + var label = name + "(" + byteLength + ").transferToImmutable(" + newLength + ")"; + var source = sourceMakers[i](); + var sourceView = new Uint8Array(source); + var expectDestContents = new Array(newLength); + for (var k = 0; k < newLength; k++) { + if (k < byteLength) sourceView[k] = k + 1; + expectDestContents[k] = k < byteLength ? k + 1 : 0; + } + + var dest = source.transferToImmutable(newLength); + assert.sameValue(source.detached, true, label + " source detached"); + assert.sameValue(dest.immutable, true, label + " is immutable"); + assert.sameValue(dest.resizable, false, label + " is not resizable"); + assert.sameValue(dest.byteLength, newLength, label + " byteLength"); + assert.sameValue(dest.maxByteLength, newLength, label + " maxByteLength"); + + var destView = new Uint8Array(dest); + assert.compareArray(destView, expectDestContents, label + " contents"); + } +} diff --git a/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/to-same-or-smaller.js b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/to-same-or-smaller.js new file mode 100644 index 00000000000000..b0c7e444080484 --- /dev/null +++ b/third_party/test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/to-same-or-smaller.js @@ -0,0 +1,76 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer.prototype.transfertoimmutable +description: > + `ab.transferToImmutable(sameOrSmallerByteLength)` detaches `ab` and returns an + immutable ArrayBuffer with contents equal to the specified-length prefix of + `ab` +info: | + ArrayBuffer.prototype.transferToImmutable ( [ newLength ] ) + 1. Let O be the this value. + 2. Return ? ArrayBufferCopyAndDetach(O, newLength, ~immutable~). + + ArrayBufferCopyAndDetach ( arrayBuffer, newLength, preserveResizability ) + 1. Perform ? RequireInternalSlot(arrayBuffer, [[ArrayBufferData]]). + 2. If IsSharedArrayBuffer(arrayBuffer) is true, throw a TypeError exception. + 3. If newLength is undefined, then + a. Let newByteLength be arrayBuffer.[[ArrayBufferByteLength]]. + 4. Else, + a. Let newByteLength be ? ToIndex(newLength). + 5. If IsDetachedBuffer(arrayBuffer) is true, throw a TypeError exception. + 6. If IsImmutableBuffer(arrayBuffer) is true, throw a TypeError exception. + 7. If arrayBuffer.[[ArrayBufferDetachKey]] is not undefined, throw a TypeError exception. + 8. Let copyLength be min(newByteLength, arrayBuffer.[[ArrayBufferByteLength]]). + 9. If preserveResizability is immutable, then + a. Let newBuffer be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, newByteLength, arrayBuffer.[[ArrayBufferData]], 0, copyLength). + 10. Else, ... + 11. Perform ! DetachArrayBuffer(arrayBuffer). +features: [Uint8Array, immutable-arraybuffer] +includes: [compareArray.js] +---*/ + +var byteLength = 4; +var sourceMakers = [ + function fixed() { + return new ArrayBuffer(byteLength); + }, + ArrayBuffer.prototype.resize && function resizable() { + return new ArrayBuffer(byteLength, { maxByteLength: byteLength * 2 }); + }, + ArrayBuffer.prototype.resize && function shrunk() { + var ab = new ArrayBuffer(byteLength * 2, { maxByteLength: byteLength * 2 }); + ab.resize(byteLength); + return ab; + }, + ArrayBuffer.prototype.resize && function grown() { + var ab = new ArrayBuffer(byteLength / 2, { maxByteLength: byteLength }); + ab.resize(byteLength); + return ab; + } +]; + +for (var i = 0; i < sourceMakers.length; i++) { + if (!sourceMakers[i]) continue; + var name = sourceMakers[i].name; + for (var j = -1; j <= byteLength; j++) { + var newLength = j < 0 ? undefined : j; + var label = name + "(" + byteLength + ").transferToImmutable(" + newLength + ")"; + var source = sourceMakers[i](); + var sourceView = new Uint8Array(source); + for (var k = 0; k < byteLength; k++) sourceView[k] = k + 1; + var expectDestContents = sourceView.slice(0, newLength); + + var dest = source.transferToImmutable(newLength); + assert.sameValue(source.detached, true, label + " source detached"); + assert.sameValue(dest.immutable, true, label + " is immutable"); + assert.sameValue(dest.resizable, false, label + " is not resizable"); + var resolvedNewLength = newLength === undefined ? byteLength : newLength; + assert.sameValue(dest.byteLength, resolvedNewLength, label + " byteLength"); + assert.sameValue(dest.maxByteLength, resolvedNewLength, label + " maxByteLength"); + + var destView = new Uint8Array(dest); + assert.compareArray(destView, expectDestContents, label + " contents"); + } +} diff --git a/third_party/test262/test/built-ins/ArrayIteratorPrototype/next/detach-typedarray-in-progress.js b/third_party/test262/test/built-ins/ArrayIteratorPrototype/next/detach-typedarray-in-progress.js index da00362a77eb52..f0abf09b6f17f9 100644 --- a/third_party/test262/test/built-ins/ArrayIteratorPrototype/next/detach-typedarray-in-progress.js +++ b/third_party/test262/test/built-ins/ArrayIteratorPrototype/next/detach-typedarray-in-progress.js @@ -13,8 +13,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(TA => { - var typedArray = new TA(5); +testWithAllTypedArrayConstructors((TA, makeCtorArg) => { + var typedArray = new TA(makeCtorArg(5)); var i = 0; assert.throws(TypeError, () => { for (let key of typedArray.keys()) { @@ -23,4 +23,4 @@ testWithTypedArrayConstructors(TA => { } }); assert.sameValue(i, 1); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/add/bad-range.js b/third_party/test262/test/built-ins/Atomics/add/bad-range.js index e01d96c79147cf..76994f228d4cbe 100644 --- a/third_party/test262/test/built-ins/Atomics/add/bad-range.js +++ b/third_party/test262/test/built-ins/Atomics/add/bad-range.js @@ -19,4 +19,4 @@ testWithTypedArrayConstructors(function(TA) { Atomics.add(view, IdxGen(view), 10); }); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/add/bigint/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/add/bigint/non-shared-bufferdata.js index 1f989deda7300c..c0ed426b7af992 100644 --- a/third_party/test262/test/built-ins/Atomics/add/bigint/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/add/bigint/non-shared-bufferdata.js @@ -7,9 +7,9 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithBigIntTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.sameValue(Atomics.add(view, 0, 1n), 0n, 'Atomics.add(view, 0, 1n) returns 0n'); assert.sameValue(Atomics.load(view, 0), 1n, 'Atomics.load(view, 0) returns 1n'); -}, null, ["passthrough"]); +}, null, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/add/good-views.js b/third_party/test262/test/built-ins/Atomics/add/good-views.js index 95f60854d90eaa..a4cec394f2a986 100644 --- a/third_party/test262/test/built-ins/Atomics/add/good-views.js +++ b/third_party/test262/test/built-ins/Atomics/add/good-views.js @@ -51,4 +51,4 @@ testWithTypedArrayConstructors(function(TA) { Atomics.store(view, Idx, 37); assert.sameValue(Atomics.add(view, Idx, 0), 37, 'Atomics.add(view, Idx, 0) returns 37'); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/add/immutable-buffer.js b/third_party/test262/test/built-ins/Atomics/add/immutable-buffer.js new file mode 100644 index 00000000000000..deac3af56bbeb7 --- /dev/null +++ b/third_party/test262/test/built-ins/Atomics/add/immutable-buffer.js @@ -0,0 +1,52 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-atomics.add +description: > + Throws a TypeError exception when the backing buffer is immutable +info: | + Atomics.add ( typedArray, index, value ) + 1. Let add be a new read-modify-write modification function... + 2. Return ? AtomicReadModifyWrite(typedArray, index, value, add). + + AtomicReadModifyWrite ( typedArray, index, value, op ) + 1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, ~write~). + + ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] ) + 1. If waitable is not present, set waitable to false. + 2. If accessMode is not present, set accessMode to ~read~. + 3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode). + + ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to ~read~. + 2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode). + + ValidateTypedArray ( O, order [ , accessMode ] ) + ... + 4. If accessMode is ~write~ and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. +features: [Atomics, immutable-arraybuffer] +includes: [compareArray.js, testTypedArray.js] +---*/ + +testWithAllTypedArrayConstructors(function(TA, makeCtorArg) { + var calls = []; + var index = { + valueOf() { + calls.push("index.valueOf"); + return 0; + } + }; + var value = { + valueOf() { + calls.push("value.valueOf"); + return 1; + } + }; + + var ta = new TA(makeCtorArg(8)); + assert.throws(TypeError, function() { + Atomics.add(ta, index, value); + }); + assert.compareArray(calls, []); +}, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/add/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/add/non-shared-bufferdata.js index a326fa5f04ff50..ca82b20116fb55 100644 --- a/third_party/test262/test/built-ins/Atomics/add/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/add/non-shared-bufferdata.js @@ -8,11 +8,9 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithAtomicsFriendlyTypedArrayConstructors(TA => { - const view = new TA( - new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) - ); +testWithAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const view = new TA(makeCtorArg(4)); assert.sameValue(Atomics.add(view, 0, 1), 0, 'Atomics.add(view, 0, 1) returns 0'); assert.sameValue(Atomics.load(view, 0), 1, 'Atomics.load(view, 0) returns 1'); -}, null, ["passthrough"]); +}, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/add/non-shared-int-views-throws.js b/third_party/test262/test/built-ins/Atomics/add/non-shared-int-views-throws.js index 4b2958e70616f5..1a0e9a231b2aad 100644 --- a/third_party/test262/test/built-ins/Atomics/add/non-shared-int-views-throws.js +++ b/third_party/test262/test/built-ins/Atomics/add/non-shared-int-views-throws.js @@ -4,15 +4,15 @@ /*--- esid: sec-atomics.add description: > - Atomics.add throws when operating on non-sharable integer TypedArrays + Atomics.add throws when operating on incompatible TypedArrays includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithNonAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.throws(TypeError, function() { Atomics.add(view, 0, 1); }, `Atomics.add(new ${TA.name}(buffer), 0, 1) throws TypeError`); -}, null, ["passthrough"]); +}, ["arraybuffer"]); diff --git a/third_party/test262/test/built-ins/Atomics/and/bad-range.js b/third_party/test262/test/built-ins/Atomics/and/bad-range.js index 811e3941727020..291272363efc16 100644 --- a/third_party/test262/test/built-ins/Atomics/and/bad-range.js +++ b/third_party/test262/test/built-ins/Atomics/and/bad-range.js @@ -19,4 +19,4 @@ testWithTypedArrayConstructors(function(TA) { Atomics.and(view, IdxGen(view), 10); }); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/and/bigint/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/and/bigint/non-shared-bufferdata.js index df04c89602c619..c677e9cbcfa9d1 100644 --- a/third_party/test262/test/built-ins/Atomics/and/bigint/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/and/bigint/non-shared-bufferdata.js @@ -7,9 +7,9 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithBigIntTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.sameValue(Atomics.and(view, 0, 1n), 0n, 'Atomics.and(view, 0, 1n) returns 0n'); assert.sameValue(Atomics.load(view, 0), 0n, 'Atomics.load(view, 0) returns 0n'); -}, null, ["passthrough"]); +}, null, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/and/good-views.js b/third_party/test262/test/built-ins/Atomics/and/good-views.js index 59fbd736c4b45b..634e48b6a792c4 100644 --- a/third_party/test262/test/built-ins/Atomics/and/good-views.js +++ b/third_party/test262/test/built-ins/Atomics/and/good-views.js @@ -66,4 +66,4 @@ testWithTypedArrayConstructors(function(TA) { Atomics.store(view, Idx, 37); assert.sameValue(Atomics.and(view, Idx, 0), 37, 'Atomics.and(view, Idx, 0) returns 37'); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/and/immutable-buffer.js b/third_party/test262/test/built-ins/Atomics/and/immutable-buffer.js new file mode 100644 index 00000000000000..c674c0eaf38507 --- /dev/null +++ b/third_party/test262/test/built-ins/Atomics/and/immutable-buffer.js @@ -0,0 +1,52 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-atomics.and +description: > + Throws a TypeError exception when the backing buffer is immutable +info: | + Atomics.and ( typedArray, index, value ) + 1. Let and be a new read-modify-write modification function... + 2. Return ? AtomicReadModifyWrite(typedArray, index, value, and). + + AtomicReadModifyWrite ( typedArray, index, value, op ) + 1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, ~write~). + + ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] ) + 1. If waitable is not present, set waitable to false. + 2. If accessMode is not present, set accessMode to ~read~. + 3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode). + + ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to ~read~. + 2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode). + + ValidateTypedArray ( O, order [ , accessMode ] ) + ... + 4. If accessMode is ~write~ and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. +features: [Atomics, immutable-arraybuffer] +includes: [compareArray.js, testTypedArray.js] +---*/ + +testWithAllTypedArrayConstructors(function(TA, makeCtorArg) { + var calls = []; + var index = { + valueOf() { + calls.push("index.valueOf"); + return 0; + } + }; + var value = { + valueOf() { + calls.push("value.valueOf"); + return 1; + } + }; + + var ta = new TA(makeCtorArg(8)); + assert.throws(TypeError, function() { + Atomics.and(ta, index, value); + }); + assert.compareArray(calls, []); +}, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/and/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/and/non-shared-bufferdata.js index a734a08b393ecf..12fcd57a3dcd14 100644 --- a/third_party/test262/test/built-ins/Atomics/and/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/and/non-shared-bufferdata.js @@ -8,11 +8,9 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithAtomicsFriendlyTypedArrayConstructors(TA => { - const view = new TA( - new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) - ); +testWithAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const view = new TA(makeCtorArg(4)); assert.sameValue(Atomics.and(view, 0, 1), 0, 'Atomics.and(view, 0, 1) returns 0'); assert.sameValue(Atomics.load(view, 0), 0, 'Atomics.load(view, 0) returns 0'); -}, null, ["passthrough"]); +}, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/and/non-shared-int-views-throws.js b/third_party/test262/test/built-ins/Atomics/and/non-shared-int-views-throws.js index eb655928afb315..74d7d21858c6d7 100644 --- a/third_party/test262/test/built-ins/Atomics/and/non-shared-int-views-throws.js +++ b/third_party/test262/test/built-ins/Atomics/and/non-shared-int-views-throws.js @@ -4,15 +4,15 @@ /*--- esid: sec-atomics.and description: > - Atomics.and throws when operating on non-sharable integer TypedArrays + Atomics.and throws when operating on incompatible TypedArrays includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithNonAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.throws(TypeError, function() { Atomics.and(view, 0, 1); }, `Atomics.and(new ${TA.name}(buffer), 0, 1) throws TypeError`); -}, null, ["passthrough"]); +}, ["arraybuffer"]); diff --git a/third_party/test262/test/built-ins/Atomics/compareExchange/bad-range.js b/third_party/test262/test/built-ins/Atomics/compareExchange/bad-range.js index 7fbd13a384e4fe..b3d0819fc0cf57 100644 --- a/third_party/test262/test/built-ins/Atomics/compareExchange/bad-range.js +++ b/third_party/test262/test/built-ins/Atomics/compareExchange/bad-range.js @@ -19,4 +19,4 @@ testWithTypedArrayConstructors(function(TA) { Atomics.compareExchange(view, IdxGen(view), 10, 0); }); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/compareExchange/bigint/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/compareExchange/bigint/non-shared-bufferdata.js index 93b060bfabf234..3322221da8c552 100644 --- a/third_party/test262/test/built-ins/Atomics/compareExchange/bigint/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/compareExchange/bigint/non-shared-bufferdata.js @@ -7,9 +7,9 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithBigIntTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.sameValue(Atomics.compareExchange(view, 0, 0n, 1n), 0n, 'Atomics.compareExchange(view, 0, 0n, 1n) returns 0n'); assert.sameValue(Atomics.load(view, 0), 1n, 'Atomics.load(view, 0) returns 1n'); -}, null, ["passthrough"]); +}, null, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/compareExchange/good-views.js b/third_party/test262/test/built-ins/Atomics/compareExchange/good-views.js index 99a55768041aee..03e7c0220e7f2c 100644 --- a/third_party/test262/test/built-ins/Atomics/compareExchange/good-views.js +++ b/third_party/test262/test/built-ins/Atomics/compareExchange/good-views.js @@ -71,4 +71,4 @@ testWithTypedArrayConstructors(function(TA) { 'Atomics.compareExchange(view, Idx, 37, 0) returns 37' ); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/compareExchange/immutable-buffer.js b/third_party/test262/test/built-ins/Atomics/compareExchange/immutable-buffer.js new file mode 100644 index 00000000000000..41bc1624d30ea8 --- /dev/null +++ b/third_party/test262/test/built-ins/Atomics/compareExchange/immutable-buffer.js @@ -0,0 +1,54 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-atomics.compareexchange +description: > + Throws a TypeError exception when the backing buffer is immutable +info: | + Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue ) + 1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, ~write~). + + ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] ) + 1. If waitable is not present, set waitable to false. + 2. If accessMode is not present, set accessMode to ~read~. + 3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode). + + ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to ~read~. + 2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode). + + ValidateTypedArray ( O, order [ , accessMode ] ) + ... + 4. If accessMode is ~write~ and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. +features: [Atomics, immutable-arraybuffer] +includes: [compareArray.js, testTypedArray.js] +---*/ + +testWithAllTypedArrayConstructors(function(TA, makeCtorArg) { + var calls = []; + var index = { + valueOf() { + calls.push("index.valueOf"); + return 0; + } + }; + var expectedValue = { + valueOf() { + calls.push("expectedValue.valueOf"); + return 0; + } + }; + var replacementValue = { + valueOf() { + calls.push("replacementValue.valueOf"); + return 1; + } + }; + + var ta = new TA(makeCtorArg(8)); + assert.throws(TypeError, function() { + Atomics.compareExchange(ta, index, expectedValue, replacementValue); + }); + assert.compareArray(calls, []); +}, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/compareExchange/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/compareExchange/non-shared-bufferdata.js index 57d00a34598bb0..e808423814e096 100644 --- a/third_party/test262/test/built-ins/Atomics/compareExchange/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/compareExchange/non-shared-bufferdata.js @@ -8,11 +8,9 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithAtomicsFriendlyTypedArrayConstructors(TA => { - const view = new TA( - new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) - ); +testWithAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const view = new TA(makeCtorArg(4)); assert.sameValue(Atomics.compareExchange(view, 0, 0, 1), 0, 'Atomics.compareExchange(view, 0, 0, 1) returns 0'); assert.sameValue(Atomics.load(view, 0), 1, 'Atomics.load(view, 0) returns 1'); -}, null, ["passthrough"]); +}, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/compareExchange/non-shared-int-views-throws.js b/third_party/test262/test/built-ins/Atomics/compareExchange/non-shared-int-views-throws.js index 3a4e907946dc9e..3ef0e4b61260ce 100644 --- a/third_party/test262/test/built-ins/Atomics/compareExchange/non-shared-int-views-throws.js +++ b/third_party/test262/test/built-ins/Atomics/compareExchange/non-shared-int-views-throws.js @@ -4,15 +4,15 @@ /*--- esid: sec-atomics.compareexchange description: > - Atomics.compareExchange throws when operating on non-sharable integer TypedArrays + Atomics.compareExchange throws when operating on incompatible TypedArrays includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithNonAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.throws(TypeError, function() { Atomics.compareExchange(view, 0, 0, 0); }, `Atomics.compareExchange(new ${TA.name}(buffer), 0, 0, 0) throws TypeError`); -}, null, ["passthrough"]); +}, ["arraybuffer"]); diff --git a/third_party/test262/test/built-ins/Atomics/exchange/bad-range.js b/third_party/test262/test/built-ins/Atomics/exchange/bad-range.js index a7f47b0bf253d3..4f1e7b88539575 100644 --- a/third_party/test262/test/built-ins/Atomics/exchange/bad-range.js +++ b/third_party/test262/test/built-ins/Atomics/exchange/bad-range.js @@ -19,4 +19,4 @@ testWithTypedArrayConstructors(function(TA) { Atomics.exchange(view, IdxGen(view), 10, 0); }); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/exchange/bigint/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/exchange/bigint/non-shared-bufferdata.js index be94a42a77d98e..1257b4e8828bf4 100644 --- a/third_party/test262/test/built-ins/Atomics/exchange/bigint/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/exchange/bigint/non-shared-bufferdata.js @@ -7,9 +7,9 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithBigIntTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.sameValue(Atomics.exchange(view, 0, 1n), 0n, 'Atomics.exchange(view, 0, 1n) returns 0n'); assert.sameValue(Atomics.load(view, 0), 1n, 'Atomics.load(view, 0) returns 1n'); -}, null, ["passthrough"]); +}, null, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/exchange/good-views.js b/third_party/test262/test/built-ins/Atomics/exchange/good-views.js index 90b635d893baee..9a3783b1adc195 100644 --- a/third_party/test262/test/built-ins/Atomics/exchange/good-views.js +++ b/third_party/test262/test/built-ins/Atomics/exchange/good-views.js @@ -52,4 +52,4 @@ testWithTypedArrayConstructors(function(TA) { Atomics.store(view, Idx, 37); assert.sameValue(Atomics.exchange(view, Idx, 0), 37, 'Atomics.exchange(view, Idx, 0) returns 37'); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/exchange/immutable-buffer.js b/third_party/test262/test/built-ins/Atomics/exchange/immutable-buffer.js new file mode 100644 index 00000000000000..77a6cd75fa6636 --- /dev/null +++ b/third_party/test262/test/built-ins/Atomics/exchange/immutable-buffer.js @@ -0,0 +1,52 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-atomics.exchange +description: > + Throws a TypeError exception when the backing buffer is immutable +info: | + Atomics.exchange ( typedArray, index, value ) + 1. Let second be a new read-modify-write modification function... + 2. Return ? AtomicReadModifyWrite(typedArray, index, value, second). + + AtomicReadModifyWrite ( typedArray, index, value, op ) + 1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, ~write~). + + ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] ) + 1. If waitable is not present, set waitable to false. + 2. If accessMode is not present, set accessMode to ~read~. + 3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode). + + ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to ~read~. + 2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode). + + ValidateTypedArray ( O, order [ , accessMode ] ) + ... + 4. If accessMode is ~write~ and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. +features: [Atomics, immutable-arraybuffer] +includes: [compareArray.js, testTypedArray.js] +---*/ + +testWithAllTypedArrayConstructors(function(TA, makeCtorArg) { + var calls = []; + var index = { + valueOf() { + calls.push("index.valueOf"); + return 0; + } + }; + var value = { + valueOf() { + calls.push("value.valueOf"); + return 1; + } + }; + + var ta = new TA(makeCtorArg(8)); + assert.throws(TypeError, function() { + Atomics.exchange(ta, index, value); + }); + assert.compareArray(calls, []); +}, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/exchange/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/exchange/non-shared-bufferdata.js index 6fdb39decfb2ee..de36d4fd17e57d 100644 --- a/third_party/test262/test/built-ins/Atomics/exchange/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/exchange/non-shared-bufferdata.js @@ -8,11 +8,9 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithAtomicsFriendlyTypedArrayConstructors(TA => { - const view = new TA( - new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) - ); +testWithAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const view = new TA(makeCtorArg(4)); assert.sameValue(Atomics.exchange(view, 0, 1), 0, 'Atomics.exchange(view, 0, 1) returns 0'); assert.sameValue(Atomics.load(view, 0), 1, 'Atomics.load(view, 0) returns 1'); -}, null, ["passthrough"]); +}, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/exchange/non-shared-int-views-throws.js b/third_party/test262/test/built-ins/Atomics/exchange/non-shared-int-views-throws.js index c179d828abb9fd..5e4bc4447d979b 100644 --- a/third_party/test262/test/built-ins/Atomics/exchange/non-shared-int-views-throws.js +++ b/third_party/test262/test/built-ins/Atomics/exchange/non-shared-int-views-throws.js @@ -4,14 +4,14 @@ /*--- esid: sec-atomics.exchange description: > - Atomics.exchange throws when operating on non-sharable integer TypedArrays + Atomics.exchange throws when operating on incompatible TypedArrays includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithNonAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.throws(TypeError, function() { Atomics.exchange(view, 0, 1); }, `Atomics.exchange(new ${TA.name}(buffer), 0, 1) throws TypeError`); -}, null, ["passthrough"]); +}, ["arraybuffer"]); diff --git a/third_party/test262/test/built-ins/Atomics/exchange/nonshared-int-views.js b/third_party/test262/test/built-ins/Atomics/exchange/nonshared-int-views.js deleted file mode 100644 index b57c7634cdeefb..00000000000000 --- a/third_party/test262/test/built-ins/Atomics/exchange/nonshared-int-views.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2017 Mozilla Corporation. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-atomics.exchange -description: > - Atomics.exchange throws when operating on non-sharable integer TypedArrays -includes: [testTypedArray.js] -features: [ArrayBuffer, Atomics, TypedArray] ----*/ - -testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); - const view = new TA(buffer); - - assert.throws(TypeError, function() { - Atomics.exchange(view, 0, 0); - }, `Atomics.exchange(new ${TA.name}(buffer), 0, 0) throws TypeError`); -}, null, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/isLockFree/bigint/expected-return-value.js b/third_party/test262/test/built-ins/Atomics/isLockFree/bigint/expected-return-value.js index 3388924cf10ae1..3a2f7cbc8d20da 100644 --- a/third_party/test262/test/built-ins/Atomics/isLockFree/bigint/expected-return-value.js +++ b/third_party/test262/test/built-ins/Atomics/isLockFree/bigint/expected-return-value.js @@ -31,5 +31,3 @@ testWithBigIntTypedArrayConstructors(function(TA) { 'Atomics.isLockFree(TA.BYTES_PER_ELEMENT) returns the value of `observed` (Atomics.isLockFree(TA.BYTES_PER_ELEMENT))' ); }, null, ["passthrough"]); - - diff --git a/third_party/test262/test/built-ins/Atomics/load/bad-range.js b/third_party/test262/test/built-ins/Atomics/load/bad-range.js index 3a3fecbf7a4627..5c2e37c8067a6f 100644 --- a/third_party/test262/test/built-ins/Atomics/load/bad-range.js +++ b/third_party/test262/test/built-ins/Atomics/load/bad-range.js @@ -19,4 +19,4 @@ testWithTypedArrayConstructors(function(TA) { Atomics.load(view, IdxGen(view)); }); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/load/bigint/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/load/bigint/non-shared-bufferdata.js index d5df77554c5112..08d782a91380fb 100644 --- a/third_party/test262/test/built-ins/Atomics/load/bigint/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/load/bigint/non-shared-bufferdata.js @@ -7,8 +7,8 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithBigIntTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.sameValue(Atomics.load(view, 0), 0n, 'Atomics.load(view, 0) returns 0n'); -}, null, ["passthrough"]); +}, null, ["arraybuffer"]); diff --git a/third_party/test262/test/built-ins/Atomics/load/good-views.js b/third_party/test262/test/built-ins/Atomics/load/good-views.js index 69b3d281300274..5615801dcff7ad 100644 --- a/third_party/test262/test/built-ins/Atomics/load/good-views.js +++ b/third_party/test262/test/built-ins/Atomics/load/good-views.js @@ -43,4 +43,4 @@ testWithTypedArrayConstructors(function(TA) { Atomics.store(view, Idx, 37); assert.sameValue(Atomics.load(view, Idx), 37, 'Atomics.load(view, Idx) returns 37'); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/load/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/load/non-shared-bufferdata.js index 51f485ee221ef9..e15e6605785978 100644 --- a/third_party/test262/test/built-ins/Atomics/load/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/load/non-shared-bufferdata.js @@ -8,10 +8,8 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithAtomicsFriendlyTypedArrayConstructors(TA => { - const view = new TA( - new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) - ); +testWithAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const view = new TA(makeCtorArg(4)); assert.sameValue(Atomics.load(view, 0), 0, 'Atomics.load(view, 0) returns 0'); -}, null, ["passthrough"]); +}, null, ["arraybuffer"]); diff --git a/third_party/test262/test/built-ins/Atomics/load/non-shared-int-views-throws.js b/third_party/test262/test/built-ins/Atomics/load/non-shared-int-views-throws.js index 1277efb684f55c..02437f7ba5ca1d 100644 --- a/third_party/test262/test/built-ins/Atomics/load/non-shared-int-views-throws.js +++ b/third_party/test262/test/built-ins/Atomics/load/non-shared-int-views-throws.js @@ -4,14 +4,14 @@ /*--- esid: sec-atomics.load description: > - Atomics.load throws when operating on non-sharable integer TypedArrays + Atomics.load throws when operating on incompatible TypedArrays includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithNonAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.throws(TypeError, function() { Atomics.load(view, 0); }, `Atomics.load(new ${TA.name}(buffer), 0) throws TypeError`); -}, null, ["passthrough"]); +}, ["arraybuffer"]); diff --git a/third_party/test262/test/built-ins/Atomics/notify/immutable-buffer-returns-0.js b/third_party/test262/test/built-ins/Atomics/notify/immutable-buffer-returns-0.js new file mode 100644 index 00000000000000..f07f0a47fe0475 --- /dev/null +++ b/third_party/test262/test/built-ins/Atomics/notify/immutable-buffer-returns-0.js @@ -0,0 +1,46 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-atomics.notify +description: Returns 0 when TA.buffer is immutable +info: | + Atomics.notify ( typedArray, index, count ) + 1. Let taRecord be ? ValidateIntegerTypedArray(typedArray, true). + 2. Let byteIndexInBuffer be ? ValidateAtomicAccess(taRecord, index). + 3. If count is undefined, then + a. Let c be +∞. + 4. Else, + a. Let intCount be ? ToIntegerOrInfinity(count). + b. Let c be max(intCount, 0). + 5. Let buffer be typedArray.[[ViewedArrayBuffer]]. + 6. Let block be buffer.[[ArrayBufferData]]. + 7. If IsSharedArrayBuffer(buffer) is false, return +0𝔽. +features: [ArrayBuffer, Atomics, immutable-arraybuffer] +includes: [compareArray.js, testTypedArray.js] +---*/ + +var waitableTypedArrayConstructors = [Int32Array]; +if (typeof BigInt64Array !== "undefined") { + waitableTypedArrayConstructors.push(BigInt64Array); +} + +testWithAllTypedArrayConstructors(function(TA, makeCtorArg) { + var calls = []; + var index = { + valueOf() { + calls.push("index.valueOf"); + return 0; + } + }; + var count = { + valueOf() { + calls.push("count.valueOf"); + return 1; + } + }; + + var ta = new TA(makeCtorArg(8)); + assert.sameValue(Atomics.notify(ta, index, count), 0); + assert.compareArray(calls, ["index.valueOf", "count.valueOf"]); +}, waitableTypedArrayConstructors, ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/or/bad-range.js b/third_party/test262/test/built-ins/Atomics/or/bad-range.js index c221f203f17595..1910e157ba535f 100644 --- a/third_party/test262/test/built-ins/Atomics/or/bad-range.js +++ b/third_party/test262/test/built-ins/Atomics/or/bad-range.js @@ -19,4 +19,4 @@ testWithTypedArrayConstructors(function(TA) { Atomics.or(view, IdxGen(view), 10); }); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/or/bigint/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/or/bigint/non-shared-bufferdata.js index 6413bbe94072e5..f5cd4acac7e2d9 100644 --- a/third_party/test262/test/built-ins/Atomics/or/bigint/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/or/bigint/non-shared-bufferdata.js @@ -7,9 +7,9 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithBigIntTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.sameValue(Atomics.or(view, 0, 1n), 0n, 'Atomics.or(view, 0, 1n) returns 0n'); assert.sameValue(Atomics.load(view, 0), 1n, 'Atomics.load(view, 0) returns 1n'); -}, null, ["passthrough"]); +}, null, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/or/good-views.js b/third_party/test262/test/built-ins/Atomics/or/good-views.js index bea292a310f059..0f2cb4038e0d04 100644 --- a/third_party/test262/test/built-ins/Atomics/or/good-views.js +++ b/third_party/test262/test/built-ins/Atomics/or/good-views.js @@ -78,4 +78,4 @@ testWithTypedArrayConstructors(function(TA) { Atomics.store(view, Idx, 37); assert.sameValue(Atomics.or(view, Idx, 0), 37, 'Atomics.or(view, Idx, 0) returns 37'); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/or/immutable-buffer.js b/third_party/test262/test/built-ins/Atomics/or/immutable-buffer.js new file mode 100644 index 00000000000000..244ed23fa379ff --- /dev/null +++ b/third_party/test262/test/built-ins/Atomics/or/immutable-buffer.js @@ -0,0 +1,52 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-atomics.or +description: > + Throws a TypeError exception when the backing buffer is immutable +info: | + Atomics.or ( typedArray, index, value ) + 1. Let or be a new read-modify-write modification function... + 2. Return ? AtomicReadModifyWrite(typedArray, index, value, or). + + AtomicReadModifyWrite ( typedArray, index, value, op ) + 1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, ~write~). + + ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] ) + 1. If waitable is not present, set waitable to false. + 2. If accessMode is not present, set accessMode to ~read~. + 3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode). + + ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to ~read~. + 2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode). + + ValidateTypedArray ( O, order [ , accessMode ] ) + ... + 4. If accessMode is ~write~ and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. +features: [Atomics, immutable-arraybuffer] +includes: [compareArray.js, testTypedArray.js] +---*/ + +testWithAllTypedArrayConstructors(function(TA, makeCtorArg) { + var calls = []; + var index = { + valueOf() { + calls.push("index.valueOf"); + return 0; + } + }; + var value = { + valueOf() { + calls.push("value.valueOf"); + return 1; + } + }; + + var ta = new TA(makeCtorArg(8)); + assert.throws(TypeError, function() { + Atomics.or(ta, index, value); + }); + assert.compareArray(calls, []); +}, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/or/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/or/non-shared-bufferdata.js index bdd1060102a9e9..8bfc4a13f7ae88 100644 --- a/third_party/test262/test/built-ins/Atomics/or/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/or/non-shared-bufferdata.js @@ -8,11 +8,9 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithAtomicsFriendlyTypedArrayConstructors(TA => { - const view = new TA( - new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) - ); +testWithAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const view = new TA(makeCtorArg(4)); assert.sameValue(Atomics.or(view, 0, 1), 0, 'Atomics.or(view, 0, 1) returns 0'); assert.sameValue(Atomics.load(view, 0), 1, 'Atomics.load(view, 0) returns 1'); -}, null, ["passthrough"]); +}, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/or/non-shared-int-views-throws.js b/third_party/test262/test/built-ins/Atomics/or/non-shared-int-views-throws.js index aa25ae3882d538..dfbbeedfbac41f 100644 --- a/third_party/test262/test/built-ins/Atomics/or/non-shared-int-views-throws.js +++ b/third_party/test262/test/built-ins/Atomics/or/non-shared-int-views-throws.js @@ -4,15 +4,15 @@ /*--- esid: sec-atomics.or description: > - Atomics.or throws when operating on non-sharable integer TypedArrays + Atomics.or throws when operating on incompatible TypedArrays includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithNonAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.throws(TypeError, function() { Atomics.or(view, 0, 1); }, `Atomics.or(new ${TA.name}(buffer), 0, 1) throws TypeError`); -}, null, ["passthrough"]); +}, ["arraybuffer"]); diff --git a/third_party/test262/test/built-ins/Atomics/store/bad-range.js b/third_party/test262/test/built-ins/Atomics/store/bad-range.js index 4449f85dcd3e33..29f6167cca8787 100644 --- a/third_party/test262/test/built-ins/Atomics/store/bad-range.js +++ b/third_party/test262/test/built-ins/Atomics/store/bad-range.js @@ -19,4 +19,4 @@ testWithTypedArrayConstructors(function(TA) { Atomics.store(view, IdxGen(view), 10); }); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/store/bigint/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/store/bigint/non-shared-bufferdata.js index 7ee3f779d12269..03a68db18e0d5b 100644 --- a/third_party/test262/test/built-ins/Atomics/store/bigint/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/store/bigint/non-shared-bufferdata.js @@ -7,9 +7,9 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithBigIntTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.sameValue(Atomics.store(view, 0, 1n), 1n, 'Atomics.store(view, 0, 1n) returns 1n'); assert.sameValue(Atomics.load(view, 0), 1n, 'Atomics.load(view, 0) returns 1n'); -}, null, ["passthrough"]); +}, null, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/store/good-views.js b/third_party/test262/test/built-ins/Atomics/store/good-views.js index f84c83ce7ed6fb..2b2b341d61aede 100644 --- a/third_party/test262/test/built-ins/Atomics/store/good-views.js +++ b/third_party/test262/test/built-ins/Atomics/store/good-views.js @@ -51,7 +51,7 @@ testWithTypedArrayConstructors(function(TA) { Atomics.store(view, Idx, 37); assert.sameValue(Atomics.load(view, Idx), 37, 'Atomics.load(view, Idx) returns 37'); }); -}, views); +}, views, ["passthrough"]); function ToInteger(v) { v = +v; diff --git a/third_party/test262/test/built-ins/Atomics/store/immutable-buffer.js b/third_party/test262/test/built-ins/Atomics/store/immutable-buffer.js new file mode 100644 index 00000000000000..32cab0ac9f453f --- /dev/null +++ b/third_party/test262/test/built-ins/Atomics/store/immutable-buffer.js @@ -0,0 +1,48 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-atomics.store +description: > + Throws a TypeError exception when the backing buffer is immutable +info: | + Atomics.store ( typedArray, index, value ) + 1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, ~write~). + + ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] ) + 1. If waitable is not present, set waitable to false. + 2. If accessMode is not present, set accessMode to ~read~. + 3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode). + + ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to ~read~. + 2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode). + + ValidateTypedArray ( O, order [ , accessMode ] ) + ... + 4. If accessMode is ~write~ and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. +features: [Atomics, immutable-arraybuffer] +includes: [compareArray.js, testTypedArray.js] +---*/ + +testWithAllTypedArrayConstructors(function(TA, makeCtorArg) { + var calls = []; + var index = { + valueOf() { + calls.push("index.valueOf"); + return 0; + } + }; + var value = { + valueOf() { + calls.push("value.valueOf"); + return 1; + } + }; + + var ta = new TA(makeCtorArg(8)); + assert.throws(TypeError, function() { + Atomics.store(ta, index, value); + }); + assert.compareArray(calls, []); +}, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/store/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/store/non-shared-bufferdata.js index 19cd477bef3c0d..680e3fc41c12da 100644 --- a/third_party/test262/test/built-ins/Atomics/store/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/store/non-shared-bufferdata.js @@ -8,11 +8,9 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithAtomicsFriendlyTypedArrayConstructors(TA => { - const view = new TA( - new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) - ); +testWithAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const view = new TA(makeCtorArg(4)); assert.sameValue(Atomics.store(view, 0, 1), 1, 'Atomics.store(view, 0, 1) returns 1'); assert.sameValue(Atomics.load(view, 0), 1, 'Atomics.load(view, 0) returns 1'); -}, null, ["passthrough"]); +}, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/store/non-shared-int-views-throws.js b/third_party/test262/test/built-ins/Atomics/store/non-shared-int-views-throws.js index 57f0943c6d32c2..a38b97af59289a 100644 --- a/third_party/test262/test/built-ins/Atomics/store/non-shared-int-views-throws.js +++ b/third_party/test262/test/built-ins/Atomics/store/non-shared-int-views-throws.js @@ -4,15 +4,15 @@ /*--- esid: sec-atomics.store description: > - Atomics.store throws when operating on non-sharable integer TypedArrays + Atomics.store throws when operating on incompatible TypedArrays includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithNonAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.throws(TypeError, function() { Atomics.store(view, 0, 1); }, `Atomics.store(new ${TA.name}(buffer), 0, 1) throws TypeError`); -}, null, ["passthrough"]); +}, ["arraybuffer"]); diff --git a/third_party/test262/test/built-ins/Atomics/sub/bad-range.js b/third_party/test262/test/built-ins/Atomics/sub/bad-range.js index 15eabc048a1f3b..a3e6e17f9e80d8 100644 --- a/third_party/test262/test/built-ins/Atomics/sub/bad-range.js +++ b/third_party/test262/test/built-ins/Atomics/sub/bad-range.js @@ -19,4 +19,4 @@ testWithTypedArrayConstructors(function(TA) { Atomics.sub(view, IdxGen(view), 10); }); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/sub/bigint/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/sub/bigint/non-shared-bufferdata.js index b07b6931dba1c0..7fffa5fd179180 100644 --- a/third_party/test262/test/built-ins/Atomics/sub/bigint/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/sub/bigint/non-shared-bufferdata.js @@ -7,10 +7,10 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithBigIntTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.sameValue(Atomics.store(view, 0, 1n), 1n, 'Atomics.store(view, 0, 1n) returns 1n'); assert.sameValue(Atomics.sub(view, 0, 1n), 1n, 'Atomics.sub(view, 0, 1n) returns 1n'); assert.sameValue(Atomics.load(view, 0), 0n, 'Atomics.load(view, 0) returns 0n'); -}, null, ["passthrough"]); +}, null, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/sub/good-views.js b/third_party/test262/test/built-ins/Atomics/sub/good-views.js index a13b7d15e8e4e3..5a5b03baad8b83 100644 --- a/third_party/test262/test/built-ins/Atomics/sub/good-views.js +++ b/third_party/test262/test/built-ins/Atomics/sub/good-views.js @@ -51,4 +51,4 @@ testWithTypedArrayConstructors(function(TA) { Atomics.store(view, Idx, 37); assert.sameValue(Atomics.sub(view, Idx, 0), 37, 'Atomics.sub(view, Idx, 0) returns 37'); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/sub/immutable-buffer.js b/third_party/test262/test/built-ins/Atomics/sub/immutable-buffer.js new file mode 100644 index 00000000000000..f3c7d83e33e08c --- /dev/null +++ b/third_party/test262/test/built-ins/Atomics/sub/immutable-buffer.js @@ -0,0 +1,52 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-atomics.sub +description: > + Throws a TypeError exception when the backing buffer is immutable +info: | + Atomics.sub ( typedArray, index, value ) + 1. Let subtract be a new read-modify-write modification function... + 2. Return ? AtomicReadModifyWrite(typedArray, index, value, subtract). + + AtomicReadModifyWrite ( typedArray, index, value, op ) + 1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, ~write~). + + ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] ) + 1. If waitable is not present, set waitable to false. + 2. If accessMode is not present, set accessMode to ~read~. + 3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode). + + ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to ~read~. + 2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode). + + ValidateTypedArray ( O, order [ , accessMode ] ) + ... + 4. If accessMode is ~write~ and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. +features: [Atomics, immutable-arraybuffer] +includes: [compareArray.js, testTypedArray.js] +---*/ + +testWithAllTypedArrayConstructors(function(TA, makeCtorArg) { + var calls = []; + var index = { + valueOf() { + calls.push("index.valueOf"); + return 0; + } + }; + var value = { + valueOf() { + calls.push("value.valueOf"); + return 1; + } + }; + + var ta = new TA(makeCtorArg(8)); + assert.throws(TypeError, function() { + Atomics.sub(ta, index, value); + }); + assert.compareArray(calls, []); +}, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/sub/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/sub/non-shared-bufferdata.js index db536ccddceb44..40c91a2cd70e25 100644 --- a/third_party/test262/test/built-ins/Atomics/sub/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/sub/non-shared-bufferdata.js @@ -8,12 +8,10 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithAtomicsFriendlyTypedArrayConstructors(TA => { - const view = new TA( - new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) - ); +testWithAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const view = new TA(makeCtorArg(4)); assert.sameValue(Atomics.store(view, 0, 1), 1, 'Atomics.store(view, 0, 1) returns 1'); assert.sameValue(Atomics.sub(view, 0, 1), 1, 'Atomics.sub(view, 0, 1) returns 1'); assert.sameValue(Atomics.load(view, 0), 0, 'Atomics.load(view, 0) returns 0'); -}, null, ["passthrough"]); +}, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/sub/non-shared-int-views-throws.js b/third_party/test262/test/built-ins/Atomics/sub/non-shared-int-views-throws.js index 091b2ef9f3b84b..b055bf714acf79 100644 --- a/third_party/test262/test/built-ins/Atomics/sub/non-shared-int-views-throws.js +++ b/third_party/test262/test/built-ins/Atomics/sub/non-shared-int-views-throws.js @@ -4,15 +4,15 @@ /*--- esid: sec-atomics.sub description: > - Atomics.sub throws when operating on non-sharable integer TypedArrays + Atomics.sub throws when operating on incompatible TypedArrays includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(16); +testWithNonAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.throws(TypeError, function() { Atomics.sub(view, 0, 1); }, `Atomics.sub(new ${TA.name}(buffer), 0, 1) throws TypeError`); -}, null, ["passthrough"]); +}, ["arraybuffer"]); diff --git a/third_party/test262/test/built-ins/Atomics/xor/bad-range.js b/third_party/test262/test/built-ins/Atomics/xor/bad-range.js index 0de01cbd9cd860..d1e7aa5e9b79cb 100644 --- a/third_party/test262/test/built-ins/Atomics/xor/bad-range.js +++ b/third_party/test262/test/built-ins/Atomics/xor/bad-range.js @@ -19,4 +19,4 @@ testWithTypedArrayConstructors(function(TA) { Atomics.xor(view, IdxGen(view), 0); }); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/xor/bigint/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/xor/bigint/non-shared-bufferdata.js index d68d56cac6ac6a..74b768bc9b8843 100644 --- a/third_party/test262/test/built-ins/Atomics/xor/bigint/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/xor/bigint/non-shared-bufferdata.js @@ -7,9 +7,9 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithBigIntTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.sameValue(Atomics.xor(view, 0, 1n), 0n, 'Atomics.xor(view, 0, 1n) returns 0n'); assert.sameValue(Atomics.load(view, 0), 1n, 'Atomics.load(view, 0) returns 1n'); -}, null, ["passthrough"]); +}, null, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/xor/good-views.js b/third_party/test262/test/built-ins/Atomics/xor/good-views.js index 74198415fe5f1f..459c64e0086b7b 100644 --- a/third_party/test262/test/built-ins/Atomics/xor/good-views.js +++ b/third_party/test262/test/built-ins/Atomics/xor/good-views.js @@ -79,4 +79,4 @@ testWithTypedArrayConstructors(function(TA) { Atomics.store(view, Idx, 37); assert.sameValue(Atomics.xor(view, Idx, 0), 37, 'Atomics.xor(view, Idx, 0) returns 37'); }); -}, views); +}, views, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/Atomics/xor/immutable-buffer.js b/third_party/test262/test/built-ins/Atomics/xor/immutable-buffer.js new file mode 100644 index 00000000000000..e40e51d2a7a3ab --- /dev/null +++ b/third_party/test262/test/built-ins/Atomics/xor/immutable-buffer.js @@ -0,0 +1,52 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-atomics.xor +description: > + Throws a TypeError exception when the backing buffer is immutable +info: | + Atomics.xor ( typedArray, index, value ) + 1. Let xor be a new read-modify-write modification function... + 2. Return ? AtomicReadModifyWrite(typedArray, index, value, xor). + + AtomicReadModifyWrite ( typedArray, index, value, op ) + 1. Let byteIndexInBuffer be ? ValidateAtomicAccessOnIntegerTypedArray(typedArray, index, false, ~write~). + + ValidateAtomicAccessOnIntegerTypedArray ( typedArray, requestIndex [ , waitable [ , accessMode ] ] ) + 1. If waitable is not present, set waitable to false. + 2. If accessMode is not present, set accessMode to ~read~. + 3. Let taRecord be ? ValidateIntegerTypedArray(typedArray, waitable, accessMode). + + ValidateIntegerTypedArray ( typedArray, waitable [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to ~read~. + 2. Let taRecord be ? ValidateTypedArray(typedArray, unordered, accessMode). + + ValidateTypedArray ( O, order [ , accessMode ] ) + ... + 4. If accessMode is ~write~ and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. +features: [Atomics, immutable-arraybuffer] +includes: [compareArray.js, testTypedArray.js] +---*/ + +testWithAllTypedArrayConstructors(function(TA, makeCtorArg) { + var calls = []; + var index = { + valueOf() { + calls.push("index.valueOf"); + return 0; + } + }; + var value = { + valueOf() { + calls.push("value.valueOf"); + return 1; + } + }; + + var ta = new TA(makeCtorArg(8)); + assert.throws(TypeError, function() { + Atomics.xor(ta, index, value); + }); + assert.compareArray(calls, []); +}, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/xor/non-shared-bufferdata.js b/third_party/test262/test/built-ins/Atomics/xor/non-shared-bufferdata.js index 7f2fe1ae2646d7..ca5e3bb73156fe 100644 --- a/third_party/test262/test/built-ins/Atomics/xor/non-shared-bufferdata.js +++ b/third_party/test262/test/built-ins/Atomics/xor/non-shared-bufferdata.js @@ -8,11 +8,9 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithAtomicsFriendlyTypedArrayConstructors(TA => { - const view = new TA( - new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) - ); +testWithAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const view = new TA(makeCtorArg(4)); assert.sameValue(Atomics.xor(view, 0, 1), 0, 'Atomics.xor(view, 0, 1) returns 0'); assert.sameValue(Atomics.load(view, 0), 1, 'Atomics.load(view, 0) returns 1'); -}, null, ["passthrough"]); +}, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Atomics/xor/non-shared-int-views-throws.js b/third_party/test262/test/built-ins/Atomics/xor/non-shared-int-views-throws.js index 84dab376692b8a..6014382047dc2c 100644 --- a/third_party/test262/test/built-ins/Atomics/xor/non-shared-int-views-throws.js +++ b/third_party/test262/test/built-ins/Atomics/xor/non-shared-int-views-throws.js @@ -4,15 +4,15 @@ /*--- esid: sec-atomics.xor description: > - Atomics.xor throws when operating on non-sharable integer TypedArrays + Atomics.xor throws when operating on incompatible TypedArrays includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ -testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { - const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); +testWithNonAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => { + const buffer = makeCtorArg(4); const view = new TA(buffer); assert.throws(TypeError, function() { Atomics.xor(view, 0, 1); }, `Atomics.xor(new ${TA.name}(buffer), 0, 1) throws TypeError`); -}, null, ["passthrough"]); +}, ["arraybuffer"]); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/getter-cross-realm.js b/third_party/test262/test/built-ins/Error/prototype/stack/getter-cross-realm.js new file mode 100644 index 00000000000000..6aabbadec96260 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/getter-cross-realm.js @@ -0,0 +1,51 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-error.prototype.stack +description: > + The getter's [[ErrorData]] check is realm-agnostic: a getter from realm A + invoked on an Error instance from realm B returns a String, since the + internal-slot check examines object identity of the slot, not realm origin. +info: | + get Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If E does not have an [[ErrorData]] internal slot, return undefined. + 4. Return an implementation-defined string that represents the stack trace of E. +features: [error-stack-accessor, cross-realm] +---*/ + +var getA = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').get; + +var realmB = $262.createRealm().global; + +assert.notSameValue( + Error.prototype, + realmB.Error.prototype, + 'precondition: the two realms have distinct Error.prototype objects' +); + +// (a) Realm A's getter on a realm B Error instance: the instance has +// [[ErrorData]], so the getter returns a string regardless of which realm +// owns the slot. +var errB = new realmB.Error('msg'); +assert.sameValue(typeof getA.call(errB), 'string', 'cross-realm Error instance returns a string'); + +// (b) Realm A's getter on a realm B plain object: no [[ErrorData]], returns +// undefined. +var plainB = new realmB.Object(); +assert.sameValue(getA.call(plainB), undefined, 'cross-realm plain object returns undefined'); + +// (c) Realm A's getter on realm B's Error.prototype: the prototype object +// itself has no [[ErrorData]] slot, so the getter returns undefined. +assert.sameValue(getA.call(realmB.Error.prototype), undefined, 'cross-realm Error.prototype returns undefined'); + +// (d) Realm B's getter on a realm A Error instance: same logic in reverse. +var getB = Object.getOwnPropertyDescriptor(realmB.Error.prototype, 'stack').get; +assert.sameValue(typeof getB, 'function', 'realm B has its own getter'); +assert.notSameValue(getA, getB, 'the two realms have distinct getter functions'); + +var errA = new Error('msg'); +assert.sameValue(typeof getB.call(errA), 'string', 'realm B getter on realm A Error instance returns a string'); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/getter-data-property-shadows.js b/third_party/test262/test/built-ins/Error/prototype/stack/getter-data-property-shadows.js new file mode 100644 index 00000000000000..16736f2d54fb6f --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/getter-data-property-shadows.js @@ -0,0 +1,37 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-error.prototype.stack +description: > + An own data property named "stack" on an Error instance shadows the inherited + accessor when accessed via property lookup. +info: | + get Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If E does not have an [[ErrorData]] internal slot, return undefined. + 4. Return an implementation-defined string that represents the stack trace of E. +includes: [nativeErrors.js] +features: [error-stack-accessor] +---*/ + +var get = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').get; + +for (var i = 0; i < nativeErrors.length; ++i) { + var Ctor = nativeErrors[i]; + var err = new Ctor('msg'); + Object.defineProperty(err, 'stack', { + value: 'sentinel', + writable: true, + enumerable: true, + configurable: true, + }); + + assert.sameValue(err.stack, 'sentinel', Ctor.name + ': own data property is returned by [[Get]]'); + + // The inherited accessor still produces a string when invoked directly, + // because the algorithm operates on the [[ErrorData]] slot, not on properties. + assert.sameValue(typeof get.call(err), 'string', Ctor.name + ': inherited accessor still returns a string'); +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/getter-error-as-prototype.js b/third_party/test262/test/built-ins/Error/prototype/stack/getter-error-as-prototype.js new file mode 100644 index 00000000000000..3c8eb6496c017c --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/getter-error-as-prototype.js @@ -0,0 +1,38 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-error.prototype.stack +description: > + An object whose prototype is an Error instance does not itself have an + [[ErrorData]] internal slot, so the getter returns undefined. The slot is + not inherited through the prototype chain. +info: | + get Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If E does not have an [[ErrorData]] internal slot, return undefined. + 4. Return an implementation-defined string that represents the stack trace of E. +includes: [nativeErrors.js] +features: [error-stack-accessor, __proto__] +---*/ + +var get = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').get; + +for (var i = 0; i < nativeErrors.length; ++i) { + var Ctor = nativeErrors[i]; + var protoErr = new Ctor('outer'); + var o = { __proto__: protoErr }; + + assert.sameValue(get.call(o), undefined, Ctor.name + ': get.call on object with instance as proto'); + + // Property access walks the prototype chain to find the accessor on + // Error.prototype, then calls the getter with this set to the original + // receiver (o). Because o lacks [[ErrorData]], the result is undefined. + assert.sameValue(o.stack, undefined, Ctor.name + ': property access on object with instance as proto'); + + // The inherited instance still produces a string when the getter is invoked + // on it directly. + assert.sameValue(typeof get.call(protoErr), 'string', Ctor.name + ': get.call on the underlying instance'); +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/getter-error-instance.js b/third_party/test262/test/built-ins/Error/prototype/stack/getter-error-instance.js new file mode 100644 index 00000000000000..aeb820f6738d53 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/getter-error-instance.js @@ -0,0 +1,38 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-error.prototype.stack +description: > + Returns a String when called on an Error instance. +info: | + get Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If E does not have an [[ErrorData]] internal slot, return undefined. + 4. Return an implementation-defined string that represents the stack trace of E. +includes: [nativeErrors.js] +features: [error-stack-accessor] +---*/ + +var get = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').get; + +var errors = []; +for (var i = 0; i < allErrorConstructors.length; ++i) { + var Ctor = allErrorConstructors[i]; + errors.push([Ctor.name, makeNativeError(Ctor, true), makeNativeError(Ctor, false)]); +} + +for (var i = 0; i < errors.length; ++i) { + var name = errors[i][0]; + var err = errors[i][1]; + var err2 = errors[i][2]; + + assert.sameValue(typeof get.call(err), 'string', name + ': new Ctor instance via get.call'); + assert.sameValue(typeof err.stack, 'string', name + ': new Ctor instance via property access'); + + assert.sameValue(typeof get.call(err2), 'string', name + ': Ctor called without new'); + + assert.sameValue(typeof get.call(err), 'string', name + ': second call still returns a string'); +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/getter-error-prototype.js b/third_party/test262/test/built-ins/Error/prototype/stack/getter-error-prototype.js new file mode 100644 index 00000000000000..0aba41d5946535 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/getter-error-prototype.js @@ -0,0 +1,42 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-error.prototype.stack +description: > + The getter returns undefined when called on Error.prototype itself or any + NativeError prototype: each is an ordinary object that is not an Error + instance and does not have an [[ErrorData]] internal slot. +info: | + get Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If E does not have an [[ErrorData]] internal slot, return undefined. + 4. Return an implementation-defined string that represents the stack trace of E. + + Properties of the Error Prototype Object + + The Error prototype object: + [...] + is not an Error instance and does not have an [[ErrorData]] internal slot. +includes: [nativeErrors.js] +features: [error-stack-accessor] +---*/ + +var get = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').get; + +var prototypes = []; +for (var i = 0; i < allErrorConstructors.length; ++i) { + var Ctor = allErrorConstructors[i]; + prototypes.push([Ctor.name + '.prototype', Ctor.prototype]); +} + +for (var i = 0; i < prototypes.length; ++i) { + var label = prototypes[i][0]; + var proto = prototypes[i][1]; + assert.sameValue(get.call(proto), undefined, label); +} + +// Access via the property also returns undefined on Error.prototype. +assert.sameValue(Error.prototype.stack, undefined, 'Error.prototype.stack property access'); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/getter-foreign-new-target.js b/third_party/test262/test/built-ins/Error/prototype/stack/getter-foreign-new-target.js new file mode 100644 index 00000000000000..0661a709e8d22e --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/getter-foreign-new-target.js @@ -0,0 +1,46 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-error.prototype.stack +description: > + An Error instance constructed with a non-Error new.target acquires the + [[ErrorData]] internal slot from Error's [[Construct]], so the getter + returns a String when invoked directly. Property access via the result + does NOT find the inherited accessor, because the result's [[Prototype]] + is the new.target's prototype, not Error.prototype. +info: | + get Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If E does not have an [[ErrorData]] internal slot, return undefined. + 4. Return an implementation-defined string that represents the stack trace of E. +includes: [nativeErrors.js] +features: [error-stack-accessor, Reflect.construct] +---*/ + +var get = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').get; + +function NotAnError() {} + +for (var i = 0; i < nativeErrors.length; ++i) { + var Ctor = nativeErrors[i]; + var e = Reflect.construct(Ctor, ['msg'], NotAnError); + + assert.sameValue( + Object.getPrototypeOf(e), + NotAnError.prototype, + Ctor.name + ': [[Prototype]] is the new.target prototype' + ); + + // The internal slot is set by Ctor's [[Construct]] regardless of new.target, + // so the getter (called directly) still produces a string. + assert.sameValue(typeof get.call(e), 'string', Ctor.name + ': via get.call'); + + // Property access on the instance does NOT find the inherited accessor: + // Error.prototype is not on e's prototype chain (it's only on Ctor.prototype, + // which is bypassed by the foreign new.target). The lookup walks + // NotAnError.prototype then Object.prototype and returns undefined. + assert.sameValue(e.stack, undefined, Ctor.name + ': property access returns undefined'); +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/getter-no-error-data.js b/third_party/test262/test/built-ins/Error/prototype/stack/getter-no-error-data.js new file mode 100644 index 00000000000000..2e6df9fff4e65f --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/getter-no-error-data.js @@ -0,0 +1,58 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-error.prototype.stack +description: > + Returns undefined when called on an object that does not have an + [[ErrorData]] internal slot. +info: | + get Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If E does not have an [[ErrorData]] internal slot, return undefined. + 4. Return an implementation-defined string that represents the stack trace of E. +features: [error-stack-accessor] +---*/ + +var get = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').get; + +var receivers = [ + ['plain object', {}], + ['null-prototype object', { __proto__: null }], + ['array', []], + ['function', function () {}], + ['RegExp', /re/], + ['Date', new Date()], + ['Boolean wrapper', new Boolean(true)], + ['Number wrapper', new Number(0)], + ['String wrapper', new String('')], + typeof ArrayBuffer === 'undefined' ? null : ['ArrayBuffer', new ArrayBuffer(0)], + typeof Map === 'undefined' ? null : ['Map', new Map()], + typeof Set === 'undefined' ? null : ['Set', new Set()], + typeof WeakMap === 'undefined' ? null : ['WeakMap', new WeakMap()], + typeof WeakSet === 'undefined' ? null : ['WeakSet', new WeakSet()], + typeof Promise === 'undefined' ? null : ['Promise', new Promise(function () {})], + typeof Int8Array === 'undefined' ? null : ['TypedArray', new Int8Array()] +]; + +for (var i = 0; i < receivers.length; ++i) { + if (!receivers[i]) continue; + var label = receivers[i][0]; + var value = receivers[i][1]; + assert.sameValue(get.call(value), undefined, label); +} + +// An object that inherits from Error.prototype but lacks [[ErrorData]] still +// returns undefined: the getter checks for the internal slot, not the prototype. +var fakeError = Object.create(Error.prototype); +assert.sameValue(get.call(fakeError), undefined, 'object with Error.prototype on its prototype chain'); + +var fakeErrorWithStack = Object.create(Error.prototype); +Object.defineProperty(fakeErrorWithStack, 'stack', { value: 'imposter', writable: true, enumerable: true, configurable: true }); +assert.sameValue( + get.call(fakeErrorWithStack), + undefined, + 'an existing own "stack" data property is ignored by the getter on a non-Error object' +); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/getter-not-a-constructor.js b/third_party/test262/test/built-ins/Error/prototype/stack/getter-not-a-constructor.js new file mode 100644 index 00000000000000..2a594897578f60 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/getter-not-a-constructor.js @@ -0,0 +1,28 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-error.prototype.stack +description: > + get Error.prototype.stack does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. +includes: [isConstructor.js] +features: [error-stack-accessor, Reflect.construct] +---*/ + +var get = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').get; + +assert.sameValue( + isConstructor(get), + false, + 'isConstructor(get Error.prototype.stack) must return false' +); + +assert.throws(TypeError, function () { + new get(); +}); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/getter-receiver-is-proxy.js b/third_party/test262/test/built-ins/Error/prototype/stack/getter-receiver-is-proxy.js new file mode 100644 index 00000000000000..a43bf4ce4e8bb8 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/getter-receiver-is-proxy.js @@ -0,0 +1,56 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-error.prototype.stack +description: > + The getter operates on the receiver's [[ErrorData]] internal slot directly. + When the receiver is a Proxy, the proxy's traps are not consulted: a Proxy + has no [[ErrorData]] internal slot regardless of its target, so the getter + returns undefined. +info: | + get Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If E does not have an [[ErrorData]] internal slot, return undefined. + 4. Return an implementation-defined string that represents the stack trace of E. +includes: [proxyTrapsHelper.js] +features: [error-stack-accessor, Proxy, Reflect] +---*/ + +var get = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').get; + +// (a) Proxy wrapping an Error instance: the Proxy itself has no [[ErrorData]], +// so the getter returns undefined without consulting the wrapped target. No +// proxy traps should fire; allowProxyTraps with no overrides throws +// Test262Error if any do. +assert.sameValue( + get.call(new Proxy(new Error('inner'), allowProxyTraps(null, '(a)'))), + undefined, + 'Proxy wrapping Error returns undefined' +); + +// (b) Property access through the Proxy: the [[Get]] forwards the access to +// the proxy's get trap, but the receiver passed through to the inherited +// accessor on Error.prototype is the proxy itself. Since the proxy lacks +// [[ErrorData]], the getter returns undefined; the get trap fires exactly +// once for the property access. +var stackTrapCalls = 0; +var pB = new Proxy(new Error('inner'), allowProxyTraps({ + get: function (t, key, receiver) { + if (key === 'stack') { + stackTrapCalls += 1; + } + return Reflect.get(t, key, receiver); + } +}, '(b)')); +assert.sameValue(pB.stack, undefined, 'property access on proxy: receiver is proxy, no [[ErrorData]]'); +assert.sameValue(stackTrapCalls, 1, 'get trap fired once for the property access'); + +// (c) Proxy wrapping a non-Error: still undefined. +assert.sameValue( + get.call(new Proxy({}, allowProxyTraps(null, '(c)'))), + undefined, + 'Proxy wrapping plain object returns undefined' +); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/getter-subclass.js b/third_party/test262/test/built-ins/Error/prototype/stack/getter-subclass.js new file mode 100644 index 00000000000000..fcda36a2f961de --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/getter-subclass.js @@ -0,0 +1,29 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-error.prototype.stack +description: > + The getter returns a String when called on a subclass of Error or any + NativeError, since subclasses inherit the [[ErrorData]] internal slot. +info: | + get Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If E does not have an [[ErrorData]] internal slot, return undefined. + 4. Return an implementation-defined string that represents the stack trace of E. +includes: [nativeErrors.js] +features: [error-stack-accessor, class] +---*/ + +var get = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').get; + +for (var i = 0; i < nativeErrors.length; ++i) { + var Ctor = nativeErrors[i]; + var Sub = class extends Ctor {}; + var e = new Sub('msg'); + + assert.sameValue(typeof get.call(e), 'string', Ctor.name + ': subclass via get.call'); + assert.sameValue(typeof e.stack, 'string', Ctor.name + ': subclass via property access'); +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/getter-this-not-object.js b/third_party/test262/test/built-ins/Error/prototype/stack/getter-this-not-object.js new file mode 100644 index 00000000000000..b0a61ccdcad7b5 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/getter-this-not-object.js @@ -0,0 +1,38 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-error.prototype.stack +description: > + Throws a TypeError if the this value is not an Object. +info: | + get Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. +features: [error-stack-accessor] +---*/ + +var get = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').get; + +assert.sameValue(typeof get, 'function'); + +var badReceivers = [ + ['undefined', undefined], + ['null', null], + ['true', true], + ['false', false], + ['number', 1], + ['string', ''], + typeof Symbol === 'undefined' ? null : ['symbol', Symbol('s')], + typeof BigInt === 'undefined' ? null : ['bigint', BigInt(0)] +]; + +for (var i = 0; i < badReceivers.length; ++i) { + if (!badReceivers[i]) continue; + var label = badReceivers[i][0]; + var value = badReceivers[i][1]; + assert.throws(TypeError, function () { + get.call(value); + }, label); +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/instance-no-own-stack.js b/third_party/test262/test/built-ins/Error/prototype/stack/instance-no-own-stack.js new file mode 100644 index 00000000000000..560a4fe3485503 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/instance-no-own-stack.js @@ -0,0 +1,53 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-error-instances +description: > + A freshly-constructed Error instance has no own "stack" property; the + property is reached via the inherited accessor on Error.prototype. +info: | + Properties of Error Instances + + Error instances are ordinary objects that inherit properties from the Error + prototype object and have an [[ErrorData]] internal slot whose value is + undefined. + + Error.prototype.stack is an accessor property with attributes + { [[Enumerable]]: false, [[Configurable]]: true }. +includes: [nativeErrors.js] +features: [error-stack-accessor] +---*/ + +for (var i = 0; i < nativeErrors.length; ++i) { + var Ctor = nativeErrors[i]; + var err = new Ctor('msg'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(err, 'stack'), + false, + Ctor.name + ': hasOwnProperty("stack") is false' + ); + + assert.sameValue( + Object.getOwnPropertyDescriptor(err, 'stack'), + undefined, + Ctor.name + ': getOwnPropertyDescriptor returns undefined' + ); + + // For NativeErrors, the immediate prototype is e.g. TypeError.prototype, + // which does NOT have its own "stack" property; the accessor lives only on + // Error.prototype, two links up. + if (Ctor !== Error) { + assert.sameValue( + Object.getOwnPropertyDescriptor(Object.getPrototypeOf(err), 'stack'), + undefined, + Ctor.name + ': stack is not an own property of NativeError.prototype' + ); + } + + var desc = Object.getOwnPropertyDescriptor(Error.prototype, 'stack'); + assert.notSameValue(desc, undefined, Ctor.name + ': Error.prototype has the accessor'); + assert.sameValue(typeof desc.get, 'function', Ctor.name + ': accessor get is a function'); + assert.sameValue(typeof desc.set, 'function', Ctor.name + ': accessor set is a function'); +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/instance-not-enumerable.js b/third_party/test262/test/built-ins/Error/prototype/stack/instance-not-enumerable.js new file mode 100644 index 00000000000000..bda43b428ace38 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/instance-not-enumerable.js @@ -0,0 +1,75 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-error.prototype-stack +description: > + "stack" is a non-enumerable accessor on Error.prototype, and Error instances + do not have an own "stack" property, so "stack" is not visible via + Object.keys, for-in, propertyIsEnumerable, or JSON.stringify. +info: | + Error.prototype.stack is an accessor property with attributes + { [[Enumerable]]: false, [[Configurable]]: true }. + + Properties of Error Instances + + Error instances are ordinary objects that inherit properties from the Error + prototype object and have an [[ErrorData]] internal slot whose value is + undefined. +includes: [nativeErrors.js] +features: [error-stack-accessor] +---*/ + +for (var i = 0; i < nativeErrors.length; ++i) { + var Ctor = nativeErrors[i]; + var err = new Ctor('msg'); + + assert.sameValue( + Object.keys(err).indexOf('stack'), + -1, + Ctor.name + ': Object.keys does not include "stack"' + ); + + assert.sameValue( + Object.getOwnPropertyNames(err).indexOf('stack'), + -1, + Ctor.name + ': getOwnPropertyNames does not include "stack"' + ); + + var sawStack = false; + for (var key in err) { + if (key === 'stack') { + sawStack = true; + } + } + assert.sameValue(sawStack, false, Ctor.name + ': for-in does not yield "stack"'); + + assert.sameValue( + Object.prototype.propertyIsEnumerable.call(err, 'stack'), + false, + Ctor.name + ': propertyIsEnumerable returns false' + ); + + assert.sameValue( + Object.prototype.propertyIsEnumerable.call(Error.prototype, 'stack'), + false, + Ctor.name + ': Error.prototype.propertyIsEnumerable("stack") is false' + ); + + // JSON.stringify omits non-enumerable / non-own properties; a fresh Error + // instance has no enumerable own properties at all. + assert.sameValue( + JSON.stringify(err), + '{}', + Ctor.name + ': JSON.stringify output is empty object' + ); + + // Object.assign reads only enumerable own properties; the inherited + // accessor is not own, so "stack" is not copied. + var copy = Object.assign({}, err); + assert.sameValue( + Object.prototype.hasOwnProperty.call(copy, 'stack'), + false, + Ctor.name + ': Object.assign({}, err) does not copy "stack"' + ); +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/prop-desc.js b/third_party/test262/test/built-ins/Error/prototype/stack/prop-desc.js new file mode 100644 index 00000000000000..1ff1753c4e637b --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/prop-desc.js @@ -0,0 +1,31 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-error.prototype-stack +description: > + Property descriptor of Error.prototype.stack +info: | + Error.prototype.stack is an accessor property with attributes + { [[Enumerable]]: false, [[Configurable]]: true }. + + ECMAScript Standard Built-in Objects + + Functions that are specified as get or set accessor functions of built-in + properties have "get " or "set " prepended to the property name string. + + Unless otherwise specified, the length property of a built-in function object + has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. + + Unless otherwise specified, the name property of a built-in function object, + if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +features: [error-stack-accessor] +includes: [propertyHelper.js] +---*/ + +verifyPrimordialAccessorProperty(Error.prototype, 'stack', { + get: { name: 'get stack', length: 0 }, + set: { name: 'set stack', length: 1 }, +}, { label: 'Error.prototype.stack' }); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-creates-own-property.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-creates-own-property.js new file mode 100644 index 00000000000000..16698efd9a776e --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-creates-own-property.js @@ -0,0 +1,67 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + When the receiver does not have an own "stack" property, the setter creates + one as a writable, enumerable, configurable data property whose value is v. +info: | + set Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If v is not a String, throw a TypeError exception. + 4. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Error.prototype%, "stack", v). + 5. Return undefined. + + SetterThatIgnoresPrototypeProperties ( this, home, p, v ) + + [...] + 3. Let desc be ? this.[[GetOwnProperty]](p). + 4. If desc is undefined, then + a. Perform ? CreateDataPropertyOrThrow(this, p, v). + [...] +includes: [nativeErrors.js, propertyHelper.js] +features: [error-stack-accessor] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +var errors = []; +for (var i = 0; i < allErrorConstructors.length; ++i) { + var Ctor = allErrorConstructors[i]; + errors.push([Ctor.name, makeNativeError(Ctor, true)]); +} + +for (var i = 0; i < errors.length; ++i) { + var name = errors[i][0]; + var err = errors[i][1]; + + assert.sameValue( + Object.prototype.hasOwnProperty.call(err, 'stack'), + false, + name + ': precondition: instance has no own "stack" property at construction' + ); + + var result = set.call(err, 'sentinel-' + name); + assert.sameValue(result, undefined, name + ': setter returns undefined'); + + verifyProperty(err, 'stack', { + value: 'sentinel-' + name, + writable: true, + enumerable: true, + configurable: true, + }); +} + +// The same applies to a plain object that lacks [[ErrorData]]: the setter +// does not check for the internal slot before installing the property. +var plain = {}; +set.call(plain, 'on-plain'); +verifyProperty(plain, 'stack', { + value: 'on-plain', + writable: true, + enumerable: true, + configurable: true, +}); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-cross-realm.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-cross-realm.js new file mode 100644 index 00000000000000..d699a76ca9dea7 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-cross-realm.js @@ -0,0 +1,90 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + The setter's home-object (SameValue) check is realm-scoped: a setter from + realm A locks against realm A's %Error.prototype% only. Cross-realm objects + are accepted as receivers (they pass the SameValue check), and an Error + instance from another realm gets an own "stack" data property installed. +info: | + set Error.prototype.stack + + [...] + 4. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Error.prototype%, "stack", v). + + SetterThatIgnoresPrototypeProperties ( this, home, p, v ) + + [...] + 2. If SameValue(this, home) is true, then + a. Throw a TypeError exception. + 3. Let desc be ? this.[[GetOwnProperty]](p). + 4. If desc is undefined, then + a. Perform ? CreateDataPropertyOrThrow(this, p, v). +includes: [propertyHelper.js] +features: [error-stack-accessor, cross-realm] +---*/ + +var setA = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +var realmB = $262.createRealm().global; + +assert.notSameValue( + Error.prototype, + realmB.Error.prototype, + 'precondition: the two realms have distinct Error.prototype objects' +); + +// (a) Realm A's setter on a realm B Error instance: passes SameValue (the +// instance is not realm A's Error.prototype), and the instance has no own +// "stack" property at construction, so CreateDataPropertyOrThrow installs one. +var errB = new realmB.Error('msg'); +assert.sameValue( + Object.prototype.hasOwnProperty.call(errB, 'stack'), + false, + 'precondition: cross-realm Error instance has no own "stack" property' +); + +setA.call(errB, 'sentinel'); + +verifyProperty(errB, 'stack', { + value: 'sentinel', + writable: true, + enumerable: true, + configurable: true, +}); + +// (b) Realm A's setter on a plain object from realm B: same path, installs an +// own data property. +var plainB = new realmB.Object(); +setA.call(plainB, 'plain'); + +verifyProperty(plainB, 'stack', { + value: 'plain', + writable: true, + enumerable: true, + configurable: true, +}); + +// (c) Realm A's setter is structurally distinct from realm B's setter. +var setB = Object.getOwnPropertyDescriptor(realmB.Error.prototype, 'stack').set; +assert.sameValue(typeof setB, 'function', 'realm B has its own setter'); +assert.notSameValue(setA, setB, 'the two realms have distinct setter functions'); + +// (d) Realm A's setter on realm B's Error.prototype passes realm A's +// SameValue check (the two prototypes are distinct objects), so step 2 of +// SetterThatIgnoresPrototypeProperties does not fire. Step 3 finds realm B's +// own "stack" accessor descriptor and proceeds to step 5: Set(O, p, v, true) +// invokes that accessor's setter, which is realm B's setter. Realm B's setter +// then throws via its own SameValue check (this === realm B's Error.prototype). +// The thrown TypeError is realm B's TypeError. +assert.throws(realmB.TypeError, function () { + setA.call(realmB.Error.prototype, 'should-throw'); +}, 'realm A setter on realm B Error.prototype throws (via realm B setter)'); + +// (e) Realm A's setter on realm A's own Error.prototype throws via step 2 +// (SameValue with realm A's home). +assert.throws(TypeError, function () { + setA.call(Error.prototype, 'should-throw'); +}, 'realm A setter on realm A Error.prototype throws via SameValue'); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-delete-round-trip.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-delete-round-trip.js new file mode 100644 index 00000000000000..1789de5313bf01 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-delete-round-trip.js @@ -0,0 +1,65 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + After the setter installs an own "stack" data property, deleting it + re-exposes the inherited accessor on Error.prototype. +info: | + set Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If v is not a String, throw a TypeError exception. + 4. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Error.prototype%, "stack", v). + 5. Return undefined. + + SetterThatIgnoresPrototypeProperties ( this, home, p, v ) + + [...] + 4. If desc is undefined, then + a. Perform ? CreateDataPropertyOrThrow(this, p, v). +includes: [nativeErrors.js] +features: [error-stack-accessor] +---*/ + +var get = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').get; +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +for (var i = 0; i < nativeErrors.length; ++i) { + var Ctor = nativeErrors[i]; + var err = new Ctor('msg'); + + // delete on a fresh instance: nothing to remove, returns true. + assert.sameValue(delete err.stack, true, Ctor.name + ': delete on fresh instance returns true'); + assert.sameValue( + Object.prototype.hasOwnProperty.call(err, 'stack'), + false, + Ctor.name + ': still no own property after delete' + ); + + // The inherited accessor still produces a string. + assert.sameValue(typeof get.call(err), 'string', Ctor.name + ': accessor still works'); + + // After setting, an own data property is installed. + set.call(err, 'sentinel'); + assert.sameValue( + Object.prototype.hasOwnProperty.call(err, 'stack'), + true, + Ctor.name + ': own property installed after set' + ); + assert.sameValue(err.stack, 'sentinel', Ctor.name + ': data property shadows accessor'); + + // delete removes the own data property. + assert.sameValue(delete err.stack, true, Ctor.name + ': delete removes own data property'); + assert.sameValue( + Object.prototype.hasOwnProperty.call(err, 'stack'), + false, + Ctor.name + ': own property removed' + ); + + // The inherited accessor is exposed again, and [[ErrorData]] still drives it. + assert.sameValue(typeof err.stack, 'string', Ctor.name + ': inherited accessor re-exposed'); + assert.sameValue(typeof get.call(err), 'string', Ctor.name + ': accessor still returns a string'); +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-empty-string.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-empty-string.js new file mode 100644 index 00000000000000..3104b88bc80cd6 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-empty-string.js @@ -0,0 +1,37 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + An empty string is a String, so the setter accepts it. +info: | + set Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If v is not a String, throw a TypeError exception. + 4. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Error.prototype%, "stack", v). + 5. Return undefined. +includes: [propertyHelper.js, nativeErrors.js] +features: [error-stack-accessor] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +for (var i = 0; i < nativeErrors.length; ++i) { + var Ctor = nativeErrors[i]; + var err = new Ctor('msg'); + set.call(err, ''); + + // Verify the round-trip via property access before invoking verifyProperty + // (which deletes the configurable own property as part of its check). + assert.sameValue(err.stack, '', Ctor.name + ': empty string round-trips through property access'); + + verifyProperty(err, 'stack', { + value: '', + writable: true, + enumerable: true, + configurable: true, + }); +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-existing-own-property.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-existing-own-property.js new file mode 100644 index 00000000000000..29cd22acbc0841 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-existing-own-property.js @@ -0,0 +1,52 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + When the receiver already has an own "stack" data property, the setter + performs a [[Set]] on it (preserving its current attributes). +info: | + set Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If v is not a String, throw a TypeError exception. + 4. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Error.prototype%, "stack", v). + 5. Return undefined. + + SetterThatIgnoresPrototypeProperties ( this, home, p, v ) + + [...] + 3. Let desc be ? this.[[GetOwnProperty]](p). + 4. If desc is undefined, then + a. Perform ? CreateDataPropertyOrThrow(this, p, v). + 5. Else, + a. Perform ? Set(this, p, v, true). + [...] +includes: [propertyHelper.js, nativeErrors.js] +features: [error-stack-accessor] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +for (var i = 0; i < nativeErrors.length; ++i) { + var Ctor = nativeErrors[i]; + var err = new Ctor('msg'); + Object.defineProperty(err, 'stack', { + value: 'original', + writable: true, + enumerable: false, + configurable: false, + }); + + set.call(err, 'updated'); + + // The existing descriptor is preserved; only the value changes (per [[Set]]). + verifyProperty(err, 'stack', { + value: 'updated', + writable: true, + enumerable: false, + configurable: false, + }); +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-no-argument.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-no-argument.js new file mode 100644 index 00000000000000..5047662c7b6b3e --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-no-argument.js @@ -0,0 +1,28 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + When the setter is called with no argument, v is undefined, which is not a + String, so a TypeError is thrown. +info: | + set Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If v is not a String, throw a TypeError exception. +includes: [nativeErrors.js] +features: [error-stack-accessor] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +for (var i = 0; i < nativeErrors.length; ++i) { + var Ctor = nativeErrors[i]; + var err = new Ctor('msg'); + + assert.throws(TypeError, function () { + set.call(err); + }, Ctor.name); +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-non-error-receiver.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-non-error-receiver.js new file mode 100644 index 00000000000000..221628ebd02931 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-non-error-receiver.js @@ -0,0 +1,61 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + The setter does not check for the [[ErrorData]] internal slot, so it works + on any extensible object that is not %Error.prototype%. +info: | + set Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If v is not a String, throw a TypeError exception. + 4. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Error.prototype%, "stack", v). + 5. Return undefined. +includes: [propertyHelper.js] +features: [error-stack-accessor] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +// Plain object: installs an own data property. +var plain = {}; +set.call(plain, 'plain'); +verifyProperty(plain, 'stack', { + value: 'plain', + writable: true, + enumerable: true, + configurable: true, +}); + +// Array: installs an own data property. +var arr = []; +set.call(arr, 'array'); +verifyProperty(arr, 'stack', { + value: 'array', + writable: true, + enumerable: true, + configurable: true, +}); + +// Function: installs an own data property. +var fn = function () {}; +set.call(fn, 'function'); +verifyProperty(fn, 'stack', { + value: 'function', + writable: true, + enumerable: true, + configurable: true, +}); + +// Object whose prototype is Error.prototype but lacks [[ErrorData]]: still works. +var fakeError = Object.create(Error.prototype); +set.call(fakeError, 'fake'); +verifyProperty(fakeError, 'stack', { + value: 'fake', + writable: true, + enumerable: true, + configurable: true, +}); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-non-extensible-receiver.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-non-extensible-receiver.js new file mode 100644 index 00000000000000..1b6741396f2743 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-non-extensible-receiver.js @@ -0,0 +1,76 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + When the receiver lacks an own "stack" property and has any integrity level + applied (preventExtensions, seal, freeze), the setter throws a TypeError + because CreateDataPropertyOrThrow cannot add a property to a non-extensible + object. +info: | + set Error.prototype.stack + + [...] + 4. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Error.prototype%, "stack", v). + + SetterThatIgnoresPrototypeProperties ( this, home, p, v ) + + [...] + 3. Let desc be ? this.[[GetOwnProperty]](p). + 4. If desc is undefined, then + a. Perform ? CreateDataPropertyOrThrow(this, p, v). + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +includes: [nativeErrors.js] +features: [error-stack-accessor] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +var integrityLevels = [ + { name: 'preventExtensions', fn: Object.preventExtensions }, + { name: 'seal', fn: Object.seal }, + { name: 'freeze', fn: Object.freeze } +]; + +for (var i = 0; i < nativeErrors.length; ++i) { + var Ctor = nativeErrors[i]; + + for (var j = 0; j < integrityLevels.length; ++j) { + var level = integrityLevels[j]; + var label = Ctor.name + '/' + level.name; + + var err = new Ctor('msg'); + assert.sameValue( + Object.prototype.hasOwnProperty.call(err, 'stack'), + false, + label + ': precondition: instance has no own "stack" property at construction' + ); + + level.fn(err); + + assert.throws(TypeError, function () { + set.call(err, 'sentinel'); + }, label + ': instance without own "stack" rejects setter'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(err, 'stack'), + false, + label + ': no own "stack" property was created' + ); + } +} + +// Same behavior on plain objects at each integrity level. +for (var k = 0; k < integrityLevels.length; ++k) { + var lvl = integrityLevels[k]; + var obj = lvl.fn({}); + assert.throws(TypeError, function () { + set.call(obj, 'sentinel'); + }, lvl.name + ' plain object without own "stack"'); +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-non-string-value.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-non-string-value.js new file mode 100644 index 00000000000000..96404f68c43746 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-non-string-value.js @@ -0,0 +1,53 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + Throws a TypeError if the value being assigned is not a String. +info: | + set Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If v is not a String, throw a TypeError exception. +includes: [nativeErrors.js] +features: [error-stack-accessor] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +// An object with a toString method is not coerced; the algorithm requires v +// to already be a String. +var coercible = { + toString: function () { return 'coerced'; }, + valueOf: function () { return 'coerced'; }, +}; + +var badValues = [ + ['undefined', undefined], + ['null', null], + ['true', true], + ['false', false], + ['number', 1], + ['object', {}], + ['array', []], + ['object with toString', coercible], + ['String wrapper object', new String('boxed')], + typeof Symbol === 'undefined' ? null : ['symbol', Symbol('s')], + typeof BigInt === 'undefined' ? null : ['bigint', BigInt(0)] +]; + +for (var i = 0; i < nativeErrors.length; ++i) { + var Ctor = nativeErrors[i]; + var err = new Ctor('msg'); + + for (var j = 0; j < badValues.length; ++j) { + if (!badValues[j]) continue; + var label = badValues[j][0]; + var value = badValues[j][1]; + assert.throws(TypeError, function () { + set.call(err, value); + }, Ctor.name + ': ' + label); + } +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-non-writable-stack.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-non-writable-stack.js new file mode 100644 index 00000000000000..672b05a79f0810 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-non-writable-stack.js @@ -0,0 +1,70 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + When the receiver has an own non-writable "stack" data property, the setter + throws a TypeError because the underlying [[Set]] is invoked with Throw=true. +info: | + set Error.prototype.stack + + [...] + 4. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Error.prototype%, "stack", v). + + SetterThatIgnoresPrototypeProperties ( this, home, p, v ) + + [...] + 3. Let desc be ? this.[[GetOwnProperty]](p). + [...] + 5. Else, + a. Perform ? Set(this, p, v, true). +includes: [propertyHelper.js, nativeErrors.js] +features: [error-stack-accessor] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +for (var i = 0; i < nativeErrors.length; ++i) { + var Ctor = nativeErrors[i]; + + var err = new Ctor('msg'); + Object.defineProperty(err, 'stack', { + value: 'original', + writable: false, + enumerable: false, + configurable: true, + }); + + assert.throws(TypeError, function () { + set.call(err, 'updated'); + }, Ctor.name + ': non-writable own "stack"'); + + verifyProperty(err, 'stack', { + value: 'original', + writable: false, + enumerable: false, + configurable: true, + }); + + // Frozen instance with an own "stack" data property: still throws. + var frozen = new Ctor('msg'); + Object.defineProperty(frozen, 'stack', { + value: 'frozen-original', + writable: false, + enumerable: false, + configurable: false, + }); + Object.preventExtensions(frozen); + + assert.throws(TypeError, function () { + set.call(frozen, 'updated'); + }, Ctor.name + ': frozen with non-writable own "stack"'); + + verifyProperty(frozen, 'stack', { + value: 'frozen-original', + writable: false, + enumerable: false, + configurable: false, + }); +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-not-a-constructor.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-not-a-constructor.js new file mode 100644 index 00000000000000..4229fb2390aa3f --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-not-a-constructor.js @@ -0,0 +1,28 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + set Error.prototype.stack does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. +includes: [isConstructor.js] +features: [error-stack-accessor, Reflect.construct] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +assert.sameValue( + isConstructor(set), + false, + 'isConstructor(set Error.prototype.stack) must return false' +); + +assert.throws(TypeError, function () { + new set(''); +}); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-own-accessor.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-own-accessor.js new file mode 100644 index 00000000000000..6a8ca2920add6c --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-own-accessor.js @@ -0,0 +1,56 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + When the receiver has an own "stack" accessor property, the setter performs + [[Set]] which invokes the own setter (or throws if the accessor has no + setter). +info: | + set Error.prototype.stack + + [...] + 4. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Error.prototype%, "stack", v). + + SetterThatIgnoresPrototypeProperties ( this, home, p, v ) + + [...] + 3. Let desc be ? this.[[GetOwnProperty]](p). + [...] + 5. Else, + a. Perform ? Set(this, p, v, true). +includes: [nativeErrors.js] +features: [error-stack-accessor] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +for (var i = 0; i < nativeErrors.length; ++i) { + var Ctor = nativeErrors[i]; + + // (a) Own accessor with a setter: the own setter receives v. + var observed; + var withSetter = new Ctor('msg'); + Object.defineProperty(withSetter, 'stack', { + get: function () { return observed; }, + set: function (v) { observed = v; }, + enumerable: false, + configurable: true, + }); + + set.call(withSetter, 'sentinel'); + assert.sameValue(observed, 'sentinel', Ctor.name + ': own setter received the value'); + + // (b) Own accessor with no setter: Set with Throw=true throws TypeError. + var withoutSetter = new Ctor('msg'); + Object.defineProperty(withoutSetter, 'stack', { + get: function () { return 'getter-only'; }, + enumerable: false, + configurable: true, + }); + + assert.throws(TypeError, function () { + set.call(withoutSetter, 'sentinel'); + }, Ctor.name + ': own accessor without a setter'); +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-proxy-trap-rejects.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-proxy-trap-rejects.js new file mode 100644 index 00000000000000..8b35620dc4f8b3 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-proxy-trap-rejects.js @@ -0,0 +1,59 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + When a Proxy receiver's defineProperty trap returns false during the + CreateDataPropertyOrThrow path, or its set trap returns false during the + Set-with-Throw=true path, the setter throws TypeError. +info: | + set Error.prototype.stack + + [...] + 4. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Error.prototype%, "stack", v). + + SetterThatIgnoresPrototypeProperties ( this, home, p, v ) + + [...] + 3. Let desc be ? this.[[GetOwnProperty]](p). + 4. If desc is undefined, then + a. Perform ? CreateDataPropertyOrThrow(this, p, v). + 5. Else, + a. Perform ? Set(this, p, v, true). + + CreateDataPropertyOrThrow ( O, P, V ) + + [...] + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. + + Set ( O, P, V, Throw ) + + [...] + 3. Let success be ? O.[[Set]](P, V, O). + 4. If success is false and Throw is true, throw a TypeError exception. +features: [error-stack-accessor, Proxy] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +// (a) defineProperty trap returns false (no own stack: CreateDataPropertyOrThrow path). +var pA = new Proxy({}, { + defineProperty: function () { + return false; + }, +}); +assert.throws(TypeError, function () { + set.call(pA, 'v'); +}, 'defineProperty returns false'); + +// (b) set trap returns false (own stack present: Set with Throw=true path). +var pB = new Proxy({ stack: 'old' }, { + set: function () { + return false; + }, +}); +assert.throws(TypeError, function () { + set.call(pB, 'v'); +}, 'set trap returns false'); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-proxy-trap-throws.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-proxy-trap-throws.js new file mode 100644 index 00000000000000..89bafda51a094f --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-proxy-trap-throws.js @@ -0,0 +1,58 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + Errors thrown by Proxy traps invoked during the setter propagate out via + the ? abstract operations in SetterThatIgnoresPrototypeProperties. +info: | + set Error.prototype.stack + + [...] + 4. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Error.prototype%, "stack", v). + + SetterThatIgnoresPrototypeProperties ( this, home, p, v ) + + [...] + 3. Let desc be ? this.[[GetOwnProperty]](p). + 4. If desc is undefined, then + a. Perform ? CreateDataPropertyOrThrow(this, p, v). + 5. Else, + a. Perform ? Set(this, p, v, true). +features: [error-stack-accessor, Proxy] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +function Sentinel() {} + +// (a) getOwnPropertyDescriptor trap throws: error propagates from step 3. +var pA = new Proxy({}, { + getOwnPropertyDescriptor: function () { + throw new Sentinel(); + }, +}); +assert.throws(Sentinel, function () { + set.call(pA, 'v'); +}, 'getOwnPropertyDescriptor trap throw'); + +// (b) defineProperty trap throws (no own stack: CreateDataPropertyOrThrow path). +var pB = new Proxy({}, { + defineProperty: function () { + throw new Sentinel(); + }, +}); +assert.throws(Sentinel, function () { + set.call(pB, 'v'); +}, 'defineProperty trap throw'); + +// (c) set trap throws (own stack present: Set path). +var pC = new Proxy({ stack: 'old' }, { + set: function () { + throw new Sentinel(); + }, +}); +assert.throws(Sentinel, function () { + set.call(pC, 'v'); +}, 'set trap throw'); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-proxy-wrapping-prototype.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-proxy-wrapping-prototype.js new file mode 100644 index 00000000000000..061a0964e6a115 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-proxy-wrapping-prototype.js @@ -0,0 +1,66 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + The home-object check uses SameValue on object identity. A Proxy wrapping + %Error.prototype% is not the same object as %Error.prototype% itself, so + step 2 of SetterThatIgnoresPrototypeProperties does not fire; the algorithm + proceeds to consult the proxy's [[GetOwnProperty]] / [[Set]] traps. +info: | + set Error.prototype.stack + + [...] + 4. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Error.prototype%, "stack", v). + + SetterThatIgnoresPrototypeProperties ( this, home, p, v ) + + [...] + 2. If SameValue(this, home) is true, then + a. Throw a TypeError exception. + 3. Let desc be ? this.[[GetOwnProperty]](p). + 4. If desc is undefined, then + a. Perform ? CreateDataPropertyOrThrow(this, p, v). + 5. Else, + a. Perform ? Set(this, p, v, true). +includes: [proxyTrapsHelper.js] +features: [error-stack-accessor, Proxy] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +var trapLog = []; +var p = new Proxy(Error.prototype, allowProxyTraps({ + getOwnPropertyDescriptor: function (t, key) { + trapLog.push(['gOPD', key]); + return Object.getOwnPropertyDescriptor(t, key); + }, + set: function (t, key, value) { + trapLog.push(['set', key, value]); + // Don't actually mutate Error.prototype; just acknowledge. + return true; + } +})); + +// SameValue(p, Error.prototype) is false: a Proxy is a distinct object from +// its target. Step 2 does not throw; the algorithm proceeds to query the +// proxy's traps. +set.call(p, 'sentinel'); + +assert(trapLog.length >= 1, 'at least one trap was invoked'); +assert.sameValue(trapLog[0][0], 'gOPD', 'getOwnPropertyDescriptor trap fired first'); +assert.sameValue(trapLog[0][1], 'stack', 'getOwnPropertyDescriptor trap was called for "stack"'); + +// Error.prototype's own "stack" descriptor is an accessor, so step 5 of +// SetterThatIgnoresPrototypeProperties takes the Set path, which invokes the +// proxy's set trap. +var sawSet = false; +for (var i = 0; i < trapLog.length; ++i) { + if (trapLog[i][0] === 'set') { + sawSet = true; + assert.sameValue(trapLog[i][1], 'stack', 'set trap was called for "stack"'); + assert.sameValue(trapLog[i][2], 'sentinel', 'set trap received the value'); + } +} +assert.sameValue(sawSet, true, 'set trap was invoked'); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-receiver-is-null-proto.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-receiver-is-null-proto.js new file mode 100644 index 00000000000000..c34191be901824 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-receiver-is-null-proto.js @@ -0,0 +1,31 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + The setter installs an own "stack" data property on a null-prototype object. + The setter does not depend on inherited machinery from Object.prototype. +info: | + set Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If v is not a String, throw a TypeError exception. + 4. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Error.prototype%, "stack", v). + 5. Return undefined. +includes: [propertyHelper.js] +features: [error-stack-accessor, __proto__] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +var nullProto = { __proto__: null }; +set.call(nullProto, 'null-proto'); + +verifyProperty(nullProto, 'stack', { + value: 'null-proto', + writable: true, + enumerable: true, + configurable: true, +}); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-receiver-is-other-prototype.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-receiver-is-other-prototype.js new file mode 100644 index 00000000000000..07551914f47426 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-receiver-is-other-prototype.js @@ -0,0 +1,69 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + The SameValue check in SetterThatIgnoresPrototypeProperties is locked to + %Error.prototype% only. Calling the setter with any other prototype object + (NativeError prototypes, AggregateError.prototype, SuppressedError.prototype) + as the receiver does NOT throw via the home-object check; it installs an own + data property on that prototype. +info: | + set Error.prototype.stack + + [...] + 4. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Error.prototype%, "stack", v). + + SetterThatIgnoresPrototypeProperties ( this, home, p, v ) + + [...] + 2. If SameValue(this, home) is true, then + a. NOTE: Throwing here emulates assignment to a non-writable data property + on the home object in strict mode code. + b. Throw a TypeError exception. + 3. Let desc be ? this.[[GetOwnProperty]](p). + 4. If desc is undefined, then + a. Perform ? CreateDataPropertyOrThrow(this, p, v). +includes: [nativeErrors.js, propertyHelper.js] +features: [error-stack-accessor] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +var prototypes = []; +for (var i = 0; i < allErrorConstructors.length; ++i) { + var Ctor = allErrorConstructors[i]; + // Error.prototype is %Error.prototype% itself; that case is covered by setter-receiver-is-prototype.js. + if (Ctor === Error) continue; + prototypes.push([Ctor.name + '.prototype', Ctor.prototype]); +} + +for (var i = 0; i < prototypes.length; ++i) { + var label = prototypes[i][0]; + var proto = prototypes[i][1]; + + assert.sameValue( + Object.getOwnPropertyDescriptor(proto, 'stack'), + undefined, + label + ': precondition: no own "stack" property' + ); + + set.call(proto, 'sentinel-' + label); + + verifyProperty(proto, 'stack', { + value: 'sentinel-' + label, + writable: true, + enumerable: true, + configurable: true, + }); + + // verifyProperty above asserts configurable: true, which causes the helper + // to delete the property as part of its check; confirm the mutation didn't + // leak. + assert.sameValue( + Object.getOwnPropertyDescriptor(proto, 'stack'), + undefined, + label + ': cleanup' + ); +} diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-receiver-is-prototype.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-receiver-is-prototype.js new file mode 100644 index 00000000000000..6dc1736edee536 --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-receiver-is-prototype.js @@ -0,0 +1,48 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + Throws a TypeError if the receiver is %Error.prototype% itself. +info: | + set Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If v is not a String, throw a TypeError exception. + 4. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Error.prototype%, "stack", v). + 5. Return undefined. + + SetterThatIgnoresPrototypeProperties ( this, home, p, v ) + + 1. If this is not an Object, throw a TypeError exception. + 2. If SameValue(this, home) is true, then + a. NOTE: Throwing here emulates assignment to a non-writable data property + on the home object in strict mode code. + b. Throw a TypeError exception. + [...] +features: [error-stack-accessor] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +assert.throws(TypeError, function () { + set.call(Error.prototype, ''); +}, 'set.call(Error.prototype, "")'); + +// Property assignment also throws. The setter throws unconditionally via +// SetterThatIgnoresPrototypeProperties; the throw originates inside the +// accessor function and propagates regardless of the caller's strict-mode +// flag. (test262 runs this file in both strict and sloppy modes by default.) +assert.throws(TypeError, function () { + Error.prototype.stack = ''; +}, 'assignment to Error.prototype.stack'); + +// The accessor descriptor on Error.prototype is unchanged. +var desc = Object.getOwnPropertyDescriptor(Error.prototype, 'stack'); +assert.notSameValue(desc, undefined, 'Error.prototype still has its own "stack" property'); +assert.sameValue(typeof desc.get, 'function', 'getter is still installed'); +assert.sameValue(typeof desc.set, 'function', 'setter is still installed'); +assert.sameValue(desc.value, undefined, 'descriptor has no value (still an accessor)'); +assert.sameValue(desc.writable, undefined, 'descriptor has no writable (still an accessor)'); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-receiver-is-proxy.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-receiver-is-proxy.js new file mode 100644 index 00000000000000..e9482fd517640c --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-receiver-is-proxy.js @@ -0,0 +1,94 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + The setter calls [[GetOwnProperty]] and either [[DefineOwnProperty]] (via + CreateDataPropertyOrThrow) or [[Set]] on the receiver, observably invoking + Proxy traps. +info: | + SetterThatIgnoresPrototypeProperties ( this, home, p, v ) + + [...] + 3. Let desc be ? this.[[GetOwnProperty]](p). + 4. If desc is undefined, then + a. Perform ? CreateDataPropertyOrThrow(this, p, v). + 5. Else, + a. Perform ? Set(this, p, v, true). +includes: [proxyTrapsHelper.js] +features: [error-stack-accessor, Proxy, Reflect] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +// (a) Proxy with no own "stack": getOwnPropertyDescriptor then defineProperty. +// allowProxyTraps throws Test262Error for any other trap (including [[Set]]). +var trapLog = []; +var target1 = {}; +var p1 = new Proxy(target1, allowProxyTraps({ + getOwnPropertyDescriptor: function (t, key) { + trapLog.push(['gOPD', key]); + return Object.getOwnPropertyDescriptor(t, key); + }, + defineProperty: function (t, key, desc) { + trapLog.push(['define', key, desc]); + return Reflect.defineProperty(t, key, desc); + } +}, '(a)')); + +set.call(p1, 'sentinel'); +assert(trapLog.length >= 2, 'at least getOwnPropertyDescriptor and defineProperty were called'); +assert.sameValue(trapLog[0][0], 'gOPD', 'first trap is getOwnPropertyDescriptor'); +assert.sameValue(trapLog[0][1], 'stack', 'getOwnPropertyDescriptor was called for "stack"'); + +var lastDefine = null; +for (var i = 0; i < trapLog.length; ++i) { + if (trapLog[i][0] === 'define') { + lastDefine = trapLog[i]; + } +} +assert.notSameValue(lastDefine, null, 'defineProperty trap was invoked'); +assert.sameValue(lastDefine[1], 'stack', 'defineProperty was called for "stack"'); + +// CreateDataProperty constructs the descriptor record +// { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }; +// FromPropertyDescriptor converts that into a plain Object with exactly those +// four own properties before invoking the defineProperty trap. +var passedDesc = lastDefine[2]; +assert.sameValue(passedDesc.value, 'sentinel', 'descriptor.value'); +assert.sameValue(passedDesc.writable, true, 'descriptor.writable'); +assert.sameValue(passedDesc.enumerable, true, 'descriptor.enumerable'); +assert.sameValue(passedDesc.configurable, true, 'descriptor.configurable'); +assert.sameValue('get' in passedDesc, false, 'descriptor has no get key'); +assert.sameValue('set' in passedDesc, false, 'descriptor has no set key'); +assert.sameValue(target1.stack, 'sentinel', 'value reached the underlying target'); + +// (b) Proxy with own "stack": getOwnPropertyDescriptor then set trap. +// allowProxyTraps throws Test262Error for any other trap (including +// [[DefineOwnProperty]]). +var trapLog2 = []; +var target2 = { stack: 'old' }; +var p2 = new Proxy(target2, allowProxyTraps({ + getOwnPropertyDescriptor: function (t, key) { + trapLog2.push(['gOPD', key]); + return Object.getOwnPropertyDescriptor(t, key); + }, + set: function (t, key, value) { + trapLog2.push(['set', key, value]); + t[key] = value; + return true; + } +}, '(b)')); + +set.call(p2, 'updated'); +var sawSet = false; +for (var j = 0; j < trapLog2.length; ++j) { + if (trapLog2[j][0] === 'set') { + sawSet = true; + assert.sameValue(trapLog2[j][1], 'stack', 'set was called for "stack"'); + assert.sameValue(trapLog2[j][2], 'updated', 'set received the value'); + } +} +assert.sameValue(sawSet, true, 'set trap was invoked'); +assert.sameValue(target2.stack, 'updated', 'value reached the underlying target'); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-this-not-object.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-this-not-object.js new file mode 100644 index 00000000000000..ae86cc280cfe2d --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-this-not-object.js @@ -0,0 +1,49 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + Throws a TypeError if the this value is not an Object. +info: | + set Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. +features: [error-stack-accessor] +---*/ + +var set = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').set; + +assert.sameValue(typeof set, 'function'); + +var badReceivers = [ + ['undefined', undefined], + ['null', null], + ['true', true], + ['false', false], + ['number', 1], + ['string', 's'], + typeof Symbol === 'undefined' ? null : ['symbol', Symbol('s')], + typeof BigInt === 'undefined' ? null : ['bigint', BigInt(0)] +]; + +for (var i = 0; i < badReceivers.length; ++i) { + if (!badReceivers[i]) continue; + var label = badReceivers[i][0]; + var value = badReceivers[i][1]; + assert.throws(TypeError, function () { + set.call(value, ''); + }, label); +} + +// A non-Object this combined with a non-String v throws TypeError. The spec +// runs step 2 (this not Object) before step 3 (v not String), but both steps +// throw TypeError, so the failure is observably the same either way. +assert.throws(TypeError, function () { + set.call(undefined, 0); +}, 'undefined this with non-String v'); + +assert.throws(TypeError, function () { + set.call(null, {}); +}, 'null this with non-String v'); diff --git a/third_party/test262/test/built-ins/Error/prototype/stack/setter-via-assignment.js b/third_party/test262/test/built-ins/Error/prototype/stack/setter-via-assignment.js new file mode 100644 index 00000000000000..20de6e8a54d55f --- /dev/null +++ b/third_party/test262/test/built-ins/Error/prototype/stack/setter-via-assignment.js @@ -0,0 +1,69 @@ +// Copyright (C) 2026 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set-error.prototype.stack +description: > + Property assignment (e.g. err.stack = v) goes through the inherited setter. +info: | + set Error.prototype.stack + + 1. Let E be the this value. + 2. If E is not an Object, throw a TypeError exception. + 3. If v is not a String, throw a TypeError exception. + 4. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Error.prototype%, "stack", v). + 5. Return undefined. +includes: [propertyHelper.js, nativeErrors.js] +features: [error-stack-accessor] +---*/ + +var get = Object.getOwnPropertyDescriptor(Error.prototype, 'stack').get; + +// Plain object inheriting the accessor: assignment installs an own data property. +var plain = Object.create(Error.prototype); +plain.stack = 'sentinel'; + +verifyProperty(plain, 'stack', { + value: 'sentinel', + writable: true, + enumerable: true, + configurable: true, +}); + +for (var i = 0; i < nativeErrors.length; ++i) { + var Ctor = nativeErrors[i]; + var err = new Ctor('msg'); + + // Assigning a non-string still throws TypeError (step 3 of the setter). + // The `err.stack = null` form covered the "release memory" pattern in V8/JSC + // before this proposal; it now throws. + assert.throws(TypeError, function () { + err.stack = null; + }, Ctor.name + ': null assignment'); + + assert.throws(TypeError, function () { + err.stack = 0; + }, Ctor.name + ': numeric assignment'); + + assert.throws(TypeError, function () { + err.stack = undefined; + }, Ctor.name + ': undefined assignment'); + + // The failed setter does not affect the [[ErrorData]] slot: the inherited + // accessor still produces a string (Issue 13: a failed setter must not + // clobber the slot). + assert.sameValue(typeof get.call(err), 'string', Ctor.name + ': [[ErrorData]] preserved across failed setters'); + + // Assigning a string installs/updates the own data property. + err.stack = 'updated'; + assert.sameValue(err.stack, 'updated', Ctor.name + ': string assignment is observable'); +} + +// Assigning to %Error.prototype%.stack always throws, because the setter +// function itself throws via SetterThatIgnoresPrototypeProperties; the throw +// originates inside the accessor function and propagates regardless of the +// caller's strict-mode flag. (test262 runs this file in both strict and +// sloppy modes by default, so the bare assignment exercises both.) +assert.throws(TypeError, function () { + Error.prototype.stack = 'top-level'; +}); diff --git a/third_party/test262/test/built-ins/Iterator/zip/iterator-zip-iteration-strict-checks-remaining-done.js b/third_party/test262/test/built-ins/Iterator/zip/iterator-zip-iteration-strict-checks-remaining-done.js new file mode 100644 index 00000000000000..dbd8ee5097ec2b --- /dev/null +++ b/third_party/test262/test/built-ins/Iterator/zip/iterator-zip-iteration-strict-checks-remaining-done.js @@ -0,0 +1,69 @@ +// Copyright (C) 2026 Test262 Contributors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-iterator.zip +description: > + With mode "strict", when all iterators finish at the same step, the result + iterator completes normally and .next() is called on all of them. +info: | + IteratorZip ( iters, mode, padding, finishResults ) + 3. Let closure be a new Abstract Closure with no parameters that captures + iters, iterCount, openIters, mode, padding, and finishResults, and + performs the following steps when called: + ... + b. Repeat, + ... + iii. For each integer i such that 0 ≤ i < iterCount, in ascending order, do + ... + 1. Let iter be iters[i]. + 2. If iter is null, then + a. Assert: mode is "longest". + ... + 3. Else, + a. Let result be Completion(IteratorStepValue(iter)). + ... + d. If result is done, then + ... + iii. Else if mode is "strict", then + i. If i ≠ 0, then + ... + ii. For each integer k such that 1 ≤ k < iterCount, in ascending order, do + i. Let open be Completion(IteratorStep(iters[k])). + ... + iii. Return ReturnCompletion(undefined). +includes: [compareArray.js] +features: [joint-iteration] +---*/ + +var log = []; + +function makeIter(name, length) { + var count = 0; + return { + next() { + count++; + log.push("call " + name + " next"); + return { done: count > length }; + }, + return() { + log.push("unexpected call " + name + " return"); + } + }; +} + +var it = Iterator.zip([makeIter("a", 2), makeIter("b", 2), makeIter("c", 2)], { mode: "strict" }); + +it.next(); +it.next(); + +log.length = 0; + +var result = it.next(); +assert.sameValue(result.done, true); + +assert.compareArray(log, [ + "call a next", + "call b next", + "call c next", +]); diff --git a/third_party/test262/test/built-ins/Iterator/zip/result-arrays-are-fresh.js b/third_party/test262/test/built-ins/Iterator/zip/result-arrays-are-fresh.js new file mode 100644 index 00000000000000..c6a81bda808b12 --- /dev/null +++ b/third_party/test262/test/built-ins/Iterator/zip/result-arrays-are-fresh.js @@ -0,0 +1,48 @@ +// Copyright (C) 2026 Test262 Contributors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-iterator.zip +description: > + Each call to next() returns a fresh array, not the same object reused. +info: | + IteratorZip ( iters, mode, padding, finishResults ) + ... + 3. Let closure be a new Abstract Closure with no parameters that captures + iters, iterCount, openIters, mode, padding, and finishResults, and + performs the following steps when called: + ... + b. Repeat, + ... + iv. Let results be finishResults(results). + v. Let completion be Completion(Yield(results)). + ... + + Iterator.zip ( iterables [ , options ] ) + ... + 15. Let finishResults be a new Abstract Closure with parameters (results) + that captures nothing and performs the following steps when called: + a. Return CreateArrayFromList(results). + ... +includes: [compareArray.js] +features: [joint-iteration] +---*/ + +var it = Iterator.zip([[1, 2, 3], [4, 5, 6]]); + +var first = it.next(); +assert.sameValue(first.done, false); + +var second = it.next(); +assert.sameValue(second.done, false); + +var third = it.next(); +assert.sameValue(third.done, false); + +assert.notSameValue(first.value, second.value); +assert.notSameValue(second.value, third.value); +assert.notSameValue(first.value, third.value); + +assert.compareArray(first.value, [1, 4]); +assert.compareArray(second.value, [2, 5]); +assert.compareArray(third.value, [3, 6]); diff --git a/third_party/test262/test/built-ins/Iterator/zipKeyed/iterator-zip-iteration-strict-checks-remaining-done.js b/third_party/test262/test/built-ins/Iterator/zipKeyed/iterator-zip-iteration-strict-checks-remaining-done.js new file mode 100644 index 00000000000000..36fc38d8bc28d3 --- /dev/null +++ b/third_party/test262/test/built-ins/Iterator/zipKeyed/iterator-zip-iteration-strict-checks-remaining-done.js @@ -0,0 +1,73 @@ +// Copyright (C) 2026 Test262 Contributors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-iterator.zipkeyed +description: > + With mode "strict", when all iterators finish at the same step, the result + iterator completes normally and .next() is called on all of them. +info: | + IteratorZip ( iters, mode, padding, finishResults ) + 3. Let closure be a new Abstract Closure with no parameters that captures + iters, iterCount, openIters, mode, padding, and finishResults, and + performs the following steps when called: + ... + b. Repeat, + ... + iii. For each integer i such that 0 ≤ i < iterCount, in ascending order, do + ... + 1. Let iter be iters[i]. + 2. If iter is null, then + a. Assert: mode is "longest". + ... + 3. Else, + a. Let result be Completion(IteratorStepValue(iter)). + ... + d. If result is done, then + ... + iii. Else if mode is "strict", then + i. If i ≠ 0, then + ... + ii. For each integer k such that 1 ≤ k < iterCount, in ascending order, do + i. Let open be Completion(IteratorStep(iters[k])). + ... + iii. Return ReturnCompletion(undefined). +includes: [compareArray.js] +features: [joint-iteration] +---*/ + +var log = []; + +function makeIter(name, length) { + var count = 0; + return { + next() { + count++; + log.push("call " + name + " next"); + return { done: count > length }; + }, + return() { + log.push("unexpected call " + name + " return"); + } + }; +} + +var it = Iterator.zipKeyed({ + a: makeIter("a", 2), + b: makeIter("b", 2), + c: makeIter("c", 2), +}, { mode: "strict" }); + +it.next(); +it.next(); + +log.length = 0; + +var result = it.next(); +assert.sameValue(result.done, true); + +assert.compareArray(log, [ + "call a next", + "call b next", + "call c next", +]); diff --git a/third_party/test262/test/built-ins/Iterator/zipKeyed/result-objects-are-fresh.js b/third_party/test262/test/built-ins/Iterator/zipKeyed/result-objects-are-fresh.js new file mode 100644 index 00000000000000..da586ea48cb414 --- /dev/null +++ b/third_party/test262/test/built-ins/Iterator/zipKeyed/result-objects-are-fresh.js @@ -0,0 +1,53 @@ +// Copyright (C) 2026 Test262 Contributors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-iterator.zipkeyed +description: > + Each call to next() returns a fresh result object, not the same object reused. +info: | + IteratorZip ( iters, mode, padding, finishResults ) + ... + 3. Let closure be a new Abstract Closure with no parameters that captures + iters, iterCount, openIters, mode, padding, and finishResults, and + performs the following steps when called: + ... + b. Repeat, + ... + iv. Let results be finishResults(results). + v. Let completion be Completion(Yield(results)). + ... + + Iterator.zipKeyed ( iterables [ , options ] ) + ... + 15. Let finishResults be a new Abstract Closure with parameters (results) that captures keys + and iterCount and performs the following steps when called: + a. Let obj be OrdinaryObjectCreate(null). + b. For each integer i such that 0 ≤ i < iterCount, in ascending order, do + i. Perform ! CreateDataPropertyOrThrow(obj, keys[i], results[i]). + c. Return obj. + ... +features: [joint-iteration] +---*/ + +var it = Iterator.zipKeyed({ a: [1, 2, 3], b: [4, 5, 6] }); + +var first = it.next(); +assert.sameValue(first.done, false); + +var second = it.next(); +assert.sameValue(second.done, false); + +var third = it.next(); +assert.sameValue(third.done, false); + +assert.notSameValue(first.value, second.value); +assert.notSameValue(second.value, third.value); +assert.notSameValue(first.value, third.value); + +assert.sameValue(first.value.a, 1); +assert.sameValue(first.value.b, 4); +assert.sameValue(second.value.a, 2); +assert.sameValue(second.value.b, 5); +assert.sameValue(third.value.a, 3); +assert.sameValue(third.value.b, 6); diff --git a/third_party/test262/test/built-ins/NativeErrors/cause_property_native_error.js b/third_party/test262/test/built-ins/NativeErrors/cause_property_native_error.js index e27e21a75c2263..69c9c9884ef99a 100644 --- a/third_party/test262/test/built-ins/NativeErrors/cause_property_native_error.js +++ b/third_party/test262/test/built-ins/NativeErrors/cause_property_native_error.js @@ -19,13 +19,9 @@ info: | esid: sec-nativeerror features: [error-cause] -includes: [propertyHelper.js] +includes: [propertyHelper.js, nativeErrors.js] ---*/ -var nativeErrors = [ - EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError -]; - for (var i = 0; i < nativeErrors.length; ++i) { var nativeError = nativeErrors[i]; diff --git a/third_party/test262/test/built-ins/NativeErrors/message_property_native_error.js b/third_party/test262/test/built-ins/NativeErrors/message_property_native_error.js index 38c2638b40fc32..cbf4ed7125223e 100644 --- a/third_party/test262/test/built-ins/NativeErrors/message_property_native_error.js +++ b/third_party/test262/test/built-ins/NativeErrors/message_property_native_error.js @@ -12,13 +12,9 @@ info: | c. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}. d. Let status be DefinePropertyOrThrow(O, "message", msgDesc). es6id: 19.5.6.1.1 -includes: [propertyHelper.js] +includes: [propertyHelper.js, nativeErrors.js] ---*/ -var nativeErrors = [ - EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError -]; - for (var i = 0; i < nativeErrors.length; ++i) { var nativeError = nativeErrors[i]; diff --git a/third_party/test262/test/built-ins/Number/MAX_VALUE/value.js b/third_party/test262/test/built-ins/Number/MAX_VALUE/value.js new file mode 100644 index 00000000000000..82f46335d7bea0 --- /dev/null +++ b/third_party/test262/test/built-ins/Number/MAX_VALUE/value.js @@ -0,0 +1,19 @@ +// Copyright (C) 2026 Luna Pfeiffer. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.max_value +description: > + Number.MAX_VALUE is approximately 1.7976931348623157 × 10³⁰⁸ + +---*/ + + +assert.sameValue(typeof Number.MAX_VALUE, "number", "Number.MAX_VALUE should be a number"); +assert(Number.MAX_VALUE > 0, "Number.MAX_VALUE must be positive"); + +assert(Number.MAX_VALUE > Number.MAX_SAFE_INTEGER, "Number.MAX_VALUE should be larger than Number.MAX_SAFE_INTEGER"); +assert(Number.MAX_VALUE < Infinity, "Number.MAX_VALUE should be less than Infinity"); + +assert.sameValue(Number.MAX_VALUE * 2, Infinity, "Number.MAX_VALUE multiplied by 2 should be Infinity"); +assert.sameValue(Number.MAX_VALUE, 1.7976931348623157e+308, "Number.MAX_VALUE should be approximately 1.7976931348623157e+308"); diff --git a/third_party/test262/test/built-ins/Number/MIN_VALUE/value.js b/third_party/test262/test/built-ins/Number/MIN_VALUE/value.js new file mode 100644 index 00000000000000..33b0baae4a0142 --- /dev/null +++ b/third_party/test262/test/built-ins/Number/MIN_VALUE/value.js @@ -0,0 +1,20 @@ +// Copyright (C) 2026 Luna Pfeiffer. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-number.min_value +description: > + Number.MIN_VALUE is approximately 5e-324. We can't directly compare it as the spec states: + + In the IEEE 754-2019 double precision binary representation, the smallest possible value is a denormalized number. + If an implementation does not support denormalized values, the value of Number.MIN_VALUE must be the smallest + non-zero positive value that can actually be represented by the implementation. +---*/ + + +assert.sameValue(typeof Number.MIN_VALUE, "number", "Number.MIN_VALUE should be a number"); +assert(Number.MIN_VALUE > 0, "Number.MIN_VALUE must be positive"); + +assert(Number.MIN_VALUE < Number.EPSILON, "Number.MIN_VALUE should be smaller than Number.EPSILON") + +assert.sameValue(Number.MIN_VALUE / 2, 0, "Number.MIN_VALUE divided by 2 should underflow to 0"); diff --git a/third_party/test262/test/built-ins/Object/isExtensible/15.2.3.13-0-3.js b/third_party/test262/test/built-ins/Object/isExtensible/15.2.3.13-0-3.js index 7e0549a7cf1ae0..70616cdf2a3c8f 100644 --- a/third_party/test262/test/built-ins/Object/isExtensible/15.2.3.13-0-3.js +++ b/third_party/test262/test/built-ins/Object/isExtensible/15.2.3.13-0-3.js @@ -3,7 +3,7 @@ /*--- info: | - A newly created object using the Object contructor has its [[Extensible]] + A newly created object using the Object constructor has its [[Extensible]] property set to true by default (15.2.2.1, step 8). es5id: 15.2.3.13-0-3 description: > diff --git a/third_party/test262/test/built-ins/Promise/allKeyed/capability-executor-not-callable.js b/third_party/test262/test/built-ins/Promise/allKeyed/capability-executor-not-callable.js new file mode 100644 index 00000000000000..54af65cb3fe8d7 --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allKeyed/capability-executor-not-callable.js @@ -0,0 +1,107 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.allkeyed +description: > + Throws a TypeError if either resolve or reject capability is not callable. +info: | + Promise.allKeyed ( promises ) + + ... + 2. Let promiseCapability be ? NewPromiseCapability(C). + + NewPromiseCapability ( C ) + + ... + 4. Let executor be a new built-in function object as defined in + GetCapabilitiesExecutor Functions. + 5. Set the [[Capability]] internal slot of executor to promiseCapability. + 6. Let promise be ? Construct(C, « executor »). + ... + 8. If IsCallable(promiseCapability.[[Resolve]]) is false, throw a TypeError exception. + 9. If IsCallable(promiseCapability.[[Reject]]) is false, throw a TypeError exception. +features: [await-dictionary] +---*/ + +var checkPoint = ""; +function fn1(executor) { + checkPoint += "a"; +} +Object.defineProperty(fn1, 'resolve', { + get() { throw new Test262Error(); } +}); +assert.throws(TypeError, function() { + Promise.allKeyed.call(fn1, {}); +}, "executor not called at all"); +assert.sameValue(checkPoint, "a", "executor not called at all"); + +checkPoint = ""; +function fn2(executor) { + checkPoint += "a"; + executor(); + checkPoint += "b"; +} +Object.defineProperty(fn2, 'resolve', { + get() { throw new Test262Error(); } +}); +assert.throws(TypeError, function() { + Promise.allKeyed.call(fn2, {}); +}, "executor called with no arguments"); +assert.sameValue(checkPoint, "ab", "executor called with no arguments"); + +checkPoint = ""; +function fn3(executor) { + checkPoint += "a"; + executor(undefined, undefined); + checkPoint += "b"; +} +Object.defineProperty(fn3, 'resolve', { + get() { throw new Test262Error(); } +}); +assert.throws(TypeError, function() { + Promise.allKeyed.call(fn3, {}); +}, "executor called with (undefined, undefined)"); +assert.sameValue(checkPoint, "ab", "executor called with (undefined, undefined)"); + +checkPoint = ""; +function fn4(executor) { + checkPoint += "a"; + executor(undefined, function() {}); + checkPoint += "b"; +} +Object.defineProperty(fn4, 'resolve', { + get() { throw new Test262Error(); } +}); +assert.throws(TypeError, function() { + Promise.allKeyed.call(fn4, {}); +}, "executor called with (undefined, function)"); +assert.sameValue(checkPoint, "ab", "executor called with (undefined, function)"); + +checkPoint = ""; +function fn5(executor) { + checkPoint += "a"; + executor(function() {}, undefined); + checkPoint += "b"; +} +Object.defineProperty(fn5, 'resolve', { + get() { throw new Test262Error(); } +}); +assert.throws(TypeError, function() { + Promise.allKeyed.call(fn5, {}); +}, "executor called with (function, undefined)"); +assert.sameValue(checkPoint, "ab", "executor called with (function, undefined)"); + +checkPoint = ""; +function fn6(executor) { + checkPoint += "a"; + executor(123, "invalid value"); + checkPoint += "b"; +} +Object.defineProperty(fn6, 'resolve', { + get() { throw new Test262Error(); } +}); +assert.throws(TypeError, function() { + Promise.allKeyed.call(fn6, {}); +}, "executor called with (Number, String)"); +assert.sameValue(checkPoint, "ab", "executor called with (Number, String)"); diff --git a/third_party/test262/test/built-ins/Promise/allKeyed/ctx-ctor-constructed.js b/third_party/test262/test/built-ins/Promise/allKeyed/ctx-ctor-constructed.js new file mode 100644 index 00000000000000..7b355467cdc53f --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allKeyed/ctx-ctor-constructed.js @@ -0,0 +1,35 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.allkeyed +description: > + Promise.allKeyed invokes the constructor via Construct (not Call), passing + a single executor argument that is a function with length 2. +info: | + Promise.allKeyed ( promises ) + + 1. Let C be the this value. + 2. Let promiseCapability be ? NewPromiseCapability(C). + + NewPromiseCapability ( C ) + + ... + 6. Let promise be Construct(C, « executor »). +features: [await-dictionary, new.target] +---*/ + +var error = new Test262Error(); + +function Constructor(executor) { + if (new.target !== Constructor) { + throw error; + } + assert.sameValue(arguments.length, 1, "expected exactly one argument"); + assert.sameValue(typeof executor, "function", "executor is a function"); + assert.sameValue(executor.length, 2, "executor.length === 2"); + executor(function() {}, function() {}); +} +Constructor.resolve = function(v) { return v; }; + +Promise.allKeyed.call(Constructor, { a: 1 }); diff --git a/third_party/test262/test/built-ins/Promise/allKeyed/ctx-ctor-throws.js b/third_party/test262/test/built-ins/Promise/allKeyed/ctx-ctor-throws.js new file mode 100644 index 00000000000000..9f4efb0f3ec932 --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allKeyed/ctx-ctor-throws.js @@ -0,0 +1,28 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.allkeyed +description: > + Promise.allKeyed invoked on a constructor value that throws an error +info: | + Promise.allKeyed ( promises ) + + 1. Let C be the this value. + 2. Let promiseCapability be ? NewPromiseCapability(C). + + NewPromiseCapability ( C ) + + ... + 6. Let promise be Construct(C, « executor »). + 7. ReturnIfAbrupt(promise). +features: [await-dictionary] +---*/ + +var CustomPromise = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + Promise.allKeyed.call(CustomPromise, {}); +}); diff --git a/third_party/test262/test/built-ins/Promise/allKeyed/getownproperty-not-enumerable.js b/third_party/test262/test/built-ins/Promise/allKeyed/getownproperty-not-enumerable.js new file mode 100644 index 00000000000000..22609abe6cdedd --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allKeyed/getownproperty-not-enumerable.js @@ -0,0 +1,48 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Keys whose property descriptor has [[Enumerable]] false are skipped +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + ... + 6. For each element key of allKeys, do + a. Let desc be ? promises.[[GetOwnProperty]](key). + b. If desc is not undefined and desc.[[Enumerable]] is true, then + ... +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary, Reflect] +---*/ + +var input = Object.create(null); +Object.defineProperty(input, "a", { + value: Promise.resolve(1), + enumerable: true, + configurable: true +}); +Object.defineProperty(input, "b", { + value: Promise.resolve(2), + enumerable: false, + configurable: true +}); +Object.defineProperty(input, "c", { + value: Promise.resolve(3), + enumerable: true, + configurable: true +}); + +asyncTest(function() { + return Promise.allKeyed(input).then(function(result) { + assert.sameValue(Object.getPrototypeOf(result), null, "result is null-prototype"); + var keys = Reflect.ownKeys(result); + assert.sameValue(keys.length, 2, "only enumerable keys are present"); + assert.sameValue(keys[0], "a", "first key"); + assert.sameValue(keys[1], "c", "second key"); + assert.sameValue(result.a, 1, "result.a"); + assert.sameValue(result.c, 3, "result.c"); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allKeyed/getownproperty-returns-undefined.js b/third_party/test262/test/built-ins/Promise/allKeyed/getownproperty-returns-undefined.js new file mode 100644 index 00000000000000..c0d47b2076afd2 --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allKeyed/getownproperty-returns-undefined.js @@ -0,0 +1,32 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Keys where [[GetOwnProperty]] returns undefined are skipped +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + ... + 6. For each element key of allKeys, do + a. Let desc be ? promises.[[GetOwnProperty]](key). + b. If desc is not undefined and desc.[[Enumerable]] is true, then + ... +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary, Proxy, Reflect] +---*/ + +var input = new Proxy({ key: Promise.resolve(1) }, { + getOwnPropertyDescriptor: function() { + return undefined; + } +}); + +asyncTest(function() { + return Promise.allKeyed(input).then(function(result) { + assert.sameValue(Object.getPrototypeOf(result), null, "result is null-prototype"); + assert.sameValue(Reflect.ownKeys(result).length, 0, "no keys in result"); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allKeyed/getownproperty-throws.js b/third_party/test262/test/built-ins/Promise/allKeyed/getownproperty-throws.js new file mode 100644 index 00000000000000..0089026aa34e56 --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allKeyed/getownproperty-throws.js @@ -0,0 +1,39 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Rejects when [[GetOwnProperty]] on the promises object throws +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + ... + 6. For each element key of allKeys, do + a. Let desc be ? promises.[[GetOwnProperty]](key). + ... + + Promise.allKeyed ( promises ) + + ... + 6. Let result be Completion(PerformPromiseAllKeyed(...)). + 7. IfAbruptRejectPromise(result, promiseCapability). +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary, Proxy] +---*/ + +var error = new Test262Error(); +var input = new Proxy({ key: 1 }, { + getOwnPropertyDescriptor: function() { + throw error; + } +}); + +asyncTest(function() { + return Promise.allKeyed(input).then(function() { + throw new Test262Error('The promise should be rejected.'); + }, function(reason) { + assert.sameValue(reason, error); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allKeyed/invoke-resolve-error-reject.js b/third_party/test262/test/built-ins/Promise/allKeyed/invoke-resolve-error-reject.js new file mode 100644 index 00000000000000..33289e4bcbbd97 --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allKeyed/invoke-resolve-error-reject.js @@ -0,0 +1,39 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Calling promiseResolve throws, resulting in promise rejection +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + ... + 6. For each element key of allKeys, do + ... + b. If desc is not undefined and desc.[[Enumerable]] is true, then + ... + iv. Let nextPromise be ? Call(promiseResolve, constructor, « value »). + + Promise.allKeyed ( promises ) + + ... + 6. Let result be Completion(PerformPromiseAllKeyed(...)). + 7. IfAbruptRejectPromise(result, promiseCapability). +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary] +---*/ + +var error = new Test262Error(); +Promise.resolve = function() { + throw error; +}; + +asyncTest(function() { + return Promise.allKeyed({ key: 1 }).then(function() { + throw new Test262Error('The promise should be rejected.'); + }, function(reason) { + assert.sameValue(reason, error); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allKeyed/invoke-resolve-get-error-reject.js b/third_party/test262/test/built-ins/Promise/allKeyed/invoke-resolve-get-error-reject.js new file mode 100644 index 00000000000000..61805ad7ff8b0c --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allKeyed/invoke-resolve-get-error-reject.js @@ -0,0 +1,37 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.allkeyed +description: > + Error retrieving the constructor's `resolve` method rejects the promise +info: | + Promise.allKeyed ( promises ) + + ... + 3. Let promiseResolve be Completion(GetPromiseResolve(C)). + 4. IfAbruptRejectPromise(promiseResolve, promiseCapability). + + GetPromiseResolve ( promiseConstructor ) + + 1. Let promiseResolve be ? Get(promiseConstructor, "resolve"). + ... +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary] +---*/ + +var error = new Test262Error(); +Object.defineProperty(Promise, 'resolve', { + get: function() { + throw error; + } +}); + +asyncTest(function() { + return Promise.allKeyed({ key: 1 }).then(function() { + throw new Test262Error('The promise should be rejected.'); + }, function(reason) { + assert.sameValue(reason, error); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allKeyed/invoke-then-error-reject.js b/third_party/test262/test/built-ins/Promise/allKeyed/invoke-then-error-reject.js new file mode 100644 index 00000000000000..9786dc2ef10e8a --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allKeyed/invoke-then-error-reject.js @@ -0,0 +1,39 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Error thrown when invoking the instance's `then` method (rejecting Promise) +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + ... + 6. For each element key of allKeys, do + ... + b. If desc is not undefined and desc.[[Enumerable]] is true, then + ... + iv. Let nextPromise be ? Call(promiseResolve, constructor, « nextValue »). + ... + xiii. Perform ? Invoke(nextPromise, "then", « onFulfilled, onRejected »). +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary] +---*/ + +var error = new Test262Error(); +var promise = new Promise(function() {}); + +Object.defineProperty(promise, "then", { + value: function() { + throw error; + } +}); + +asyncTest(function() { + return Promise.allKeyed({ key: promise }).then(function() { + throw new Test262Error('The promise should be rejected.'); + }, function(reason) { + assert.sameValue(reason, error); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allKeyed/invoke-then-get-error-reject.js b/third_party/test262/test/built-ins/Promise/allKeyed/invoke-then-get-error-reject.js new file mode 100644 index 00000000000000..833a55a0c343a1 --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allKeyed/invoke-then-get-error-reject.js @@ -0,0 +1,39 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Error thrown when accessing the instance's `then` method (rejecting Promise) +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + ... + 6. For each element key of allKeys, do + ... + b. If desc is not undefined and desc.[[Enumerable]] is true, then + ... + iv. Let nextPromise be ? Call(promiseResolve, constructor, « nextValue »). + ... + xiii. Perform ? Invoke(nextPromise, "then", « onFulfilled, onRejected »). +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary] +---*/ + +var error = new Test262Error(); +var promise = new Promise(function() {}); + +Object.defineProperty(promise, "then", { + get: function() { + throw error; + } +}); + +asyncTest(function() { + return Promise.allKeyed({ key: promise }).then(function() { + throw new Test262Error('The promise should be rejected.'); + }, function(reason) { + assert.sameValue(reason, error); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allKeyed/ownkeys-throws.js b/third_party/test262/test/built-ins/Promise/allKeyed/ownkeys-throws.js new file mode 100644 index 00000000000000..a0814d8a2f51e5 --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allKeyed/ownkeys-throws.js @@ -0,0 +1,37 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Rejects when [[OwnPropertyKeys]] on the promises object throws +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + 1. Let allKeys be ? promises.[[OwnPropertyKeys]](). + ... + + Promise.allKeyed ( promises ) + + ... + 6. Let result be Completion(PerformPromiseAllKeyed(...)). + 7. IfAbruptRejectPromise(result, promiseCapability). +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary, Proxy] +---*/ + +var error = new Test262Error(); +var input = new Proxy({}, { + ownKeys: function() { + throw error; + } +}); + +asyncTest(function() { + return Promise.allKeyed(input).then(function() { + throw new Test262Error('The promise should be rejected.'); + }, function(reason) { + assert.sameValue(reason, error); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allKeyed/reject-last.js b/third_party/test262/test/built-ins/Promise/allKeyed/reject-last.js new file mode 100644 index 00000000000000..ea32775c3c48e2 --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allKeyed/reject-last.js @@ -0,0 +1,46 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Promise.allKeyed rejects when the last promise to settle is rejected +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + ... + 6. For each element key of allKeys, do + ... + b. If desc is not undefined and desc.[[Enumerable]] is true, then + ... + 8. If variant is all, then + a. Let onRejected be resultCapability.[[Reject]]. + ... + 11. Perform ? Invoke(nextPromise, "then", « onFulfilled, onRejected »). +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary] +---*/ + +var error = new Test262Error(); +var resolveFirst, resolveSecond, rejectThird; + +var input = { + first: new Promise(function(resolve) { resolveFirst = resolve; }), + second: new Promise(function(resolve) { resolveSecond = resolve; }), + third: new Promise(function(_, reject) { rejectThird = reject; }) +}; + +var combined = Promise.allKeyed(input); + +resolveFirst('a'); +resolveSecond('b'); +rejectThird(error); + +asyncTest(function() { + return combined.then(function() { + throw new Test262Error('The promise should not be fulfilled.'); + }, function(reason) { + assert.sameValue(reason, error); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allKeyed/reject-second.js b/third_party/test262/test/built-ins/Promise/allKeyed/reject-second.js new file mode 100644 index 00000000000000..f4e923f61fc3ea --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allKeyed/reject-second.js @@ -0,0 +1,46 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Promise.allKeyed rejects when the second promise to settle is rejected +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + ... + 6. For each element key of allKeys, do + ... + b. If desc is not undefined and desc.[[Enumerable]] is true, then + ... + 8. If variant is all, then + a. Let onRejected be resultCapability.[[Reject]]. + ... + 11. Perform ? Invoke(nextPromise, "then", « onFulfilled, onRejected »). +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary] +---*/ + +var error = new Test262Error(); +var resolveFirst, rejectSecond, resolveThird; + +var input = { + first: new Promise(function(resolve) { resolveFirst = resolve; }), + second: new Promise(function(_, reject) { rejectSecond = reject; }), + third: new Promise(function(resolve) { resolveThird = resolve; }) +}; + +var combined = Promise.allKeyed(input); + +resolveFirst('a'); +rejectSecond(error); +resolveThird('c'); + +asyncTest(function() { + return combined.then(function() { + throw new Test262Error('The promise should not be fulfilled.'); + }, function(reason) { + assert.sameValue(reason, error); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allKeyed/resolve-before-loop-exit.js b/third_party/test262/test/built-ins/Promise/allKeyed/resolve-before-loop-exit.js new file mode 100644 index 00000000000000..21d43098db46c9 --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allKeyed/resolve-before-loop-exit.js @@ -0,0 +1,79 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Cannot tamper remainingElementsCount when resolve element functions are called + synchronously from thenables during the loop. +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + ... + 4. Let remainingElementsCount be the Record { [[Value]]: 1 }. + ... + 6. For each element key of allKeys, do + ... + b. If desc is not undefined and desc.[[Enumerable]] is true, then + ... + vi. Let onFulfilled be a new Abstract Closure ... + ... + 5. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1. + 6. If remainingElementsCount.[[Value]] = 0, then + ... + ... + 7. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1. + 8. If remainingElementsCount.[[Value]] = 0, then + ... + NOTE: This can happen even if keys was non-empty if an ill-behaved thenable + synchronously invoked the callback passed to its "then" method. +features: [await-dictionary, Reflect] +---*/ + +var resolveStartCount = 0; +var resolveEndCount = 0; + +function Constructor(executor) { + function resolve(result) { + resolveStartCount += 1; + assert.sameValue(Object.getPrototypeOf(result), null, "result is null-prototype"); + var keys = Reflect.ownKeys(result); + assert.sameValue(keys.length, 3, "result has 3 keys"); + assert.sameValue(result.a, "a-fulfill", "result.a"); + assert.sameValue(result.b, "b-fulfill", "result.b"); + assert.sameValue(result.c, "c-fulfill", "result.c"); + resolveEndCount += 1; + } + executor(resolve, Test262Error.thrower); +} +Constructor.resolve = function(v) { + return v; +}; + +var aOnFulfilled; + +var input = { + a: { + then: function(onFulfilled, onRejected) { + aOnFulfilled = onFulfilled; + } + }, + b: { + then: function(onFulfilled, onRejected) { + aOnFulfilled("a-fulfill"); + onFulfilled("b-fulfill"); + } + }, + c: { + then: function(onFulfilled, onRejected) { + onFulfilled("c-fulfill"); + } + } +}; + +assert.sameValue(resolveStartCount, 0, "resolveStartCount before call to allKeyed()"); + +Promise.allKeyed.call(Constructor, input); + +assert.sameValue(resolveStartCount, 1, "resolve callback entered once"); +assert.sameValue(resolveEndCount, 1, "resolve callback completed once"); diff --git a/third_party/test262/test/built-ins/Promise/allSettledKeyed/capability-executor-not-callable.js b/third_party/test262/test/built-ins/Promise/allSettledKeyed/capability-executor-not-callable.js new file mode 100644 index 00000000000000..b6c1c36ca5d1d8 --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allSettledKeyed/capability-executor-not-callable.js @@ -0,0 +1,107 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.allsettledkeyed +description: > + Throws a TypeError if either resolve or reject capability is not callable. +info: | + Promise.allSettledKeyed ( promises ) + + ... + 2. Let promiseCapability be ? NewPromiseCapability(C). + + NewPromiseCapability ( C ) + + ... + 4. Let executor be a new built-in function object as defined in + GetCapabilitiesExecutor Functions. + 5. Set the [[Capability]] internal slot of executor to promiseCapability. + 6. Let promise be ? Construct(C, « executor »). + ... + 8. If IsCallable(promiseCapability.[[Resolve]]) is false, throw a TypeError exception. + 9. If IsCallable(promiseCapability.[[Reject]]) is false, throw a TypeError exception. +features: [await-dictionary] +---*/ + +var checkPoint = ""; +function fn1(executor) { + checkPoint += "a"; +} +Object.defineProperty(fn1, 'resolve', { + get() { throw new Test262Error(); } +}); +assert.throws(TypeError, function() { + Promise.allSettledKeyed.call(fn1, {}); +}, "executor not called at all"); +assert.sameValue(checkPoint, "a", "executor not called at all"); + +checkPoint = ""; +function fn2(executor) { + checkPoint += "a"; + executor(); + checkPoint += "b"; +} +Object.defineProperty(fn2, 'resolve', { + get() { throw new Test262Error(); } +}); +assert.throws(TypeError, function() { + Promise.allSettledKeyed.call(fn2, {}); +}, "executor called with no arguments"); +assert.sameValue(checkPoint, "ab", "executor called with no arguments"); + +checkPoint = ""; +function fn3(executor) { + checkPoint += "a"; + executor(undefined, undefined); + checkPoint += "b"; +} +Object.defineProperty(fn3, 'resolve', { + get() { throw new Test262Error(); } +}); +assert.throws(TypeError, function() { + Promise.allSettledKeyed.call(fn3, {}); +}, "executor called with (undefined, undefined)"); +assert.sameValue(checkPoint, "ab", "executor called with (undefined, undefined)"); + +checkPoint = ""; +function fn4(executor) { + checkPoint += "a"; + executor(undefined, function() {}); + checkPoint += "b"; +} +Object.defineProperty(fn4, 'resolve', { + get() { throw new Test262Error(); } +}); +assert.throws(TypeError, function() { + Promise.allSettledKeyed.call(fn4, {}); +}, "executor called with (undefined, function)"); +assert.sameValue(checkPoint, "ab", "executor called with (undefined, function)"); + +checkPoint = ""; +function fn5(executor) { + checkPoint += "a"; + executor(function() {}, undefined); + checkPoint += "b"; +} +Object.defineProperty(fn5, 'resolve', { + get() { throw new Test262Error(); } +}); +assert.throws(TypeError, function() { + Promise.allSettledKeyed.call(fn5, {}); +}, "executor called with (function, undefined)"); +assert.sameValue(checkPoint, "ab", "executor called with (function, undefined)"); + +checkPoint = ""; +function fn6(executor) { + checkPoint += "a"; + executor(123, "invalid value"); + checkPoint += "b"; +} +Object.defineProperty(fn6, 'resolve', { + get() { throw new Test262Error(); } +}); +assert.throws(TypeError, function() { + Promise.allSettledKeyed.call(fn6, {}); +}, "executor called with (Number, String)"); +assert.sameValue(checkPoint, "ab", "executor called with (Number, String)"); diff --git a/third_party/test262/test/built-ins/Promise/allSettledKeyed/ctx-ctor-constructed.js b/third_party/test262/test/built-ins/Promise/allSettledKeyed/ctx-ctor-constructed.js new file mode 100644 index 00000000000000..b1964388896ecc --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allSettledKeyed/ctx-ctor-constructed.js @@ -0,0 +1,35 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.allsettledkeyed +description: > + Promise.allSettledKeyed invokes the constructor via Construct (not Call), + passing a single executor argument that is a function with length 2. +info: | + Promise.allSettledKeyed ( promises ) + + 1. Let C be the this value. + 2. Let promiseCapability be ? NewPromiseCapability(C). + + NewPromiseCapability ( C ) + + ... + 6. Let promise be Construct(C, « executor »). +features: [await-dictionary, new.target] +---*/ + +var error = new Test262Error(); + +function Constructor(executor) { + if (new.target !== Constructor) { + throw error; + } + assert.sameValue(arguments.length, 1, "expected exactly one argument"); + assert.sameValue(typeof executor, "function", "executor is a function"); + assert.sameValue(executor.length, 2, "executor.length === 2"); + executor(function() {}, function() {}); +} +Constructor.resolve = function(v) { return v; }; + +Promise.allSettledKeyed.call(Constructor, { a: 1 }); diff --git a/third_party/test262/test/built-ins/Promise/allSettledKeyed/ctx-ctor-throws.js b/third_party/test262/test/built-ins/Promise/allSettledKeyed/ctx-ctor-throws.js new file mode 100644 index 00000000000000..e099c9a3783183 --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allSettledKeyed/ctx-ctor-throws.js @@ -0,0 +1,28 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.allsettledkeyed +description: > + Promise.allSettledKeyed invoked on a constructor value that throws an error +info: | + Promise.allSettledKeyed ( promises ) + + 1. Let C be the this value. + 2. Let promiseCapability be ? NewPromiseCapability(C). + + NewPromiseCapability ( C ) + + ... + 6. Let promise be Construct(C, « executor »). + 7. ReturnIfAbrupt(promise). +features: [await-dictionary] +---*/ + +var CustomPromise = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + Promise.allSettledKeyed.call(CustomPromise, {}); +}); diff --git a/third_party/test262/test/built-ins/Promise/allSettledKeyed/getownproperty-not-enumerable.js b/third_party/test262/test/built-ins/Promise/allSettledKeyed/getownproperty-not-enumerable.js new file mode 100644 index 00000000000000..2fcad73cd545be --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allSettledKeyed/getownproperty-not-enumerable.js @@ -0,0 +1,50 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Keys whose property descriptor has [[Enumerable]] false are skipped +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + ... + 6. For each element key of allKeys, do + a. Let desc be ? promises.[[GetOwnProperty]](key). + b. If desc is not undefined and desc.[[Enumerable]] is true, then + ... +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary, Reflect] +---*/ + +var input = Object.create(null); +Object.defineProperty(input, "a", { + value: Promise.resolve(1), + enumerable: true, + configurable: true +}); +Object.defineProperty(input, "b", { + value: Promise.resolve(2), + enumerable: false, + configurable: true +}); +Object.defineProperty(input, "c", { + value: Promise.resolve(3), + enumerable: true, + configurable: true +}); + +asyncTest(function() { + return Promise.allSettledKeyed(input).then(function(result) { + assert.sameValue(Object.getPrototypeOf(result), null, "result is null-prototype"); + var keys = Reflect.ownKeys(result); + assert.sameValue(keys.length, 2, "only enumerable keys are present"); + assert.sameValue(keys[0], "a", "first key"); + assert.sameValue(keys[1], "c", "second key"); + assert.sameValue(result.a.status, "fulfilled", "result.a.status"); + assert.sameValue(result.a.value, 1, "result.a.value"); + assert.sameValue(result.c.status, "fulfilled", "result.c.status"); + assert.sameValue(result.c.value, 3, "result.c.value"); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allSettledKeyed/getownproperty-returns-undefined.js b/third_party/test262/test/built-ins/Promise/allSettledKeyed/getownproperty-returns-undefined.js new file mode 100644 index 00000000000000..72fc5a5498afac --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allSettledKeyed/getownproperty-returns-undefined.js @@ -0,0 +1,32 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Keys where [[GetOwnProperty]] returns undefined are skipped +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + ... + 6. For each element key of allKeys, do + a. Let desc be ? promises.[[GetOwnProperty]](key). + b. If desc is not undefined and desc.[[Enumerable]] is true, then + ... +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary, Proxy, Reflect] +---*/ + +var input = new Proxy({ key: Promise.resolve(1) }, { + getOwnPropertyDescriptor: function() { + return undefined; + } +}); + +asyncTest(function() { + return Promise.allSettledKeyed(input).then(function(result) { + assert.sameValue(Object.getPrototypeOf(result), null, "result is null-prototype"); + assert.sameValue(Reflect.ownKeys(result).length, 0, "no keys in result"); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allSettledKeyed/getownproperty-throws.js b/third_party/test262/test/built-ins/Promise/allSettledKeyed/getownproperty-throws.js new file mode 100644 index 00000000000000..91cc64af658efc --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allSettledKeyed/getownproperty-throws.js @@ -0,0 +1,39 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Rejects when [[GetOwnProperty]] on the promises object throws +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + ... + 6. For each element key of allKeys, do + a. Let desc be ? promises.[[GetOwnProperty]](key). + ... + + Promise.allSettledKeyed ( promises ) + + ... + 6. Let result be Completion(PerformPromiseAllKeyed(...)). + 7. IfAbruptRejectPromise(result, promiseCapability). +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary, Proxy] +---*/ + +var error = new Test262Error(); +var input = new Proxy({ key: 1 }, { + getOwnPropertyDescriptor: function() { + throw error; + } +}); + +asyncTest(function() { + return Promise.allSettledKeyed(input).then(function() { + throw new Test262Error('The promise should be rejected.'); + }, function(reason) { + assert.sameValue(reason, error); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allSettledKeyed/invoke-resolve-error-reject.js b/third_party/test262/test/built-ins/Promise/allSettledKeyed/invoke-resolve-error-reject.js new file mode 100644 index 00000000000000..d7d53ffbd98631 --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allSettledKeyed/invoke-resolve-error-reject.js @@ -0,0 +1,39 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Calling promiseResolve throws, resulting in promise rejection +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + ... + 6. For each element key of allKeys, do + ... + b. If desc is not undefined and desc.[[Enumerable]] is true, then + ... + iv. Let nextPromise be ? Call(promiseResolve, constructor, « value »). + + Promise.allSettledKeyed ( promises ) + + ... + 6. Let result be Completion(PerformPromiseAllKeyed(...)). + 7. IfAbruptRejectPromise(result, promiseCapability). +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary] +---*/ + +var error = new Test262Error(); +Promise.resolve = function() { + throw error; +}; + +asyncTest(function() { + return Promise.allSettledKeyed({ key: 1 }).then(function() { + throw new Test262Error('The promise should be rejected.'); + }, function(reason) { + assert.sameValue(reason, error); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allSettledKeyed/invoke-resolve-get-error-reject.js b/third_party/test262/test/built-ins/Promise/allSettledKeyed/invoke-resolve-get-error-reject.js new file mode 100644 index 00000000000000..4fc59bd6ae183d --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allSettledKeyed/invoke-resolve-get-error-reject.js @@ -0,0 +1,37 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.allsettledkeyed +description: > + Error retrieving the constructor's `resolve` method rejects the promise +info: | + Promise.allSettledKeyed ( promises ) + + ... + 3. Let promiseResolve be Completion(GetPromiseResolve(C)). + 4. IfAbruptRejectPromise(promiseResolve, promiseCapability). + + GetPromiseResolve ( promiseConstructor ) + + 1. Let promiseResolve be ? Get(promiseConstructor, "resolve"). + ... +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary] +---*/ + +var error = new Test262Error(); +Object.defineProperty(Promise, 'resolve', { + get: function() { + throw error; + } +}); + +asyncTest(function() { + return Promise.allSettledKeyed({ key: 1 }).then(function() { + throw new Test262Error('The promise should be rejected.'); + }, function(reason) { + assert.sameValue(reason, error); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allSettledKeyed/invoke-then-error-reject.js b/third_party/test262/test/built-ins/Promise/allSettledKeyed/invoke-then-error-reject.js new file mode 100644 index 00000000000000..ce6bedb719b601 --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allSettledKeyed/invoke-then-error-reject.js @@ -0,0 +1,39 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Error thrown when invoking the instance's `then` method (rejecting Promise) +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + ... + 6. For each element key of allKeys, do + ... + b. If desc is not undefined and desc.[[Enumerable]] is true, then + ... + iv. Let nextPromise be ? Call(promiseResolve, constructor, « nextValue »). + ... + xiii. Perform ? Invoke(nextPromise, "then", « onFulfilled, onRejected »). +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary] +---*/ + +var error = new Test262Error(); +var promise = new Promise(function() {}); + +Object.defineProperty(promise, "then", { + value: function() { + throw error; + } +}); + +asyncTest(function() { + return Promise.allSettledKeyed({ key: promise }).then(function() { + throw new Test262Error('The promise should be rejected.'); + }, function(reason) { + assert.sameValue(reason, error); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allSettledKeyed/invoke-then-get-error-reject.js b/third_party/test262/test/built-ins/Promise/allSettledKeyed/invoke-then-get-error-reject.js new file mode 100644 index 00000000000000..405892b3b04b24 --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allSettledKeyed/invoke-then-get-error-reject.js @@ -0,0 +1,39 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Error thrown when accessing the instance's `then` method (rejecting Promise) +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + ... + 6. For each element key of allKeys, do + ... + b. If desc is not undefined and desc.[[Enumerable]] is true, then + ... + iv. Let nextPromise be ? Call(promiseResolve, constructor, « nextValue »). + ... + xiii. Perform ? Invoke(nextPromise, "then", « onFulfilled, onRejected »). +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary] +---*/ + +var error = new Test262Error(); +var promise = new Promise(function() {}); + +Object.defineProperty(promise, "then", { + get: function() { + throw error; + } +}); + +asyncTest(function() { + return Promise.allSettledKeyed({ key: promise }).then(function() { + throw new Test262Error('The promise should be rejected.'); + }, function(reason) { + assert.sameValue(reason, error); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allSettledKeyed/ownkeys-throws.js b/third_party/test262/test/built-ins/Promise/allSettledKeyed/ownkeys-throws.js new file mode 100644 index 00000000000000..b9bd51a41c3a1b --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allSettledKeyed/ownkeys-throws.js @@ -0,0 +1,37 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Rejects when [[OwnPropertyKeys]] on the promises object throws +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + 1. Let allKeys be ? promises.[[OwnPropertyKeys]](). + ... + + Promise.allSettledKeyed ( promises ) + + ... + 6. Let result be Completion(PerformPromiseAllKeyed(...)). + 7. IfAbruptRejectPromise(result, promiseCapability). +includes: [asyncHelpers.js] +flags: [async] +features: [await-dictionary, Proxy] +---*/ + +var error = new Test262Error(); +var input = new Proxy({}, { + ownKeys: function() { + throw error; + } +}); + +asyncTest(function() { + return Promise.allSettledKeyed(input).then(function() { + throw new Test262Error('The promise should be rejected.'); + }, function(reason) { + assert.sameValue(reason, error); + }); +}); diff --git a/third_party/test262/test/built-ins/Promise/allSettledKeyed/resolve-before-loop-exit.js b/third_party/test262/test/built-ins/Promise/allSettledKeyed/resolve-before-loop-exit.js new file mode 100644 index 00000000000000..ca3c117b6cebe7 --- /dev/null +++ b/third_party/test262/test/built-ins/Promise/allSettledKeyed/resolve-before-loop-exit.js @@ -0,0 +1,82 @@ +// Copyright (C) 2026 Danial Asaria (Bloomberg LP). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-performpromiseallkeyed +description: > + Cannot tamper remainingElementsCount when resolve element functions are called + synchronously from thenables during the loop. +info: | + PerformPromiseAllKeyed ( variant, promises, constructor, resultCapability, promiseResolve ) + + ... + 4. Let remainingElementsCount be the Record { [[Value]]: 1 }. + ... + 6. For each element key of allKeys, do + ... + b. If desc is not undefined and desc.[[Enumerable]] is true, then + ... + vi. Let onFulfilled be a new Abstract Closure ... + ... + 5. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1. + 6. If remainingElementsCount.[[Value]] = 0, then + ... + ... + 7. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1. + 8. If remainingElementsCount.[[Value]] = 0, then + ... + NOTE: This can happen even if keys was non-empty if an ill-behaved thenable + synchronously invoked the callback passed to its "then" method. +features: [await-dictionary, Reflect] +---*/ + +var resolveStartCount = 0; +var resolveEndCount = 0; + +function Constructor(executor) { + function resolve(result) { + resolveStartCount += 1; + assert.sameValue(Object.getPrototypeOf(result), null, "result is null-prototype"); + var keys = Reflect.ownKeys(result); + assert.sameValue(keys.length, 3, "result has 3 keys"); + assert.sameValue(result.a.status, "fulfilled", "result.a.status"); + assert.sameValue(result.a.value, "a-fulfill", "result.a.value"); + assert.sameValue(result.b.status, "fulfilled", "result.b.status"); + assert.sameValue(result.b.value, "b-fulfill", "result.b.value"); + assert.sameValue(result.c.status, "fulfilled", "result.c.status"); + assert.sameValue(result.c.value, "c-fulfill", "result.c.value"); + resolveEndCount += 1; + } + executor(resolve, Test262Error.thrower); +} +Constructor.resolve = function(v) { + return v; +}; + +var aOnFulfilled; + +var input = { + a: { + then: function(onFulfilled, onRejected) { + aOnFulfilled = onFulfilled; + } + }, + b: { + then: function(onFulfilled, onRejected) { + aOnFulfilled("a-fulfill"); + onFulfilled("b-fulfill"); + } + }, + c: { + then: function(onFulfilled, onRejected) { + onFulfilled("c-fulfill"); + } + } +}; + +assert.sameValue(resolveStartCount, 0, "resolveStartCount before call to allSettledKeyed()"); + +Promise.allSettledKeyed.call(Constructor, input); + +assert.sameValue(resolveStartCount, 1, "resolve callback entered once"); +assert.sameValue(resolveEndCount, 1, "resolve callback completed once"); diff --git a/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/exact-multiple-of-larger-unit-plaindate.js b/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/exact-multiple-of-larger-unit-plaindate.js new file mode 100644 index 00000000000000..0a3adc763daa96 --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/exact-multiple-of-larger-unit-plaindate.js @@ -0,0 +1,41 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.round +description: > + Rounding does not add a spurious extra smallestUnit when the difference has + zero of the smallestUnit +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const relativeTo = new Temporal.PlainDate(2012, 1, 1); + +for (const roundingMode of ["ceil", "floor", "expand", "halfCeil", "halfFloor", "halfEven", "halfExpand", "halfTrunc", "trunc"]) { + TemporalHelpers.assertDuration( + new Temporal.Duration(0, 0, 0, 31).round( + { smallestUnit: "weeks", largestUnit: "months", roundingMode, relativeTo }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + `P31D weeks..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + new Temporal.Duration(1).round( + { smallestUnit: "months", largestUnit: "years", roundingMode, relativeTo }), + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `P1Y months..years ${roundingMode}` + ); + + TemporalHelpers.assertDuration( + new Temporal.Duration(0, 0, 0, -31).round( + { smallestUnit: "weeks", largestUnit: "months", roundingMode, relativeTo }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + `-P31D weeks..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + new Temporal.Duration(-1).round( + { smallestUnit: "months", largestUnit: "years", roundingMode, relativeTo }), + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1Y months..years ${roundingMode}` + ); +} diff --git a/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/exact-multiple-of-larger-unit-zoned.js b/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/exact-multiple-of-larger-unit-zoned.js new file mode 100644 index 00000000000000..6618591ee185ff --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/exact-multiple-of-larger-unit-zoned.js @@ -0,0 +1,77 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.round +description: > + Rounding does not add a spurious extra smallestUnit when the difference has + zero of the smallestUnit +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const relativeTo = Temporal.ZonedDateTime.from("2012-01-01T12:00:00+00:00[UTC]"); + +for (const roundingMode of ["ceil", "floor", "expand", "halfCeil", "halfFloor", "halfEven", "halfExpand", "halfTrunc", "trunc"]) { + TemporalHelpers.assertDuration( + new Temporal.Duration(0, 0, 0, 7).round( + { smallestUnit: "days", largestUnit: "weeks", roundingMode, relativeTo }), + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + `P7D days..weeks ${roundingMode}` + ); + TemporalHelpers.assertDuration( + new Temporal.Duration(0, 0, 0, 31).round( + { smallestUnit: "days", largestUnit: "months", roundingMode, relativeTo }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + `P31D days..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + new Temporal.Duration(1).round( + { smallestUnit: "days", largestUnit: "years", roundingMode, relativeTo }), + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `P1Y days..years ${roundingMode}` + ); + TemporalHelpers.assertDuration( + new Temporal.Duration(0, 0, 0, 31).round( + { smallestUnit: "weeks", largestUnit: "months", roundingMode, relativeTo }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + `P31D weeks..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + new Temporal.Duration(1).round( + { smallestUnit: "months", largestUnit: "years", roundingMode, relativeTo }), + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `P1Y months..years ${roundingMode}` + ); + + TemporalHelpers.assertDuration( + new Temporal.Duration(0, 0, 0, -7).round( + { smallestUnit: "days", largestUnit: "weeks", roundingMode, relativeTo }), + 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, + `-P7D days..weeks ${roundingMode}` + ); + TemporalHelpers.assertDuration( + new Temporal.Duration(0, 0, 0, -31).round( + { smallestUnit: "days", largestUnit: "months", roundingMode, relativeTo }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + `-P31D days..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + new Temporal.Duration(-1).round( + { smallestUnit: "days", largestUnit: "years", roundingMode, relativeTo }), + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1Y days..years ${roundingMode}` + ); + TemporalHelpers.assertDuration( + new Temporal.Duration(0, 0, 0, -31).round( + { smallestUnit: "weeks", largestUnit: "months", roundingMode, relativeTo }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + `-P31D weeks..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + new Temporal.Duration(-1).round( + { smallestUnit: "months", largestUnit: "years", roundingMode, relativeTo }), + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1Y months..years ${roundingMode}` + ); +} diff --git a/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/relativeto-plaindate-large-time-component-out-of-range.js b/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/relativeto-plaindate-large-time-component-out-of-range.js new file mode 100644 index 00000000000000..8c73d1d67b4ed3 --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/relativeto-plaindate-large-time-component-out-of-range.js @@ -0,0 +1,22 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.round +description: > + Duration with an overly large time component rounded to a calendar unit + relative to a PlainDate +info: | + 28.d. Let _dateDuration_ be ? AdjustDateDurationRecord( + _internalDuration_.[[Date]], _targetTime_.[[Days]]). +features: [Temporal] +---*/ + +const relativeTo = new Temporal.PlainDate(2020, 1, 1); + +[Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER].forEach((seconds) => { + const d = new Temporal.Duration(0, 0, 0, 0, 0, 0, seconds); + assert.throws(RangeError, () => d.round({ smallestUnit: "year", relativeTo })); + assert.throws(RangeError, () => d.round({ smallestUnit: "month", relativeTo })); + assert.throws(RangeError, () => d.round({ smallestUnit: "week", relativeTo })); +}); diff --git a/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/relativeto-rounding-near-minimum-date.js b/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/relativeto-rounding-near-minimum-date.js new file mode 100644 index 00000000000000..faf0baa75d9284 --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/relativeto-rounding-near-minimum-date.js @@ -0,0 +1,26 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.round +description: > + Rounding with largestUnit "year" with relativeTo near the earlier date limit + correctly rounds the day even though year boundaries fall outside the valid + range +info: Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=2036259 +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const relativeTo = new Temporal.PlainDate(-271821, 5, 19); +const duration = new Temporal.Duration(0, 0, 0, 0, -23); + +const result = duration.round({ + largestUnit: "year", + smallestUnit: "day", + roundingMode: "expand", + relativeTo, +}); + +TemporalHelpers.assertDuration(result, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, + "-23 hours rounds to -1 day near minimum date"); diff --git a/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-large-time-component-out-of-range.js b/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-large-time-component-out-of-range.js new file mode 100644 index 00000000000000..52fee7c3456f7e --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-large-time-component-out-of-range.js @@ -0,0 +1,22 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.round +description: > + Duration with an overly large time component rounded to a calendar unit + relative to a ZonedDateTime +info: | + 27.e. Let _targetEpochNs_ be ? AddZonedDateTime(_relativeEpochNs_, _timeZone_, + _calendar_, _internalDuration_, ~constrain~). +features: [Temporal] +---*/ + +const relativeTo = new Temporal.ZonedDateTime(0n, "UTC"); + +[Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER].forEach((seconds) => { + const d = new Temporal.Duration(0, 0, 0, 0, 0, 0, seconds); + assert.throws(RangeError, () => d.round({ smallestUnit: "year", relativeTo })); + assert.throws(RangeError, () => d.round({ smallestUnit: "month", relativeTo })); + assert.throws(RangeError, () => d.round({ smallestUnit: "week", relativeTo })); +}); diff --git a/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/rounding-increment-relativeto.js b/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/rounding-increment-relativeto.js index 762be1f1d5bba1..1e66b492d05f40 100644 --- a/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/rounding-increment-relativeto.js +++ b/third_party/test262/test/built-ins/Temporal/Duration/prototype/round/rounding-increment-relativeto.js @@ -39,8 +39,3 @@ TemporalHelpers.assertDuration(new Temporal.Duration(0, 1, 0, 30).round({ roundingIncrement: 2, relativeTo: new Temporal.PlainDate(1970, 7, 31) }), 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, `1m30d to 2m with relativeTo 1970-07-31`); -TemporalHelpers.assertDuration(new Temporal.Duration(0, 1, 0, 30).round({ - smallestUnit: "months", - roundingIncrement: 2, - relativeTo: Temporal.ZonedDateTime.from('2025-03-09T03:00:00-07:00[America/Vancouver]') -}), 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, `1m30d to 2m with relativeTo 2025-03-09T03:00:00-07:00[America/Vancouver]`); diff --git a/third_party/test262/test/built-ins/Temporal/Duration/prototype/total/relativeto-plaindate-large-time-component-out-of-range.js b/third_party/test262/test/built-ins/Temporal/Duration/prototype/total/relativeto-plaindate-large-time-component-out-of-range.js new file mode 100644 index 00000000000000..220eec68218f8c --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/Duration/prototype/total/relativeto-plaindate-large-time-component-out-of-range.js @@ -0,0 +1,22 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.total +description: > + Duration with an overly large time component total of a calendar unit relative + to a PlainDate +info: | + 13.d. Let _dateDuration_ be ? AdjustDateDurationRecord( + _internalDuration_.[[Date]], _targetTime_.[[Days]]). +features: [Temporal] +---*/ + +const relativeTo = new Temporal.PlainDate(2020, 1, 1); + +[Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER].forEach((seconds) => { + const d = new Temporal.Duration(0, 0, 0, 0, 0, 0, seconds); + assert.throws(RangeError, () => d.total({ unit: "year", relativeTo })); + assert.throws(RangeError, () => d.total({ unit: "month", relativeTo })); + assert.throws(RangeError, () => d.total({ unit: "week", relativeTo })); +}); diff --git a/third_party/test262/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-large-time-component-out-of-range.js b/third_party/test262/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-large-time-component-out-of-range.js new file mode 100644 index 00000000000000..0457eaf86b8838 --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-large-time-component-out-of-range.js @@ -0,0 +1,22 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.total +description: > + Duration with an overly large time component total of a calendar unit relative + to a ZonedDateTime +info: | + 12.e. Let _targetEpochNs_ be ? AddZonedDateTime(_relativeEpochNs_, _timeZone_, + _calendar_, _internalDuration_, ~constrain~). +features: [Temporal] +---*/ + +const relativeTo = new Temporal.ZonedDateTime(0n, "UTC"); + +[Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER].forEach((seconds) => { + const d = new Temporal.Duration(0, 0, 0, 0, 0, 0, seconds); + assert.throws(RangeError, () => d.total({ unit: "year", relativeTo })); + assert.throws(RangeError, () => d.total({ unit: "month", relativeTo })); + assert.throws(RangeError, () => d.total({ unit: "week", relativeTo })); +}); diff --git a/third_party/test262/test/built-ins/Temporal/PlainDate/prototype/since/exact-multiple-of-larger-unit.js b/third_party/test262/test/built-ins/Temporal/PlainDate/prototype/since/exact-multiple-of-larger-unit.js new file mode 100644 index 00000000000000..b2e89336e19555 --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/PlainDate/prototype/since/exact-multiple-of-larger-unit.js @@ -0,0 +1,41 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.since +description: > + Rounding up does not add a spurious extra smallestUnit when the difference has + zero of the smallestUnit +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const start = new Temporal.PlainDate(2012, 1, 1); + +for (const roundingMode of ["ceil", "floor", "expand", "halfCeil", "halfFloor", "halfEven", "halfExpand", "halfTrunc", "trunc"]) { + TemporalHelpers.assertDuration( + new Temporal.PlainDate(2012, 2, 1).since(start, + { smallestUnit: "weeks", largestUnit: "months", roundingMode }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + `P1M weeks..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(2013, 1, 1).since(start, + { smallestUnit: "months", largestUnit: "years", roundingMode }), + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `P1Y months..years ${roundingMode}` + ); + + TemporalHelpers.assertDuration( + new Temporal.PlainDate(2011, 12, 1).since(start, + { smallestUnit: "weeks", largestUnit: "months", roundingMode }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1M weeks..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(2011, 1, 1).since(start, + { smallestUnit: "months", largestUnit: "years", roundingMode }), + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1Y months..years ${roundingMode}` + ); +} diff --git a/third_party/test262/test/built-ins/Temporal/PlainDate/prototype/since/rounding-near-minimum-date.js b/third_party/test262/test/built-ins/Temporal/PlainDate/prototype/since/rounding-near-minimum-date.js new file mode 100644 index 00000000000000..276cf600ca541c --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/PlainDate/prototype/since/rounding-near-minimum-date.js @@ -0,0 +1,25 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.since +description: > + Rounding with largestUnit "year" near the earlier date limit correctly rounds + the day increment even though year boundaries fall outside the valid range +info: Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=2036259 +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const d1 = new Temporal.PlainDate(-271821, 5, 19); +const d2 = new Temporal.PlainDate(-271821, 5, 18); + +const result = d1.since(d2, { + largestUnit: "year", + smallestUnit: "day", + roundingIncrement: 2, + roundingMode: "expand", +}); + +TemporalHelpers.assertDuration(result, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, + "expand rounding of 1 day to increment 2 near minimum date gives 2 days"); diff --git a/third_party/test262/test/built-ins/Temporal/PlainDate/prototype/until/exact-multiple-of-larger-unit.js b/third_party/test262/test/built-ins/Temporal/PlainDate/prototype/until/exact-multiple-of-larger-unit.js new file mode 100644 index 00000000000000..6aea0315be7e9c --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/PlainDate/prototype/until/exact-multiple-of-larger-unit.js @@ -0,0 +1,41 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.until +description: > + Rounding up does not add a spurious extra smallestUnit when the difference has + zero of the smallestUnit +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const start = new Temporal.PlainDate(2012, 1, 1); + +for (const roundingMode of ["ceil", "floor", "expand", "halfCeil", "halfFloor", "halfEven", "halfExpand", "halfTrunc", "trunc"]) { + TemporalHelpers.assertDuration( + start.until(new Temporal.PlainDate(2012, 2, 1), + { smallestUnit: "weeks", largestUnit: "months", roundingMode }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + `P1M weeks..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + start.until(new Temporal.PlainDate(2013, 1, 1), + { smallestUnit: "months", largestUnit: "years", roundingMode }), + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `P1Y months..years ${roundingMode}` + ); + + TemporalHelpers.assertDuration( + start.until(new Temporal.PlainDate(2011, 12, 1), + { smallestUnit: "weeks", largestUnit: "months", roundingMode }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1M weeks..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + start.until(new Temporal.PlainDate(2011, 1, 1), + { smallestUnit: "months", largestUnit: "years", roundingMode }), + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1Y months..years ${roundingMode}` + ); +} diff --git a/third_party/test262/test/built-ins/Temporal/PlainDate/prototype/until/rounding-near-minimum-date.js b/third_party/test262/test/built-ins/Temporal/PlainDate/prototype/until/rounding-near-minimum-date.js new file mode 100644 index 00000000000000..b91ca0acd255c7 --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/PlainDate/prototype/until/rounding-near-minimum-date.js @@ -0,0 +1,25 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.until +description: > + Rounding with largestUnit "year" near the earlier date limit correctly rounds + the day increment even though year boundaries fall outside the valid range +info: Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=2036259 +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const d1 = new Temporal.PlainDate(-271821, 5, 19); +const d2 = new Temporal.PlainDate(-271821, 5, 18); + +const result = d1.until(d2, { + largestUnit: "year", + smallestUnit: "day", + roundingIncrement: 2, + roundingMode: "expand", +}); + +TemporalHelpers.assertDuration(result, 0, 0, 0, -2, 0, 0, 0, 0, 0, 0, + "expand rounding of -1 day to increment 2 near minimum date gives -2 days"); diff --git a/third_party/test262/test/built-ins/Temporal/PlainDateTime/prototype/since/exact-multiple-of-larger-unit.js b/third_party/test262/test/built-ins/Temporal/PlainDateTime/prototype/since/exact-multiple-of-larger-unit.js new file mode 100644 index 00000000000000..765a351805404c --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/PlainDateTime/prototype/since/exact-multiple-of-larger-unit.js @@ -0,0 +1,41 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.since +description: > + Rounding up does not add a spurious extra smallestUnit when the difference has + zero of the smallestUnit +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const start = new Temporal.PlainDateTime(2012, 1, 1, 12); + +for (const roundingMode of ["ceil", "floor", "expand", "halfCeil", "halfFloor", "halfEven", "halfExpand", "halfTrunc", "trunc"]) { + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(2012, 2, 1, 12).since(start, + { smallestUnit: "weeks", largestUnit: "months", roundingMode }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + `P1M weeks..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(2013, 1, 1, 12).since(start, + { smallestUnit: "months", largestUnit: "years", roundingMode }), + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `P1Y months..years ${roundingMode}` + ); + + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(2011, 12, 1, 12).since(start, + { smallestUnit: "weeks", largestUnit: "months", roundingMode }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1M weeks..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(2011, 1, 1, 12).since(start, + { smallestUnit: "months", largestUnit: "years", roundingMode }), + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1Y months..years ${roundingMode}` + ); +} diff --git a/third_party/test262/test/built-ins/Temporal/PlainDateTime/prototype/since/rounding-near-minimum-date.js b/third_party/test262/test/built-ins/Temporal/PlainDateTime/prototype/since/rounding-near-minimum-date.js new file mode 100644 index 00000000000000..2d933ab399f588 --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/PlainDateTime/prototype/since/rounding-near-minimum-date.js @@ -0,0 +1,25 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.since +description: > + Rounding with largestUnit "year" near the earlier date limit correctly rounds + the day increment even though year boundaries fall outside the valid range +info: Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=2036259 +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dt1 = new Temporal.PlainDateTime(-271821, 5, 19, 0, 0, 0); +const dt2 = new Temporal.PlainDateTime(-271821, 5, 18, 0, 0, 0); + +const result = dt1.since(dt2, { + largestUnit: "year", + smallestUnit: "day", + roundingIncrement: 2, + roundingMode: "expand", +}); + +TemporalHelpers.assertDuration(result, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, + "expand rounding of 1 day to increment 2 near minimum date gives 2 days"); diff --git a/third_party/test262/test/built-ins/Temporal/PlainDateTime/prototype/until/exact-multiple-of-larger-unit.js b/third_party/test262/test/built-ins/Temporal/PlainDateTime/prototype/until/exact-multiple-of-larger-unit.js new file mode 100644 index 00000000000000..f36fba39fc6615 --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/PlainDateTime/prototype/until/exact-multiple-of-larger-unit.js @@ -0,0 +1,41 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.until +description: > + Rounding up does not add a spurious extra smallestUnit when the difference has + zero of the smallestUnit +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const start = new Temporal.PlainDateTime(2012, 1, 1, 12); + +for (const roundingMode of ["ceil", "floor", "expand", "halfCeil", "halfFloor", "halfEven", "halfExpand", "halfTrunc", "trunc"]) { + TemporalHelpers.assertDuration( + start.until(new Temporal.PlainDateTime(2012, 2, 1, 12), + { smallestUnit: "weeks", largestUnit: "months", roundingMode }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + `P1M weeks..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + start.until(new Temporal.PlainDateTime(2013, 1, 1, 12), + { smallestUnit: "months", largestUnit: "years", roundingMode }), + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `P1Y months..years ${roundingMode}` + ); + + TemporalHelpers.assertDuration( + start.until(new Temporal.PlainDateTime(2011, 12, 1, 12), + { smallestUnit: "weeks", largestUnit: "months", roundingMode }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1M weeks..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + start.until(new Temporal.PlainDateTime(2011, 1, 1, 12), + { smallestUnit: "months", largestUnit: "years", roundingMode }), + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1Y months..years ${roundingMode}` + ); +} diff --git a/third_party/test262/test/built-ins/Temporal/PlainDateTime/prototype/until/rounding-near-minimum-date.js b/third_party/test262/test/built-ins/Temporal/PlainDateTime/prototype/until/rounding-near-minimum-date.js new file mode 100644 index 00000000000000..85b85b55a325f5 --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/PlainDateTime/prototype/until/rounding-near-minimum-date.js @@ -0,0 +1,25 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.until +description: > + Rounding with largestUnit "year" near the earlier date limit correctly rounds + the day increment even though year boundaries fall outside the valid range +info: Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=2036259 +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dt1 = new Temporal.PlainDateTime(-271821, 5, 19, 0, 0, 0); +const dt2 = new Temporal.PlainDateTime(-271821, 5, 18, 0, 0, 0); + +const result = dt1.until(dt2, { + largestUnit: "year", + smallestUnit: "day", + roundingIncrement: 2, + roundingMode: "expand", +}); + +TemporalHelpers.assertDuration(result, 0, 0, 0, -2, 0, 0, 0, 0, 0, 0, + "expand rounding of -1 day to increment 2 near minimum date gives -2 days"); diff --git a/third_party/test262/test/built-ins/Temporal/PlainYearMonth/prototype/since/exact-multiple-of-larger-unit.js b/third_party/test262/test/built-ins/Temporal/PlainYearMonth/prototype/since/exact-multiple-of-larger-unit.js new file mode 100644 index 00000000000000..d181c4c1dda0cc --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/PlainYearMonth/prototype/since/exact-multiple-of-larger-unit.js @@ -0,0 +1,29 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.since +description: > + Rounding up does not add a spurious extra smallestUnit when the difference has + zero of the smallestUnit +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const start = new Temporal.PlainYearMonth(2012, 1); + +for (const roundingMode of ["ceil", "floor", "expand", "halfCeil", "halfFloor", "halfEven", "halfExpand", "halfTrunc", "trunc"]) { + TemporalHelpers.assertDuration( + new Temporal.PlainYearMonth(2013, 1).since(start, + { smallestUnit: "months", largestUnit: "years", roundingMode, roundingIncrement: 2 }), + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `P1Y months..years ${roundingMode}` + ); + + TemporalHelpers.assertDuration( + new Temporal.PlainYearMonth(2011, 1).since(start, + { smallestUnit: "months", largestUnit: "years", roundingMode, roundingIncrement: 2 }), + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1Y months..years ${roundingMode}` + ); +} diff --git a/third_party/test262/test/built-ins/Temporal/PlainYearMonth/prototype/until/exact-multiple-of-larger-unit.js b/third_party/test262/test/built-ins/Temporal/PlainYearMonth/prototype/until/exact-multiple-of-larger-unit.js new file mode 100644 index 00000000000000..9bdd5b6767c11b --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/PlainYearMonth/prototype/until/exact-multiple-of-larger-unit.js @@ -0,0 +1,29 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.until +description: > + Rounding up does not add a spurious extra smallestUnit when the difference has + zero of the smallestUnit +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const start = new Temporal.PlainYearMonth(2012, 1); + +for (const roundingMode of ["ceil", "floor", "expand", "halfCeil", "halfFloor", "halfEven", "halfExpand", "halfTrunc", "trunc"]) { + TemporalHelpers.assertDuration( + start.until(new Temporal.PlainYearMonth(2013, 1), + { smallestUnit: "months", largestUnit: "years", roundingMode, roundingIncrement: 2 }), + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `P1Y months..years ${roundingMode}` + ); + + TemporalHelpers.assertDuration( + start.until(new Temporal.PlainYearMonth(2011, 1), + { smallestUnit: "months", largestUnit: "years", roundingMode, roundingIncrement: 2 }), + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1Y months..years ${roundingMode}` + ); +} diff --git a/third_party/test262/test/built-ins/Temporal/ZonedDateTime/prototype/since/exact-multiple-of-larger-unit.js b/third_party/test262/test/built-ins/Temporal/ZonedDateTime/prototype/since/exact-multiple-of-larger-unit.js new file mode 100644 index 00000000000000..3a466c2379ec2c --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/ZonedDateTime/prototype/since/exact-multiple-of-larger-unit.js @@ -0,0 +1,77 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.since +description: > + Rounding up does not add a spurious extra smallestUnit when the difference has + zero of the smallestUnit +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const start = Temporal.ZonedDateTime.from("2012-01-01T12:00:00+00:00[UTC]"); + +for (const roundingMode of ["ceil", "floor", "expand", "halfCeil", "halfFloor", "halfEven", "halfExpand", "halfTrunc", "trunc"]) { + TemporalHelpers.assertDuration( + Temporal.ZonedDateTime.from("2012-01-08T12:00:00+00:00[UTC]").since(start, + { smallestUnit: "days", largestUnit: "weeks", roundingMode }), + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + `P7D days..weeks ${roundingMode}` + ); + TemporalHelpers.assertDuration( + Temporal.ZonedDateTime.from("2012-02-01T12:00:00+00:00[UTC]").since(start, + { smallestUnit: "days", largestUnit: "months", roundingMode }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + `P1M days..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + Temporal.ZonedDateTime.from("2013-01-01T12:00:00+00:00[UTC]").since(start, + { smallestUnit: "days", largestUnit: "years", roundingMode }), + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `P1Y days..years ${roundingMode}` + ); + TemporalHelpers.assertDuration( + Temporal.ZonedDateTime.from("2012-02-01T12:00:00+00:00[UTC]").since(start, + { smallestUnit: "weeks", largestUnit: "months", roundingMode }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + `P1M weeks..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + Temporal.ZonedDateTime.from("2013-01-01T12:00:00+00:00[UTC]").since(start, + { smallestUnit: "months", largestUnit: "years", roundingMode }), + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `P1Y months..years ${roundingMode}` + ); + + TemporalHelpers.assertDuration( + Temporal.ZonedDateTime.from("2011-12-25T12:00:00+00:00[UTC]").since(start, + { smallestUnit: "days", largestUnit: "weeks", roundingMode }), + 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, + `-P7D days..weeks ${roundingMode}` + ); + TemporalHelpers.assertDuration( + Temporal.ZonedDateTime.from("2011-12-01T12:00:00+00:00[UTC]").since(start, + { smallestUnit: "days", largestUnit: "months", roundingMode }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1M days..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + Temporal.ZonedDateTime.from("2011-01-01T12:00:00+00:00[UTC]").since(start, + { smallestUnit: "days", largestUnit: "years", roundingMode }), + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1Y days..years ${roundingMode}` + ); + TemporalHelpers.assertDuration( + Temporal.ZonedDateTime.from("2011-12-01T12:00:00+00:00[UTC]").since(start, + { smallestUnit: "weeks", largestUnit: "months", roundingMode }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1M weeks..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + Temporal.ZonedDateTime.from("2011-01-01T12:00:00+00:00[UTC]").since(start, + { smallestUnit: "months", largestUnit: "years", roundingMode }), + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1Y months..years ${roundingMode}` + ); +} diff --git a/third_party/test262/test/built-ins/Temporal/ZonedDateTime/prototype/until/exact-multiple-of-larger-unit.js b/third_party/test262/test/built-ins/Temporal/ZonedDateTime/prototype/until/exact-multiple-of-larger-unit.js new file mode 100644 index 00000000000000..2a9d8fcb8070fc --- /dev/null +++ b/third_party/test262/test/built-ins/Temporal/ZonedDateTime/prototype/until/exact-multiple-of-larger-unit.js @@ -0,0 +1,77 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.until +description: > + Rounding up does not add a spurious extra smallestUnit when the difference has + zero of the smallestUnit +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const start = Temporal.ZonedDateTime.from("2012-01-01T12:00:00+00:00[UTC]"); + +for (const roundingMode of ["ceil", "floor", "expand", "halfCeil", "halfFloor", "halfEven", "halfExpand", "halfTrunc", "trunc"]) { + TemporalHelpers.assertDuration( + start.until(Temporal.ZonedDateTime.from("2012-01-08T12:00:00+00:00[UTC]"), + { smallestUnit: "days", largestUnit: "weeks", roundingMode }), + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + `P7D days..weeks ${roundingMode}` + ); + TemporalHelpers.assertDuration( + start.until(Temporal.ZonedDateTime.from("2012-02-01T12:00:00+00:00[UTC]"), + { smallestUnit: "days", largestUnit: "months", roundingMode }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + `P1M days..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + start.until(Temporal.ZonedDateTime.from("2013-01-01T12:00:00+00:00[UTC]"), + { smallestUnit: "days", largestUnit: "years", roundingMode }), + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `P1Y days..years ${roundingMode}` + ); + TemporalHelpers.assertDuration( + start.until(Temporal.ZonedDateTime.from("2012-02-01T12:00:00+00:00[UTC]"), + { smallestUnit: "weeks", largestUnit: "months", roundingMode }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + `P1M weeks..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + start.until(Temporal.ZonedDateTime.from("2013-01-01T12:00:00+00:00[UTC]"), + { smallestUnit: "months", largestUnit: "years", roundingMode }), + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `P1Y months..years ${roundingMode}` + ); + + TemporalHelpers.assertDuration( + start.until(Temporal.ZonedDateTime.from("2011-12-25T12:00:00+00:00[UTC]"), + { smallestUnit: "days", largestUnit: "weeks", roundingMode }), + 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, + `-P7D days..weeks ${roundingMode}` + ); + TemporalHelpers.assertDuration( + start.until(Temporal.ZonedDateTime.from("2011-12-01T12:00:00+00:00[UTC]"), + { smallestUnit: "days", largestUnit: "months", roundingMode }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1M days..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + start.until(Temporal.ZonedDateTime.from("2011-01-01T12:00:00+00:00[UTC]"), + { smallestUnit: "days", largestUnit: "years", roundingMode }), + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1Y days..years ${roundingMode}` + ); + TemporalHelpers.assertDuration( + start.until(Temporal.ZonedDateTime.from("2011-12-01T12:00:00+00:00[UTC]"), + { smallestUnit: "weeks", largestUnit: "months", roundingMode }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1M weeks..months ${roundingMode}` + ); + TemporalHelpers.assertDuration( + start.until(Temporal.ZonedDateTime.from("2011-01-01T12:00:00+00:00[UTC]"), + { smallestUnit: "months", largestUnit: "years", roundingMode }), + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `-P1Y months..years ${roundingMode}` + ); +} diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js index e08e84c6c07b53..c31b2ec882070f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js @@ -14,8 +14,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, Symbol.toStringTag, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.sameValue(sample[Symbol.toStringTag], TA.name); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js b/third_party/test262/test/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js index 1cd8e47c90269c..13c80d44aa79ab 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js @@ -15,7 +15,7 @@ includes: [testTypedArray.js] features: [BigInt, Symbol.toStringTag, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var ta = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var ta = new TA(makeCtorArg(0)); assert.sameValue(ta[Symbol.toStringTag], TA.name, "property value"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js index f24e7147f11f61..7587e6fddad5b3 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js @@ -14,8 +14,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [Symbol.toStringTag, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.sameValue(sample[Symbol.toStringTag], TA.name); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js b/third_party/test262/test/built-ins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js index b16a10837ad99c..2840761d9eb1eb 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js @@ -15,7 +15,7 @@ includes: [testTypedArray.js] features: [Symbol.toStringTag, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var ta = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var ta = new TA(makeCtorArg(0)); assert.sameValue(ta[Symbol.toStringTag], TA.name, "property value"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/buffer/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/buffer/BigInt/detached-buffer.js index deb168fb340fd3..a134d722c589b2 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/buffer/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/buffer/BigInt/detached-buffer.js @@ -13,9 +13,9 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var buffer = new ArrayBuffer(8); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var buffer = makeCtorArg(8); var sample = new TA(buffer, 0, 1); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.buffer, buffer); -}, null, ["passthrough"]); +}, null, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/buffer/BigInt/return-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/buffer/BigInt/return-buffer.js index 037d36237c7224..dccac55059c1e2 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/buffer/BigInt/return-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/buffer/BigInt/return-buffer.js @@ -14,9 +14,9 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var buffer = makeCtorArg(1); var ta = new TA(buffer); assert.sameValue(ta.buffer, buffer); -}, null, ["passthrough"]); +}, null, ["arraybuffer"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/buffer/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/buffer/detached-buffer.js index 1aa7e028c7c328..e472bc3c8c5c79 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/buffer/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/buffer/detached-buffer.js @@ -13,9 +13,9 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var buffer = new ArrayBuffer(8); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var buffer = makeCtorArg(8); var sample = new TA(buffer, 0, 1); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.buffer, buffer); -}, null, ["passthrough"]); +}, null, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/buffer/return-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/buffer/return-buffer.js index a80c1e072ea80b..c1a6f434020464 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/buffer/return-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/buffer/return-buffer.js @@ -14,9 +14,9 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var buffer = makeCtorArg(1); var ta = new TA(buffer); assert.sameValue(ta.buffer, buffer); -}, null, ["passthrough"]); +}, null, ["arraybuffer"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js index 08c330cb5f0e57..c1c9c9019da734 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js @@ -14,8 +14,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.byteLength, 0); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/byteLength/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/byteLength/detached-buffer.js index 029ef7137e1f78..fdd57281e85c70 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/byteLength/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/byteLength/detached-buffer.js @@ -14,8 +14,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.byteLength, 0); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js index 036c4cbbb50466..aa7142867a6bef 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js @@ -14,9 +14,9 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var buffer = new ArrayBuffer(128); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var buffer = makeCtorArg(128); var sample = new TA(buffer, 8, 1); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.byteOffset, 0); -}, null, ["passthrough"]); +}, null, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js b/third_party/test262/test/built-ins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js index 2a53ba897a83ab..4e086d44ce4991 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js @@ -14,18 +14,18 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var ta1 = new TA(); assert.sameValue(ta1.byteOffset, 0, "Regular typedArray"); var offset = 4 * TA.BYTES_PER_ELEMENT; - var buffer1 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var buffer1 = makeCtorArg(8); var ta2 = new TA(buffer1, offset); assert.sameValue(ta2.byteOffset, offset, "TA(buffer, offset)"); - var buffer2 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var buffer2 = makeCtorArg(8); var sample = new TA(buffer2, offset); var ta3 = new TA(sample); assert.sameValue(ta3.byteOffset, 0, "TA(typedArray)"); -}, null, ["passthrough"]); +}, null, ["arraybuffer"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/byteOffset/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/byteOffset/detached-buffer.js index 0c1114403dc81c..6dbda3f738d5b7 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/byteOffset/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/byteOffset/detached-buffer.js @@ -14,9 +14,9 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var buffer = new ArrayBuffer(128); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var buffer = makeCtorArg(128); var sample = new TA(buffer, 8, 1); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.byteOffset, 0); -}, null, ["passthrough"]); +}, null, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/byteOffset/return-byteoffset.js b/third_party/test262/test/built-ins/TypedArray/prototype/byteOffset/return-byteoffset.js index 50f22d50fe2410..cbca8c3ecb76c4 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/byteOffset/return-byteoffset.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/byteOffset/return-byteoffset.js @@ -14,18 +14,18 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var ta1 = new TA(); assert.sameValue(ta1.byteOffset, 0, "Regular typedArray"); var offset = 4 * TA.BYTES_PER_ELEMENT; - var buffer1 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var buffer1 = makeCtorArg(8); var ta2 = new TA(buffer1, offset); assert.sameValue(ta2.byteOffset, offset, "TA(buffer, offset)"); - var buffer2 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var buffer2 = makeCtorArg(8); var sample = new TA(buffer2, offset); var ta3 = new TA(sample); assert.sameValue(ta3.byteOffset, 0, "TA(typedArray)"); -}, null, ["passthrough"]); +}, null, ["arraybuffer"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js index 98b60e2bbaf3a0..50ff90fc4b3d97 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js @@ -74,4 +74,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { ), 'float -2.5 value coerced to integer -2' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js index 82ca98590c7bd1..4a7c6cbcba6b57 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js @@ -89,4 +89,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { ), '1.5 float value coerced to integer 1' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js index 39fe0dd7c979f3..4551963f7f9f6f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js @@ -89,4 +89,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { ), '1.5 float value coerced to integer 1' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js index 75e1622c5057cc..cad1119ceba4d3 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js @@ -25,10 +25,10 @@ var obj = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.copyWithin(obj, obj); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-end.js index b14d4bdac37294..a00b5a4c1bd9ce 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-end.js @@ -92,4 +92,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { ), '[0, 1, 2, 3, 4].copyWithin(-5, -2, -1) -> [3, 1, 2, 3, 4]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js index 92eb58d0a9036b..4877a16671f254 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js @@ -108,4 +108,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { ), '[1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity) -> [1, 2, 3, 4, 5]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js index 71927d17ab44c7..cbfc985e94a3ec 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js @@ -90,4 +90,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { ), '[1, 2, 3, 4, 5].copyWithin(-9, -Infinity) -> [1, 2, 3, 4, 5]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js index 3b0a18701b47b6..2f1ca8b608a55f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js @@ -58,4 +58,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { ), '[1, 2, 3, 4, 5].copyWithin(-Infinity, 2) -> [3, 4, 5, 4, 5]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-start.js index b55690204f12e6..8ceb36225dcb70 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-start.js @@ -74,4 +74,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { ), '[0, 1, 2, 3, 4].copyWithin(-5, -2) -> [3, 4, 2, 3, 4]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-target.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-target.js index 8f73e7150e9e5d..defdb9f9c22850 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-target.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-target.js @@ -50,4 +50,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { ), '[0, 1, 2, 3].copyWithin(-1, 2) -> [0, 1, 2, 2]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js index cb2123459ef710..5de4974df747f6 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js @@ -51,4 +51,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { ), '[1, 2, 3, 4, 5].copyWithin(1, 3, Infinity) -> [1, 4, 5, 4, 5]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js index 8be6d08fc4e1b7..32a7d4b2b4a5d5 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js @@ -71,4 +71,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { ), '[1, 2, 3, 4, 5].copyWithin(Infinity, Infinity) -> [1, 2, 3, 4, 5]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js index 6adbdf917b6067..3b36bb3e42df29 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js @@ -47,4 +47,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { [0n, 4n, 5n, 3n, 4n, 5n] ) ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js index 0e6295b36ddc41..9605fee5a0509e 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js @@ -70,4 +70,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { ), '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 5) -> [0, 3, 4, 3, 4, 5]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js index 73ee9bde7a8da2..27a1d8e6a57538 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js @@ -28,9 +28,9 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol(1); -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.copyWithin(0, 0, s); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js index 91ddf11c5f319e..756928658d58d1 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js @@ -26,14 +26,14 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var o1 = { valueOf: function() { throw new Test262Error(); } }; - var sample = new TA(); + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.copyWithin(0, 0, o1); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js index 915c0ec6d56ba6..44352d75d7bbc0 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js @@ -27,9 +27,9 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol(1); -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.copyWithin(0, s); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js index 2cae99c67e54aa..5a994750084687 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js @@ -37,9 +37,9 @@ var err = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.copyWithin(0, o, err); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js index 927e25f20e2963..e96cb6a94c5ef6 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js @@ -27,9 +27,9 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol(1); -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.copyWithin(s, 0); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js index ac2984d2cf0aed..0bdec02c2f9f90 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js @@ -31,9 +31,9 @@ var o = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.copyWithin(o); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-this.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-this.js index 27f15a3d6f6cf7..5a3155113c38d2 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-this.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-this.js @@ -33,4 +33,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var result2 = sample2.copyWithin(1, 0); assert.sameValue(result2, sample2); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js index f1b67f7a474f99..ed9199a9503525 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js @@ -42,4 +42,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { ), '[0, 1, 2, 3].copyWithin(0, 1) -> [1, 2, 3, 3]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/bit-precision.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/bit-precision.js index e50187441c5139..9d50404adc1032 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/bit-precision.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/bit-precision.js @@ -16,8 +16,8 @@ includes: [nans.js, compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function body(FloatArray) { - var subject = new FloatArray(NaNs.length * 2); +testWithTypedArrayConstructors(function body(FloatArray, makeCtorArg) { + var subject = new FloatArray(makeCtorArg(NaNs.length * 2)); NaNs.forEach(function(v, i) { subject[i] = v; @@ -39,4 +39,4 @@ testWithTypedArrayConstructors(function body(FloatArray) { ); assert(compareArray(originalBytes, copiedBytes)); -}, floatArrayConstructors); +}, floatArrayConstructors, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/byteoffset.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/byteoffset.js index 01555b72c9bd11..8bb96b6fc30681 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/byteoffset.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/byteoffset.js @@ -30,4 +30,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { [0, 1, 2, 1], 'underlying arraybuffer should have been updated' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js index fcbfa18978d2a3..289133f850eee7 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js @@ -21,7 +21,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var ta; var array = []; @@ -33,8 +33,8 @@ testWithTypedArrayConstructors(function(TA) { array.length = 10000; // big arrays are more likely to cause a crash if they are accessed after they are freed array.fill(7, 0); - ta = new TA(array); + ta = new TA(makeCtorArg(array)); assert.throws(TypeError, function(){ ta.copyWithin(0, 100, {valueOf : detachAndReturnIndex}); }, "should throw TypeError as array is detached"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js index ef49765ebe4780..3d39f016bded34 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js @@ -21,7 +21,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var ta; function detachAndReturnIndex(){ $DETACHBUFFER(ta.buffer); @@ -31,8 +31,8 @@ testWithTypedArrayConstructors(function(TA) { var array = []; array.length = 10000; // big arrays are more likely to cause a crash if they are accessed after they are freed array.fill(7, 0); - ta = new TA(array); + ta = new TA(makeCtorArg(array)); assert.throws(TypeError, function(){ ta.copyWithin(0, 100, {valueOf : detachAndReturnIndex}); }, "should throw TypeError as array is detached"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end.js index a542be2bb70319..a8c2157f50e248 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end.js @@ -74,4 +74,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { ), 'float -2.5 value coerced to integer -2' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js index 01cc87d9366852..5bb1b155059d81 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js @@ -21,7 +21,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var ta; function detachAndReturnIndex(){ $DETACHBUFFER(ta.buffer); @@ -31,8 +31,8 @@ testWithTypedArrayConstructors(function(TA) { var array = []; array.length = 10000; // big arrays are more likely to cause a crash if they are accessed after they are freed array.fill(7, 0); - ta = new TA(array); + ta = new TA(makeCtorArg(array)); assert.throws(TypeError, function(){ ta.copyWithin(0, {valueOf : detachAndReturnIndex}, 1000); }, "should throw TypeError as array is detached"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-start.js index 72e5bc406a1cd6..92aa33c9cd155f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-start.js @@ -89,4 +89,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { ), '1.5 float value coerced to integer 1' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-target.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-target.js index 9adfd9cd10625e..8e3239903f9576 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-target.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/coerced-values-target.js @@ -97,4 +97,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { ), 'object value coerced to integer 0' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/detached-buffer.js index 7c1aa1b693733a..0cfbea18115562 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/detached-buffer.js @@ -25,10 +25,10 @@ var obj = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.copyWithin(obj, obj); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/immutable-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/immutable-buffer.js new file mode 100644 index 00000000000000..21561cd7d6a87e --- /dev/null +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/immutable-buffer.js @@ -0,0 +1,59 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: Throws a TypeError exception when the backing buffer is immutable +info: | + %TypedArray%.prototype.copyWithin ( target, start [ , end ] ) + 1. Let O be the this value. + 2. Let taRecord be ? ValidateTypedArray(O, ~seq-cst~, ~write~). + 3. Let len be TypedArrayLength(taRecord). + 4. Let relativeTarget be ? ToIntegerOrInfinity(target). + 5. If relativeTarget = -∞, let targetIndex be 0. + 6. Else if relativeTarget < 0, let targetIndex be max(len + relativeTarget, 0). + 7. Else, let targetIndex be min(relativeTarget, len). + 8. Let relativeStart be ? ToIntegerOrInfinity(start). + 9. If relativeStart = -∞, let startIndex be 0. + 10. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0). + 11. Else, let startIndex be min(relativeStart, len). + 12. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end). + + ValidateTypedArray ( O, order [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to read. + 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). + 3. Assert: O has a [[ViewedArrayBuffer]] internal slot. + 4. If accessMode is ~write~ and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. +features: [TypedArray, immutable-arraybuffer] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithAllTypedArrayConstructors((TA, makeCtorArg) => { + var calls = []; + + var ta = new TA(makeCtorArg(["1", "2", "3", "4"])); + var target = { + valueOf() { + calls.push("target.valueOf"); + return 1; + } + }; + var start = { + valueOf() { + calls.push("start.valueOf"); + return 2; + } + }; + var end = { + valueOf() { + calls.push("end.valueOf"); + return 2; + } + }; + + assert.throws(TypeError, function() { + ta.copyWithin(target, start, end); + }); + assert.compareArray(calls, [], "Must verify mutability before reading arguments."); + assert.compareArray(ta, new TA(["1", "2", "3", "4"]), "Must not mutate contents."); +}, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-end.js index 1f8c6d083f88fe..3d18750139ed27 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-end.js @@ -92,4 +92,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { ), '[0, 1, 2, 3, 4].copyWithin(-5, -2, -1) -> [3, 1, 2, 3, 4]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js index c8687b85d4c37e..24e6955e39dc94 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js @@ -108,4 +108,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { ), '[1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity) -> [1, 2, 3, 4, 5]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js index 3826ed37a2da2d..5ef955bd0a902b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js @@ -90,4 +90,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { ), '[1, 2, 3, 4, 5].copyWithin(-9, -Infinity) -> [1, 2, 3, 4, 5]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js index 56e28367f83ccc..34690c59db03e3 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js @@ -58,4 +58,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { ), '[1, 2, 3, 4, 5].copyWithin(-Infinity, 2) -> [3, 4, 5, 4, 5]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-start.js index 70b305349e11e0..eacbcd9687b7fc 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-start.js @@ -74,4 +74,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { ), '[0, 1, 2, 3, 4].copyWithin(-5, -2) -> [3, 4, 2, 3, 4]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-target.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-target.js index f5a90997958666..a3e12b60a3bffd 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-target.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/negative-target.js @@ -50,4 +50,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { ), '[0, 1, 2, 3].copyWithin(-1, 2) -> [0, 1, 2, 2]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js index 23df3ef812a055..0cd078665efe1b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js @@ -51,4 +51,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { ), '[1, 2, 3, 4, 5].copyWithin(1, 3, Infinity) -> [1, 4, 5, 4, 5]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js index 6956d288b47ab5..1ef8740a1ac618 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js @@ -71,4 +71,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { ), '[1, 2, 3, 4, 5].copyWithin(Infinity, Infinity) -> [1, 2, 3, 4, 5]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js index 72c6badc2aa59f..db6cc87defbc4b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js @@ -47,4 +47,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { [0, 4, 5, 3, 4, 5] ) ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js index 9e37ecba37df10..c81708208e7776 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js @@ -70,4 +70,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { ), '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 5) -> [0, 3, 4, 3, 4, 5]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js index ce76b90db28e3c..67a099ca5d6409 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js @@ -28,9 +28,9 @@ features: [Symbol, TypedArray] var s = Symbol(1); -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.copyWithin(0, 0, s); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js index 8ce6a9f601af3e..de0d1d9e5dfcbe 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js @@ -26,14 +26,14 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var o1 = { valueOf: function() { throw new Test262Error(); } }; - var sample = new TA(); + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.copyWithin(0, 0, o1); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js index 9fe2f2849e1768..2905361800b98b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js @@ -27,9 +27,9 @@ features: [Symbol, TypedArray] var s = Symbol(1); -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.copyWithin(0, s); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js index b726df0c1f9d5c..c97639ccf9582f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js @@ -37,9 +37,9 @@ var err = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.copyWithin(0, o, err); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js index 1aac7608a1b48e..8a403ce70cbfb5 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js @@ -27,9 +27,9 @@ features: [Symbol, TypedArray] var s = Symbol(1); -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.copyWithin(s, 0); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js index 9e3fb26583ad21..97d60c4e5f0ae5 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js @@ -31,9 +31,9 @@ var o = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.copyWithin(o); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-this.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-this.js index 68bd240e212720..42eb83172a561c 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-this.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/return-this.js @@ -33,4 +33,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { var result2 = sample2.copyWithin(1, 0); assert.sameValue(result2, sample2); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/undefined-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/undefined-end.js index add95fbbaa729c..0c491bf2c6544d 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/undefined-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/copyWithin/undefined-end.js @@ -42,4 +42,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { ), '[0, 1, 2, 3].copyWithin(0, 1) -> [1, 2, 3, 3]' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/entries/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/entries/BigInt/detached-buffer.js index 381f1b7f8d2169..7b965e58c32ec2 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/entries/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/entries/BigInt/detached-buffer.js @@ -18,10 +18,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.entries(); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/entries/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/entries/detached-buffer.js index 87415a6eadee47..d5dfb77df6b4d0 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/entries/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/entries/detached-buffer.js @@ -18,10 +18,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.entries(); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/entries/return-itor.js b/third_party/test262/test/built-ins/TypedArray/prototype/entries/return-itor.js index 217f3e37069c19..8a7876266096b8 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/entries/return-itor.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/entries/return-itor.js @@ -14,8 +14,8 @@ features: [TypedArray] var sample = [0, 42, 64]; -testWithTypedArrayConstructors(function(TA) { - var typedArray = new TA(sample); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var typedArray = new TA(makeCtorArg(sample)); var itor = typedArray.entries(); var next = itor.next(); @@ -33,4 +33,4 @@ testWithTypedArrayConstructors(function(TA) { next = itor.next(); assert.sameValue(next.value, undefined); assert.sameValue(next.done, true); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js index 1b66fb608c7197..ae6107ba435a19 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js @@ -25,9 +25,9 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.every(function() { if (loops === 0) { @@ -38,4 +38,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js b/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js index ac79c980aab09e..5d49fa2eb33db8 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js @@ -25,12 +25,12 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; - new TA().every(function() { + new TA(makeCtorArg(0)).every(function() { called++; }); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js b/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js index d9b3ba0e914bcd..86e6ca013d5de7 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js @@ -55,4 +55,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7"); assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1"); assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/detached-buffer.js index bb784071f31b3e..1f4a4f7f55dc37 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/detached-buffer.js @@ -23,10 +23,10 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.every(callbackfn); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js b/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js index 9f3422fff3674a..6f364a3a2a74bb 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js @@ -20,7 +20,7 @@ includes: [testTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; var values = [ true, @@ -35,7 +35,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { 0.1, -0.1 ]; - var sample = new TA(values.length); + var sample = new TA(makeCtorArg(values.length)); var result = sample.every(function() { called++; return values.unshift(); @@ -43,4 +43,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.sameValue(called, sample.length, "callbackfn called for each index"); assert.sameValue(result, true, "return is true"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/values-are-not-cached.js b/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/values-are-not-cached.js index a397c4708765a7..0431e4febd04a3 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/values-are-not-cached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/every/BigInt/values-are-not-cached.js @@ -39,4 +39,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { ); return true; }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js index 3ca47cde6b9a91..5787fdc4a7f7a0 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js @@ -25,9 +25,9 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.every(function() { if (loops === 0) { @@ -38,4 +38,4 @@ testWithTypedArrayConstructors(function(TA) { }); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js b/third_party/test262/test/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js index 055c5065ca69ab..d347f6855f5788 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js @@ -25,12 +25,12 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; - new TA().every(function() { + new TA(makeCtorArg(0)).every(function() { called++; }); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js b/third_party/test262/test/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js index 235f03353ed185..5d3e01448e5072 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js @@ -55,4 +55,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample[0], 7, "changed values after iteration [0] == 7"); assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1"); assert.sameValue(sample[2], 2, "changed values after iteration [2] == 2"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/every/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/every/detached-buffer.js index b5d535f691df0b..85910709e7e38c 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/every/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/every/detached-buffer.js @@ -23,10 +23,10 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.every(callbackfn); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js b/third_party/test262/test/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js index f00d93d546b84d..52acdbae30bb9c 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js @@ -20,7 +20,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; var values = [ true, @@ -35,7 +35,7 @@ testWithTypedArrayConstructors(function(TA) { 0.1, -0.1 ]; - var sample = new TA(values.length); + var sample = new TA(makeCtorArg(values.length)); var result = sample.every(function() { called++; return values.unshift(); @@ -43,4 +43,4 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(called, sample.length, "callbackfn called for each index"); assert.sameValue(result, true, "return is true"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/every/values-are-not-cached.js b/third_party/test262/test/built-ins/TypedArray/prototype/every/values-are-not-cached.js index f9f9e06901707d..f61fc01acf5e06 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/every/values-are-not-cached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/every/values-are-not-cached.js @@ -39,4 +39,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { ); return true; }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/coerced-indexes.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/coerced-indexes.js index 4f3cded462108c..e6e797f4808126 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/coerced-indexes.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/coerced-indexes.js @@ -101,4 +101,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(new TA(makeCtorArg([0n, 0n])).fill(1n, 0, 1.5), [1n, 0n]), 'end as a float number coerced' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/detached-buffer.js index c9492dc31870f2..a248f4abcc1b3c 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/detached-buffer.js @@ -25,10 +25,10 @@ var obj = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.fill(obj); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js index ce5853f52d8efb..4f3647f9a6b204 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js @@ -24,5 +24,5 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(n, 2n, "additional unexpected ToBigInt() calls"); assert.sameValue(sample[0], 1n, "incorrect ToNumber result in index 0"); assert.sameValue(sample[1], 1n, "incorrect ToNumber result in index 1"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js index 4d82b802be1082..78cbcf8e3bcdef 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js @@ -39,4 +39,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert(compareArray(new TA(makeCtorArg([0n, 0n, 0n, 0n, 0n])).fill(8n, -2, -1), [0n, 0n, 0n, 8n, 0n])); assert(compareArray(new TA(makeCtorArg([0n, 0n, 0n, 0n, 0n])).fill(8n, -1, -3), [0n, 0n, 0n, 0n, 0n])); assert(compareArray(new TA(makeCtorArg([0n, 0n, 0n, 0n, 0n])).fill(8n, 1, 3), [0n, 8n, 8n, 0n, 0n])); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js index 34b86e4019c1a9..298117a683b8d1 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js @@ -64,4 +64,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { sample.fill("nonsense"); }, "abrupt completion from string"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js index 7f2be13728b973..6b7cb72ae1a9b7 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js @@ -80,4 +80,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { }); assert.sameValue(sample[0], 7n, "object toString when valueOf is absent"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js index 1740920d61f980..52eaf2dc7a5866 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js @@ -50,4 +50,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(new TA(makeCtorArg([0n, 0n, 0n])).fill(8n, 0, -4), [0n, 0n, 0n]), "end position is 0 when (len + relativeEnd) < 0" ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js index 5c6101368817c0..f645d9c0caa10f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js @@ -48,4 +48,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(new TA(makeCtorArg([0n, 0n, 0n])).fill(8n, -5), [8n, 8n, 8n]), "start position is 0 when (len + relativeStart) < 0" ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js index 24b7bc17d1f693..988601ba2a7c38 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js @@ -55,4 +55,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(TypeError, function() { sample.fill(s); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values.js index 4bd08ca21d585c..773a407b3113ec 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values.js @@ -41,4 +41,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(new TA(makeCtorArg([0n, 0n, 0n])).fill(8n), [8n, 8n, 8n]), "Default start and end indexes are 0 and this.length" ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js index 71a12c08d4ecc6..c1f1892df4f463 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js @@ -30,9 +30,9 @@ features: [BigInt, Symbol, TypedArray] var end = Symbol(1); -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.fill(1n, 0, end); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js index 712cedf1f8a655..8db32a08e2d4f5 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js @@ -34,9 +34,9 @@ var end = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.fill(1n, 0, end); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js index a3fc6ea35c4bdd..f3a6af18dcf699 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js @@ -58,4 +58,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(Test262Error, function() { sample.fill(obj); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js index e696a35a1201db..f32d519d164f6b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js @@ -29,9 +29,9 @@ features: [BigInt, Symbol, TypedArray] var start = Symbol(1); -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.fill(1n, start); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js index 362bf4327a5355..51f8d33d4f5c03 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js @@ -33,9 +33,9 @@ var start = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.fill(1n, start); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-this.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-this.js index c21609020079c2..c7225384d3164b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-this.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/BigInt/return-this.js @@ -17,4 +17,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var sample2 = new TA(makeCtorArg(42)); var result2 = sample2.fill(7n); assert.sameValue(result2, sample2); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/coerced-end-detach.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/coerced-end-detach.js index 1f358d3703ca50..70fe6a719e7687 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/coerced-end-detach.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/coerced-end-detach.js @@ -14,8 +14,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(10); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(10)); function detachAndReturnIndex(){ $DETACHBUFFER(sample.buffer); @@ -25,4 +25,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { sample.fill(0x77, 0, {valueOf: detachAndReturnIndex}); }, "Detachment when coercing end should throw TypeError"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/coerced-indexes.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/coerced-indexes.js index 58a2b16e0112bc..c6834011dd0fdf 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/coerced-indexes.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/coerced-indexes.js @@ -101,4 +101,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(new TA(makeCtorArg([0, 0])).fill(1, 0, 1.5), [1, 0]), 'end as a float number coerced' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/coerced-start-detach.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/coerced-start-detach.js index 64b51882aeef05..f1839ca892ed9e 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/coerced-start-detach.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/coerced-start-detach.js @@ -15,8 +15,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(10); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(10)); function detachAndReturnIndex(){ $DETACHBUFFER(sample.buffer); @@ -26,4 +26,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { sample.fill(0x77, {valueOf: detachAndReturnIndex}, 10); }, "Detachment when coercing start should throw TypeError"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/coerced-value-detach.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/coerced-value-detach.js index 8a83b5e5943de2..7be93b514eb353 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/coerced-value-detach.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/coerced-value-detach.js @@ -15,8 +15,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(10); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(10)); function detachAndReturnIndex(){ $DETACHBUFFER(sample.buffer); @@ -26,4 +26,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { sample.fill({valueOf: detachAndReturnIndex}, 0, 10); }, "Detachment when coercing value should throw TypeError"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/detached-buffer.js index 9bbe7d0d7b9d8d..99d79328729736 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/detached-buffer.js @@ -25,10 +25,10 @@ var obj = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.fill(obj); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-conversion-once.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-conversion-once.js index 8a3531936ee9a8..8617c5811b9a63 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-conversion-once.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-conversion-once.js @@ -23,5 +23,5 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(n, 2, "additional unexpected ToNumber() calls"); assert.sameValue(sample[0], 1, "incorrect ToNumber result in index 0"); assert.sameValue(sample[1], 1, "incorrect ToNumber result in index 1"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js index aeaac53e670860..2558a013da0a24 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js @@ -98,4 +98,4 @@ testWithTypedArrayConstructors(function(FA, makeCtorArg) { ); } } -}, floatArrayConstructors); +}, floatArrayConstructors, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js index 7ee112c0d9a76c..9371e6f13f803a 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js @@ -39,4 +39,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert(compareArray(new TA(makeCtorArg([0, 0, 0, 0, 0])).fill(8, -2, -1), [0, 0, 0, 8, 0])); assert(compareArray(new TA(makeCtorArg([0, 0, 0, 0, 0])).fill(8, -1, -3), [0, 0, 0, 0, 0])); assert(compareArray(new TA(makeCtorArg([0, 0, 0, 0, 0])).fill(8, 1, 3), [0, 8, 8, 0, 0])); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-non-numeric.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-non-numeric.js index cb05403e576dd5..e544c9469447a6 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-non-numeric.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-non-numeric.js @@ -84,4 +84,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { } }); assert.sameValue(sample[0], 7, "object toString when valueOf is absent"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-relative-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-relative-end.js index 598715aefd73f4..f5a2e63147d1d1 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-relative-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-relative-end.js @@ -50,4 +50,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(new TA(makeCtorArg([0, 0, 0])).fill(8, 0, -4), [0, 0, 0]), "end position is 0 when (len + relativeEnd) < 0" ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-relative-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-relative-start.js index 0261a22d1b372b..3af094a5750808 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-relative-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-relative-start.js @@ -48,4 +48,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(new TA(makeCtorArg([0, 0, 0])).fill(8, -5), [8, 8, 8]), "start position is 0 when (len + relativeStart) < 0" ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-symbol-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-symbol-throws.js index 36d041b36ba08f..a42844db792dd6 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-symbol-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values-symbol-throws.js @@ -55,4 +55,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(TypeError, function() { sample.fill(s); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values.js index 63207f87c58fc8..30cedcccb28585 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/fill-values.js @@ -41,4 +41,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(new TA(makeCtorArg([0, 0, 0])).fill(8), [8, 8, 8]), "Default start and end indexes are 0 and this.length" ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/immutable-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/immutable-buffer.js new file mode 100644 index 00000000000000..c466a105465e58 --- /dev/null +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/immutable-buffer.js @@ -0,0 +1,57 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.fill +description: Throws a TypeError exception when the backing buffer is immutable +info: | + %TypedArray%.prototype.fill ( value [ , start [ , end ] ] ) + 1. Let O be the this value. + 2. Let taRecord be ? ValidateTypedArray(O, ~seq-cst~, ~write~). + 3. Let len be TypedArrayLength(taRecord). + 4. If O.[[ContentType]] is bigint, set value to ? ToBigInt(value). + 5. Otherwise, set value to ? ToNumber(value). + 6. Let relativeStart be ? ToIntegerOrInfinity(start). + 7. If relativeStart = -∞, let startIndex be 0. + 8. Else if relativeStart < 0, let startIndex be max(len + relativeStart, 0). + 9. Else, let startIndex be min(relativeStart, len). + 10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end). + + ValidateTypedArray ( O, order [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to read. + 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). + 3. Assert: O has a [[ViewedArrayBuffer]] internal slot. + 4. If accessMode is ~write~ and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. +features: [TypedArray, immutable-arraybuffer] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithAllTypedArrayConstructors((TA, makeCtorArg) => { + var calls = []; + + var ta = new TA(makeCtorArg(["1", "2", "3", "4"])); + var value = { + valueOf() { + calls.push("value.valueOf"); + return "8"; + } + }; + var start = { + valueOf() { + calls.push("start.valueOf"); + return 1; + } + }; + var end = { + valueOf() { + calls.push("end.valueOf"); + return 1; + } + }; + + assert.throws(TypeError, function() { + ta.fill(value, start, end); + }); + assert.compareArray(calls, [], "Must verify mutability before reading arguments."); + assert.compareArray(ta, new TA(["1", "2", "3", "4"]), "Must not mutate contents."); +}, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js index 8c6a62b155f7d5..76042af484c3b1 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js @@ -30,9 +30,9 @@ features: [Symbol, TypedArray] var end = Symbol(1); -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.fill(1, 0, end); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-end.js index db9d08a09c0114..495353ea09d0c2 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-end.js @@ -34,9 +34,9 @@ var end = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.fill(1, 0, end); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-set-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-set-value.js index 0c52c3675be74a..ca68ae49c0f527 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-set-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-set-value.js @@ -58,4 +58,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(Test262Error, function() { sample.fill(obj); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js index bfbbfc3dfacb33..6c2f4e014d9916 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js @@ -29,9 +29,9 @@ features: [Symbol, TypedArray] var start = Symbol(1); -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.fill(1, start); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-start.js index 0b10cf6b336688..92b9df93f87fe6 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-abrupt-from-start.js @@ -33,9 +33,9 @@ var start = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.fill(1, start); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-this.js b/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-this.js index 84859f01859b89..5f1b1603ee0f45 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-this.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/fill/return-this.js @@ -17,4 +17,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { var sample2 = new TA(makeCtorArg(42)); var result2 = sample2.fill(7); assert.sameValue(result2, sample2); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js index f26d2183136a2c..5180ebdd0479f7 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js @@ -17,9 +17,9 @@ includes: [testTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var length = 42; - var sample = new TA(length); + var sample = new TA(makeCtorArg(length)); var calls = 0; var before = false; diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js index 948af79ddba695..785b334e6f5098 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js @@ -17,9 +17,9 @@ includes: [testTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var length = 42; - var sample = new TA(length); + var sample = new TA(makeCtorArg(length)); var calls = 0; var before = false; diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js index 04fb2e917cf10f..c66add78f542a9 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js @@ -18,9 +18,9 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.filter(function() { var flag = true; @@ -34,4 +34,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js index 2b8effd4189557..3e98c6da6879d0 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js @@ -16,12 +16,12 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; - new TA().filter(function() { + new TA(makeCtorArg(0)).filter(function() { called++; }); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js index 78ebdd956d2d2b..c4beeb4eed727d 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js @@ -9,9 +9,7 @@ features: [BigInt, TypedArray] ---*/ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { - var sample1 = new TA(makeCtorArg(3)); - - sample1[1] = 1n; + var sample1 = new TA(makeCtorArg(["0", "1", "0"])); sample1.filter(function() { return 42; diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js index 959ad02f270c34..84a490a6eceb72 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js @@ -44,4 +44,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample[0], 7n, "changed values after interaction [0] == 7"); assert.sameValue(sample[1], 1n, "changed values after interaction [1] == 1"); assert.sameValue(sample[2], 2n, "changed values after interaction [2] == 2"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/detached-buffer.js index 808fec192159cd..d0d7ec883b3a63 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/detached-buffer.js @@ -23,10 +23,10 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.filter(callbackfn); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js index fe17657080bd05..5ba4cb58b281c7 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js @@ -28,4 +28,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { v, 42n, "method does not cache values before callbackfn calls" ); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js index ec67bea1bd4652..765a6730c38c8c 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js @@ -17,9 +17,9 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var length = 42; - var sample = new TA(length); + var sample = new TA(makeCtorArg(length)); var calls = 0; var before = false; diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-called-before-species.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-called-before-species.js index a5e77a49139124..4289ab5dfc2190 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-called-before-species.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-called-before-species.js @@ -17,9 +17,9 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var length = 42; - var sample = new TA(length); + var sample = new TA(makeCtorArg(length)); var calls = 0; var before = false; diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-detachbuffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-detachbuffer.js index 638438e219db8b..2f3e1ed1a64c78 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-detachbuffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-detachbuffer.js @@ -17,9 +17,9 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.filter(function() { if (loops === 0) { @@ -30,4 +30,4 @@ testWithTypedArrayConstructors(function(TA) { }); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js index 8adf0021807673..0d7f6183765d40 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js @@ -16,12 +16,12 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; - new TA().filter(function() { + new TA(makeCtorArg(0)).filter(function() { called++; }); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js index 3c5d96ceee7016..3d09210fd25df7 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js @@ -9,9 +9,7 @@ features: [TypedArray] ---*/ testWithTypedArrayConstructors(function(TA, makeCtorArg) { - var sample1 = new TA(makeCtorArg(3)); - - sample1[1] = 1; + var sample1 = new TA(makeCtorArg(["0", "1", "0"])); sample1.filter(function() { return 42; diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js index 29b3fc0e6b750a..e5188e0cc5e481 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js @@ -44,4 +44,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample[0], 7, "changed values after interaction [0] == 7"); assert.sameValue(sample[1], 1, "changed values after interaction [1] == 1"); assert.sameValue(sample[2], 2, "changed values after interaction [2] == 2"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/detached-buffer.js index 5f25343417c8dc..84a498de00ea45 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/filter/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/detached-buffer.js @@ -23,10 +23,10 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.filter(callbackfn); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/speciesctor-destination-backed-by-immutable-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/speciesctor-destination-backed-by-immutable-buffer.js new file mode 100644 index 00000000000000..ac1a61b10884f2 --- /dev/null +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/speciesctor-destination-backed-by-immutable-buffer.js @@ -0,0 +1,82 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Throws a TypeError exception when the receiver constructs an instance backed + by an immutable buffer +info: | + %TypedArray%.prototype.filter ( callback [ , thisArg ] ) + ... + 8. Repeat, while k < len, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ! Get(O, Pk). + c. Let selected be ToBoolean(? Call(callback, thisArg, « kValue, 𝔽(k), O »)). + d. If selected is true, then + i. Append kValue to kept. + ii. Set captured to captured + 1. + e. Set k to k + 1. + 9. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(captured) », ~write~). + 10. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false. + + TypedArraySpeciesCreate ( exemplar, argumentList [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to ~read~. + 2. Let defaultConstructor be the intrinsic object associated with the constructor name exemplar.[[TypedArrayName]] in Table 73. + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Let result be ? TypedArrayCreateFromConstructor(constructor, argumentList, accessMode). + + TypedArrayCreateFromConstructor ( constructor, argumentList [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to ~read~. + 2. Let newTypedArray be ? Construct(constructor, argumentList). + 3. Let taRecord be ? ValidateTypedArray(newTypedArray, seq-cst, accessMode). + + ValidateTypedArray ( O, order [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to read. + 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). + 3. Assert: O has a [[ViewedArrayBuffer]] internal slot. + 4. If accessMode is ~write~ and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. +features: [Symbol.species, TypedArray, immutable-arraybuffer] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithAllTypedArrayConstructors((TA, makeCtorArg) => { + var calls = []; + + var ta = new TA(makeCtorArg(["1", "2"])); + var iab = (new TA(["3", "4"])).buffer.transferToImmutable(); + var constructor = {}; + Object.defineProperty(ta, "constructor", { + get: function() { + calls.push("get ta.constructor"); + return constructor; + } + }); + Object.defineProperty(constructor, Symbol.species, { + get: function() { + calls.push("get ta.constructor[Symbol.species]"); + return function speciesCtor() { + calls.push("construct result"); + var result = new TA(iab); + calls.push("return result"); + return result; + }; + } + }); + + assert.throws(TypeError, function() { + ta.filter(function(value, index) { + calls.push("filter index " + index); + return !index; + }); + }); + var expectCalls = [ + "filter index 0", + "filter index 1", + "get ta.constructor", + "get ta.constructor[Symbol.species]", + "construct result", + "return result" + ]; + assert.compareArray(calls, expectCalls, "Must visit elements before constructing the result."); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/filter/values-are-not-cached.js b/third_party/test262/test/built-ins/TypedArray/prototype/filter/values-are-not-cached.js index 448c33f4d14140..e27bf951f0a6b5 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/filter/values-are-not-cached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/filter/values-are-not-cached.js @@ -28,4 +28,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { v, 42, "method does not cache values before callbackfn calls" ); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/detached-buffer.js index da8daa539db31e..f271038edca027 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/detached-buffer.js @@ -23,10 +23,10 @@ var predicate = function() { throw new Test262Error(); }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.find(predicate); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js index e7aa737815888d..867eed774e30c2 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js @@ -75,4 +75,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { return true; }); assert.sameValue(result, 1n, "find() returns previous found value"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js index e33cc3646dde74..cdff56f3a6e9cf 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js @@ -25,8 +25,8 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.find({}); @@ -63,4 +63,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { sample.find(/./); }, "regexp"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js index 65720dc5e21877..6bdec4d62594b9 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js @@ -42,9 +42,9 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.find(function() { if (loops === 0) { @@ -54,4 +54,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js b/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js index 152d92f52fb317..69fa9f1e5bcc42 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js @@ -27,8 +27,8 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); var called = false; var result = sample.find(function() { @@ -46,4 +46,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { undefined, "find returns undefined when predicate is not called" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/find/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/find/detached-buffer.js index c37bd6962f7609..e2152642ccb63a 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/find/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/find/detached-buffer.js @@ -23,10 +23,10 @@ var predicate = function() { throw new Test262Error(); }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.find(predicate); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/find/predicate-call-changes-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/find/predicate-call-changes-value.js index ce2cafed376a99..1e717cac11e6fd 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/find/predicate-call-changes-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/find/predicate-call-changes-value.js @@ -75,4 +75,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { return true; }); assert.sameValue(result, 1, "find() returns previous found value"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/find/predicate-is-not-callable-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/find/predicate-is-not-callable-throws.js index d041ec58791ba5..72c5ec5f3c4c0d 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/find/predicate-is-not-callable-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/find/predicate-is-not-callable-throws.js @@ -25,8 +25,8 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.find({}); @@ -63,4 +63,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { sample.find(/./); }, "regexp"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/find/predicate-may-detach-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/find/predicate-may-detach-buffer.js index 80a70f9dad5582..56fa10b268982d 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/find/predicate-may-detach-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/find/predicate-may-detach-buffer.js @@ -42,9 +42,9 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.find(function() { if (loops === 0) { @@ -54,4 +54,4 @@ testWithTypedArrayConstructors(function(TA) { }); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js b/third_party/test262/test/built-ins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js index 9dd1e94ab02067..efcec7131245ac 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js @@ -27,8 +27,8 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); var called = false; var result = sample.find(function() { @@ -46,4 +46,4 @@ testWithTypedArrayConstructors(function(TA) { undefined, "find returns undefined when predicate is not called" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js index a3fbcbd99c2579..7b5e2ad6c64d40 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js @@ -23,10 +23,10 @@ var predicate = function() { throw new Test262Error(); }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.findIndex(predicate); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js index e6ee1d4b025dca..636cdd225dbec6 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js @@ -64,4 +64,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { return val === 7n; }); assert.sameValue(result, -1, "value not found - changed after call"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js index c7fd11789963d4..18c281d5c5c2d5 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js @@ -23,8 +23,8 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.findIndex({}); }, "{}"); @@ -60,5 +60,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { sample.findIndex(/./); }, "/./"); -}, null, ["passthrough"]); - +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js index 831bccbf988742..6cbedff1c4374c 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js @@ -34,8 +34,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(2); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(2)); var loops = 0; sample.findIndex(function() { @@ -45,4 +45,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { loops++; }); assert.sameValue(loops, 2, "predicate is called once"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js index e60ad6ae102401..cd9fb7099099b9 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js @@ -26,8 +26,8 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); var called = false; var predicate = function() { @@ -45,4 +45,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { result, -1, "returns -1 on an empty instance" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/detached-buffer.js index 5d79ae9af8b482..8ff3a6ef9ca54d 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/detached-buffer.js @@ -23,10 +23,10 @@ var predicate = function() { throw new Test262Error(); }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.findIndex(predicate); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/predicate-call-changes-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/predicate-call-changes-value.js index e47a006c5e134d..2a7fc69297a972 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/predicate-call-changes-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/predicate-call-changes-value.js @@ -64,4 +64,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { return val === 7; }); assert.sameValue(result, -1, "value not found - changed after call"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js index 07e07caf7b10e6..c859acc7f18230 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js @@ -23,8 +23,8 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.findIndex({}); }, "{}"); @@ -60,5 +60,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { sample.findIndex(/./); }, "/./"); -}, null, ["passthrough"]); - +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js index fca55d59895b10..54ac0d615f59d8 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js @@ -31,8 +31,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(2); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(2)); var loops = 0; sample.findIndex(function() { @@ -42,4 +42,4 @@ testWithTypedArrayConstructors(function(TA) { loops++; }); assert.sameValue(loops, 2, "predicate is called once"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js index 7a3ec2a004e118..41ff0abda796c2 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js @@ -26,8 +26,8 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); var called = false; var predicate = function() { @@ -45,4 +45,4 @@ testWithTypedArrayConstructors(function(TA) { result, -1, "returns -1 on an empty instance" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/detached-buffer.js index ce76155d1227df..bedeb671387f87 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/detached-buffer.js @@ -21,10 +21,10 @@ var predicate = function() { throw new Test262Error(); }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.findLast(predicate); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js index f05e04712dfffb..dbacb1c19d1506 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js @@ -63,4 +63,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { return true; }); assert.sameValue(result, 3n, "findLast() returns previous found value"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js index 9d4251a9be749c..082fb04ec38a99 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js @@ -14,8 +14,8 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray, array-find-from-last] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.findLast({}); @@ -52,4 +52,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { sample.findLast(/./); }, "regexp"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js index 6cd3e204a61ed5..1927ed16677e74 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js @@ -24,9 +24,9 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray, array-find-from-last] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.findLast(function() { if (loops === 0) { @@ -36,4 +36,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js index 0ac503c7136995..672810e69e5401 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js @@ -15,8 +15,8 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray, array-find-from-last] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); var called = false; var result = sample.findLast(function() { @@ -34,4 +34,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { undefined, "findLast returns undefined when predicate is not called" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/detached-buffer.js index fa0f8b6af81633..1667c2538653d0 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/detached-buffer.js @@ -21,10 +21,10 @@ var predicate = function() { throw new Test262Error(); }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.findLast(predicate); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/predicate-call-changes-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/predicate-call-changes-value.js index c86ce12a5736a8..20c188a5fc532f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/predicate-call-changes-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/predicate-call-changes-value.js @@ -63,4 +63,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { return true; }); assert.sameValue(result, 3, "findLast() returns previous found value"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js index abfa53835f58a1..958cb4b92d54bc 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js @@ -14,8 +14,8 @@ includes: [testTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.findLast({}); @@ -52,4 +52,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { sample.findLast(/./); }, "regexp"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js index 45f2f837142d68..60222805b9a87c 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js @@ -24,9 +24,9 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray, array-find-from-last] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.findLast(function() { if (loops === 0) { @@ -36,4 +36,4 @@ testWithTypedArrayConstructors(function(TA) { }); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js index 9d804b4c3485e7..2b6ba1014eeef3 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js @@ -15,8 +15,8 @@ includes: [testTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); var called = false; var result = sample.findLast(function() { @@ -34,4 +34,4 @@ testWithTypedArrayConstructors(function(TA) { undefined, "findLast returns undefined when predicate is not called" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js index 75684bc023e067..877cd49d2d885e 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js @@ -23,10 +23,10 @@ var predicate = function() { throw new Test262Error(); }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.findLastIndex(predicate); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js index cf0043d99d1486..e42b60edf5f0d0 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js @@ -55,4 +55,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { return val === 7n; }); assert.sameValue(result, -1, "value not found - changed after call"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js index ef0a4f17012540..1ad6d0ca0aaff6 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js @@ -14,8 +14,8 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray, array-find-from-last] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.findLastIndex({}); }, "{}"); @@ -51,5 +51,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { sample.findLastIndex(/./); }, "/./"); -}, null, ["passthrough"]); - +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js index 252923f21c8c8e..fa51f7444fc63d 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js @@ -23,8 +23,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray, array-find-from-last] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(2); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(2)); var loops = 0; sample.findLastIndex(function() { @@ -34,4 +34,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { loops++; }); assert.sameValue(loops, 2, "predicate is called once"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js index 774c57eb08eb25..41b2a43cf3bbc6 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js @@ -17,8 +17,8 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray, array-find-from-last] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); var called = false; var predicate = function() { @@ -36,4 +36,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { result, -1, "returns -1 on an empty instance" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/detached-buffer.js index f2e9c00f1bd5bc..955dc1a7018729 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/detached-buffer.js @@ -23,10 +23,10 @@ var predicate = function() { throw new Test262Error(); }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.findLastIndex(predicate); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js index eb4f30385d379f..93e98e4e010a5e 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js @@ -55,4 +55,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { return val === 7; }); assert.sameValue(result, -1, "value not found - changed after call"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js index ec7ecacf88a452..745c26995ba74b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js @@ -14,8 +14,8 @@ includes: [testTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.findLastIndex({}); }, "{}"); @@ -51,5 +51,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { sample.findLastIndex(/./); }, "/./"); -}, null, ["passthrough"]); - +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js index 147f64162e1e43..15745d2267a4b8 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js @@ -23,8 +23,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray, array-find-from-last] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(2); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(2)); var loops = 0; sample.findLastIndex(function() { @@ -34,4 +34,4 @@ testWithTypedArrayConstructors(function(TA) { loops++; }); assert.sameValue(loops, 2, "predicate is called once"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js index 18d6c80db1bcdb..95fe9e2b826383 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js @@ -17,8 +17,8 @@ includes: [testTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); var called = false; var predicate = function() { @@ -36,4 +36,4 @@ testWithTypedArrayConstructors(function(TA) { result, -1, "returns -1 on an empty instance" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js index fbe8544d5f35c8..0ae4f2e59c3e16 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js @@ -43,5 +43,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { }); assert.sameValue(loop, 7, "accessor descriptor"); -}, null, ["passthrough"]); - +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js index cfb457f8072fdc..7bb15321753e37 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js @@ -25,9 +25,9 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.forEach(function() { if (loops === 0) { @@ -37,4 +37,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js index 72e719d82a29b5..a96dff276bb72b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js @@ -25,12 +25,12 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; - new TA().forEach(function() { + new TA(makeCtorArg(0)).forEach(function() { called++; }); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js index ea6cbd54867005..40c068dbfe03fc 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js @@ -16,9 +16,7 @@ features: [BigInt, TypedArray] ---*/ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { - var sample1 = new TA(makeCtorArg(3)); - - sample1[1] = 1n; + var sample1 = new TA(makeCtorArg(["0", "1", "0"])); sample1.forEach(function() { return 42; diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js index 5a9b6f7bbe3631..68c2937d56ad66 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js @@ -44,4 +44,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7"); assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1"); assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/detached-buffer.js index b8acbcc4b28cd0..d9b4220e1b9bc4 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/detached-buffer.js @@ -23,10 +23,10 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.forEach(callbackfn); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js index e8b8eda98ec715..81208159c8ca2e 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js @@ -28,4 +28,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { v, 42n, "method does not cache values before callbackfn calls" ); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/arraylength-internal.js b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/arraylength-internal.js index ba7e08bf46b015..7cfe7f77c5946c 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/arraylength-internal.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/arraylength-internal.js @@ -43,5 +43,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { }); assert.sameValue(loop, 7, "accessor descriptor"); -}, null, ["passthrough"]); - +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js index d2a8a31d7eadcb..62228118ff7527 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js @@ -25,9 +25,9 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.forEach(function() { if (loops === 0) { @@ -37,4 +37,4 @@ testWithTypedArrayConstructors(function(TA) { }); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js index c039fff8dd4c30..14aca8e788327b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js @@ -25,12 +25,12 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; - new TA().forEach(function() { + new TA(makeCtorArg(0)).forEach(function() { called++; }); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js index b047cce3d40ee6..b0c0e5d7f7f8bc 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js @@ -16,9 +16,7 @@ features: [TypedArray] ---*/ testWithTypedArrayConstructors(function(TA, makeCtorArg) { - var sample1 = new TA(makeCtorArg(3)); - - sample1[1] = 1; + var sample1 = new TA(makeCtorArg(["0", "1", "0"])); sample1.forEach(function() { return 42; diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js index 70ab374a215b0a..a218c7e9345ae1 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js @@ -44,4 +44,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample[0], 7, "changed values after iteration [0] == 7"); assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1"); assert.sameValue(sample[2], 2, "changed values after iteration [2] == 2"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/detached-buffer.js index 9415d549606a08..16d85c5bb29169 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/detached-buffer.js @@ -23,10 +23,10 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.forEach(callbackfn); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/values-are-not-cached.js b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/values-are-not-cached.js index 73647d4520e67e..4d69907917b2fc 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/forEach/values-are-not-cached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/forEach/values-are-not-cached.js @@ -28,4 +28,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { v, 42, "method does not cache values before callbackfn calls" ); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js b/third_party/test262/test/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js index c45405bf86d3ef..d24a2079e4e729 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js @@ -33,8 +33,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - const sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + const sample = new TA(makeCtorArg(1)); const fromIndex = { valueOf() { $DETACHBUFFER(sample.buffer); @@ -43,4 +43,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }; assert.sameValue(sample.includes(0n, fromIndex), false); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js b/third_party/test262/test/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js index 9b79efad06b4f7..ad6a163369b752 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js @@ -3,7 +3,7 @@ /*--- esid: sec-%typedarray%.prototype.includes description: > - Returns false if buffer is detached after ValidateTypedArray and searchElement is a value + Returns true if buffer is detached after ValidateTypedArray and searchElement is undefined info: | %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) @@ -34,8 +34,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - const sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + const sample = new TA(makeCtorArg(1)); const fromIndex = { valueOf() { $DETACHBUFFER(sample.buffer); @@ -44,4 +44,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }; assert.sameValue(sample.includes(undefined, fromIndex), true); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer.js index 8944bbed0a0fac..4cbfc9a57c0f91 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer.js @@ -19,10 +19,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.includes(0n); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js b/third_party/test262/test/built-ins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js index af723ed08f8788..f424bdc3fde679 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js @@ -28,12 +28,12 @@ var fromIndex = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.sameValue(sample.includes(0), false, "returns false"); assert.sameValue(sample.includes(), false, "returns false - no arg"); assert.sameValue( sample.includes(0n, fromIndex), false, "length is checked before ToInteger(fromIndex)" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js b/third_party/test262/test/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js index c8cac5d0dded85..2463120ecd1a82 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js @@ -3,7 +3,7 @@ /*--- esid: sec-%typedarray%.prototype.includes description: > - Returns false if buffer is detached after ValidateTypedArray and searchElement is a value + Returns false if buffer is detached after ValidateTypedArray and searchElement is not undefined info: | %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) @@ -34,8 +34,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - const sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + const sample = new TA(makeCtorArg(1)); const fromIndex = { valueOf() { $DETACHBUFFER(sample.buffer); @@ -44,4 +44,4 @@ testWithTypedArrayConstructors(function(TA) { }; assert.sameValue(sample.includes(0, fromIndex), false); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js b/third_party/test262/test/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js index de8a5f95249d1e..0d3d7f6f29c916 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js @@ -34,8 +34,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - const sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + const sample = new TA(makeCtorArg(1)); const fromIndex = { valueOf() { $DETACHBUFFER(sample.buffer); @@ -44,4 +44,4 @@ testWithTypedArrayConstructors(function(TA) { }; assert.sameValue(sample.includes(undefined, fromIndex), true); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/includes/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/includes/detached-buffer.js index 864871778c725d..1b1ea4750e3860 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/includes/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/includes/detached-buffer.js @@ -19,10 +19,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.includes(0); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/includes/length-zero-returns-false.js b/third_party/test262/test/built-ins/TypedArray/prototype/includes/length-zero-returns-false.js index 0bafd9f9f2a749..45c22ad6fe00b5 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/includes/length-zero-returns-false.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/includes/length-zero-returns-false.js @@ -28,12 +28,12 @@ var fromIndex = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.sameValue(sample.includes(0), false, "returns false"); assert.sameValue(sample.includes(), false, "returns false - no arg"); assert.sameValue( sample.includes(0, fromIndex), false, "length is checked before ToInteger(fromIndex)" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/includes/searchelement-not-integer.js b/third_party/test262/test/built-ins/TypedArray/prototype/includes/searchelement-not-integer.js index f01191e20902c2..08a4672b4c885e 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/includes/searchelement-not-integer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/includes/searchelement-not-integer.js @@ -20,10 +20,5 @@ features: [TypedArray] testWithTypedArrayConstructors(function(TA, makeCtorArg) { var sample = new TA(makeCtorArg(10)); - function throwFunc(){ - throw Test262Error() - return 0; - } - - assert.sameValue(sample.includes({valueOf : throwFunc}), false); + assert.sameValue(sample.includes({ valueOf: Test262Error.thrower }), false); }); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js index bb1774ee0bd20d..6553066e63679c 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- esid: sec-%typedarray%.prototype.indexof -description: Throws a TypeError if this has a detached buffer +description: Returns -1 if buffer is detached after ValidateTypedArray info: | %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] ) @@ -36,8 +36,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - const sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + const sample = new TA(makeCtorArg(1)); const fromIndex = { valueOf() { $DETACHBUFFER(sample.buffer); @@ -46,4 +46,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }; assert.sameValue(sample.indexOf(undefined, fromIndex), -1); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js index 1b877af2548009..31cbc6c8fb2f89 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- esid: sec-%typedarray%.prototype.indexof -description: Throws a TypeError if this has a detached buffer +description: Returns -1 if buffer is detached after ValidateTypedArray info: | %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] ) @@ -36,8 +36,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - const sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + const sample = new TA(makeCtorArg(1)); const fromIndex = { valueOf() { $DETACHBUFFER(sample.buffer); @@ -46,4 +46,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }; assert.sameValue(sample.indexOf(0n, fromIndex), -1); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js index acc7a76616a1c7..7a9ec72f591b60 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js @@ -19,10 +19,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.indexOf(0n); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js b/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js index b43eaff9a326be..9c439b1bc8bc48 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js @@ -27,11 +27,11 @@ var fromIndex = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.sameValue(sample.indexOf(0n), -1, "returns -1"); assert.sameValue( sample.indexOf(0n, fromIndex), -1, "length is checked before ToInteger(fromIndex)" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js index c05fc647ad2382..504bc19ed8e44b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -36,8 +36,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - const sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + const sample = new TA(makeCtorArg(1)); const fromIndex = { valueOf() { $DETACHBUFFER(sample.buffer); @@ -46,4 +46,4 @@ testWithTypedArrayConstructors(function(TA) { }; assert.sameValue(sample.indexOf(undefined, fromIndex), -1); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js index fd044fbd3f52ec..741d44b90d0262 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -36,8 +36,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - const sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + const sample = new TA(makeCtorArg(1)); const fromIndex = { valueOf() { $DETACHBUFFER(sample.buffer); @@ -46,4 +46,4 @@ testWithTypedArrayConstructors(function(TA) { }; assert.sameValue(sample.indexOf(0, fromIndex), -1); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/detached-buffer.js index 573ddc0c800e13..1e01b6c5fd7b4b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/detached-buffer.js @@ -19,10 +19,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.indexOf(0); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js b/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js index 53a8c4fca40b5d..b207ed95daff90 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js @@ -27,11 +27,11 @@ var fromIndex = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.sameValue(sample.indexOf(0), -1, "returns -1"); assert.sameValue( sample.indexOf(0, fromIndex), -1, "length is checked before ToInteger(fromIndex)" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js b/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js index a84d1452159ec6..78107d27bda538 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js @@ -29,8 +29,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - const sample = new TA([1n,2n,3n]); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + const sample = new TA(makeCtorArg([1n,2n,3n])); const separator = { toString() { $DETACHBUFFER(sample.buffer); @@ -39,4 +39,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }; assert.sameValue(sample.join(separator), ',,'); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/detached-buffer.js index c5b584c31eba7b..2e74fd5b995d1e 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/detached-buffer.js @@ -24,10 +24,10 @@ let obj = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - let sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + let sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, () => { sample.join(obj); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js b/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js index c0638c4de873de..c709334d6f4f78 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js @@ -21,9 +21,9 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.sameValue(sample.join(), ""); assert.sameValue(sample.join("test262"), ""); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js index 0bfcc1b17a9ae0..f3cc194015a61b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js @@ -23,10 +23,10 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol(""); -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.join(s); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js b/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js index 7ea61bd4deaf2f..640e7a377bd6dc 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js @@ -27,10 +27,10 @@ var obj = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.join(obj); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js index d89d65b5c6014b..3fe586684335d7 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js @@ -31,8 +31,8 @@ features: [TypedArray] var arr = [-2, Infinity, NaN, -Infinity, 0.6, 9007199254740992]; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(arr); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(arr)); var result, separator, expected; separator = ","; @@ -132,4 +132,4 @@ testWithTypedArrayConstructors(function(TA) { }).join(separator); result = sample.join(separator); assert.sameValue(result, expected, "using: " + separator); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js b/third_party/test262/test/built-ins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js index c44a154e086310..a9a329a677a743 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js @@ -29,8 +29,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - const sample = new TA([1,2,3]); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + const sample = new TA(makeCtorArg([1,2,3])); const separator = { toString() { $DETACHBUFFER(sample.buffer); @@ -39,4 +39,4 @@ testWithTypedArrayConstructors(function(TA) { }; assert.sameValue(sample.join(separator), ',,'); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/join/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/join/detached-buffer.js index 104b20cd40911e..c741b8fb85e684 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/join/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/join/detached-buffer.js @@ -24,10 +24,10 @@ let obj = { } }; -testWithTypedArrayConstructors(function(TA) { - let sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + let sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, () => { sample.join(obj); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/join/empty-instance-empty-string.js b/third_party/test262/test/built-ins/TypedArray/prototype/join/empty-instance-empty-string.js index 5bee678817f248..3b3902132cb223 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/join/empty-instance-empty-string.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/join/empty-instance-empty-string.js @@ -21,9 +21,9 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.sameValue(sample.join(), ""); assert.sameValue(sample.join("test262"), ""); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-value.js index 140967881569eb..a517201d917dcb 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-value.js @@ -30,8 +30,8 @@ features: [TypedArray] var arr = [-2, Infinity, NaN, -Infinity, 0.6, 9007199254740992]; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(arr); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(arr)); // Use converted values using Array methods as helpers var expected = arr.map(function(_, i) { @@ -41,4 +41,4 @@ testWithTypedArrayConstructors(function(TA) { var result = sample.join(); assert.sameValue(result, expected); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js index a1df649ca0e97d..6e930d5b1f7a6b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js @@ -23,10 +23,10 @@ features: [Symbol, TypedArray] var s = Symbol(""); -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.join(s); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/join/return-abrupt-from-separator.js b/third_party/test262/test/built-ins/TypedArray/prototype/join/return-abrupt-from-separator.js index 0a64c53808a35b..ddb5bf3834e5a5 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/join/return-abrupt-from-separator.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/join/return-abrupt-from-separator.js @@ -27,10 +27,10 @@ var obj = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.join(obj); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/keys/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/keys/BigInt/detached-buffer.js index 425f729620c74b..9e0a2d9b056bbc 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/keys/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/keys/BigInt/detached-buffer.js @@ -18,10 +18,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.keys(); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/keys/BigInt/return-itor.js b/third_party/test262/test/built-ins/TypedArray/prototype/keys/BigInt/return-itor.js index e1d9db19333e1e..47698c1f2e91c0 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/keys/BigInt/return-itor.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/keys/BigInt/return-itor.js @@ -14,8 +14,8 @@ features: [BigInt, TypedArray] var sample = [0n, 42n, 64n]; -testWithBigIntTypedArrayConstructors(function(TA) { - var typedArray = new TA(sample); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var typedArray = new TA(makeCtorArg(sample)); var itor = typedArray.keys(); var next = itor.next(); @@ -33,4 +33,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { next = itor.next(); assert.sameValue(next.value, undefined); assert.sameValue(next.done, true); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/keys/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/keys/detached-buffer.js index 8c097b7ee1f2da..72f53aa34bdf77 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/keys/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/keys/detached-buffer.js @@ -18,10 +18,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.keys(); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/keys/return-itor.js b/third_party/test262/test/built-ins/TypedArray/prototype/keys/return-itor.js index 4ea2460883e104..a8802462923407 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/keys/return-itor.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/keys/return-itor.js @@ -14,8 +14,8 @@ features: [TypedArray] var sample = [0, 42, 64]; -testWithTypedArrayConstructors(function(TA) { - var typedArray = new TA(sample); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var typedArray = new TA(makeCtorArg(sample)); var itor = typedArray.keys(); var next = itor.next(); @@ -33,4 +33,4 @@ testWithTypedArrayConstructors(function(TA) { next = itor.next(); assert.sameValue(next.value, undefined); assert.sameValue(next.done, true); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js index 807821f023f00e..7ed8dbf32c31b0 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -33,8 +33,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - const sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + const sample = new TA(makeCtorArg(1)); const fromIndex = { valueOf() { $DETACHBUFFER(sample.buffer); @@ -43,4 +43,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }; assert.sameValue(sample.lastIndexOf(undefined, fromIndex), -1); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js index f4ccfd286438a5..d47563cdb33722 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -33,8 +33,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - const sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + const sample = new TA(makeCtorArg(1)); const fromIndex = { valueOf() { $DETACHBUFFER(sample.buffer); @@ -43,4 +43,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }; assert.sameValue(sample.lastIndexOf(0n, fromIndex), -1); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js index 58c8f2c69e5efb..ef74306fc126fa 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js @@ -19,10 +19,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.lastIndexOf(0n); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js b/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js index f8ba19915467e3..3500cc11009f25 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js @@ -27,11 +27,11 @@ var fromIndex = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.sameValue(sample.lastIndexOf(0), -1, "returns -1"); assert.sameValue( sample.lastIndexOf(0n, fromIndex), -1, "length is checked before ToInteger(fromIndex)" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js index c49ada378e1187..6172c23bbe5bdb 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -33,8 +33,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - const sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + const sample = new TA(makeCtorArg(1)); const fromIndex = { valueOf() { $DETACHBUFFER(sample.buffer); @@ -43,4 +43,4 @@ testWithTypedArrayConstructors(function(TA) { }; assert.sameValue(sample.lastIndexOf(undefined, fromIndex), -1); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js index 120e9b818da652..9273b21fad66e7 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -33,8 +33,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - const sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + const sample = new TA(makeCtorArg(1)); const fromIndex = { valueOf() { $DETACHBUFFER(sample.buffer); @@ -43,4 +43,4 @@ testWithTypedArrayConstructors(function(TA) { }; assert.sameValue(sample.lastIndexOf(0, fromIndex), -1); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer.js index 717f32e8b23bfc..c959b9258f6084 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer.js @@ -19,10 +19,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.lastIndexOf(0); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js b/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js index 6481759acc7a7d..574258158ef97a 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js @@ -27,11 +27,11 @@ var fromIndex = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.sameValue(sample.lastIndexOf(0), -1, "returns -1"); assert.sameValue( sample.lastIndexOf(0, fromIndex), -1, "length is checked before ToInteger(fromIndex)" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/length/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/length/BigInt/detached-buffer.js index 2a0a155fab4657..e752b6f033eba4 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/length/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/length/BigInt/detached-buffer.js @@ -14,8 +14,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(42); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(42)); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.length, 0); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/length/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/length/detached-buffer.js index 9762092255c1d7..232cfe9ab3cda7 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/length/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/length/detached-buffer.js @@ -14,8 +14,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(42); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(42)); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.length, 0); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/arraylength-internal.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/arraylength-internal.js index 6c5a599736b084..897a22fe713189 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/arraylength-internal.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/arraylength-internal.js @@ -41,5 +41,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { return 0n; }); assert.sameValue(loop, 4, "accessor descriptor"); -}, null, ["passthrough"]); - +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js index ded0928ab3594b..d09536931017d7 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js @@ -17,9 +17,9 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.map(function() { if (loops === 0) { @@ -30,4 +30,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js index 8f63f39c28c5fe..fb67cf404c1ae0 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js @@ -17,12 +17,12 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; - new TA().map(function() { + new TA(makeCtorArg(0)).map(function() { called++; }); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js index 4d3cd8b5f4aece..04a907c72a6426 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js @@ -11,9 +11,7 @@ features: [BigInt, TypedArray] ---*/ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { - var sample1 = new TA(makeCtorArg(3)); - - sample1[1] = 1n; + var sample1 = new TA(makeCtorArg(["0", "1", "0"])); sample1.map(function() { return 42n; diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js index dd275585d23453..835888f7faa693 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js @@ -40,4 +40,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7"); assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1"); assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/detached-buffer.js index 76d39d558f56a6..b6626c658cbaa1 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/detached-buffer.js @@ -23,10 +23,10 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.map(callbackfn); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js index dbe9cb5cf08229..8e2eb553b991cb 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js @@ -42,4 +42,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { }); }); assert.sameValue(callCount, 0, "callback should not be called"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js index f419827c62df5a..fb7983ed0dab8f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js @@ -51,4 +51,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { TA, "use defaultCtor on an undefined return - .constructor check" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js index 2fb535f0d3fa78..3d7a09c209e899 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js @@ -42,4 +42,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(Test262Error, function() { sample.map(function() { return 0n; }); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js index ad722cec7f6a88..894a3b4eb2f15f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js @@ -43,4 +43,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { sample.map(function() { return 0n; }); assert.sameValue(calls, 1); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/values-are-not-cached.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/values-are-not-cached.js index 864817dca64073..2b8bc35716d2c1 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/values-are-not-cached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/BigInt/values-are-not-cached.js @@ -25,4 +25,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { return 0n; }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/arraylength-internal.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/arraylength-internal.js index 5c4430109d9f6d..9afaaf8bb221e8 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/arraylength-internal.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/arraylength-internal.js @@ -41,5 +41,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { return 0; }); assert.sameValue(loop, 4, "accessor descriptor"); -}, null, ["passthrough"]); - +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/callbackfn-detachbuffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/callbackfn-detachbuffer.js index a2bc897189260e..1c6d829acaa9ad 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/callbackfn-detachbuffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/callbackfn-detachbuffer.js @@ -17,9 +17,9 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.map(function() { if (loops === 0) { @@ -30,4 +30,4 @@ testWithTypedArrayConstructors(function(TA) { }); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js index 49949decf9007a..624d15fd5d88ac 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js @@ -17,12 +17,12 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; - new TA().map(function() { + new TA(makeCtorArg(0)).map(function() { called++; }); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js index b881bee0b17509..a16f3d04e55968 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js @@ -11,9 +11,7 @@ features: [TypedArray] ---*/ testWithTypedArrayConstructors(function(TA, makeCtorArg) { - var sample1 = new TA(makeCtorArg(3)); - - sample1[1] = 1; + var sample1 = new TA(makeCtorArg(["0", "1", "0"])); sample1.map(function() { return 42; diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js index 97efe48f1eb3a3..111b353e17f4fb 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js @@ -40,4 +40,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample[0], 7, "changed values after iteration [0] == 7"); assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1"); assert.sameValue(sample[2], 2, "changed values after iteration [2] == 2"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/detached-buffer.js index cc00481646dd41..9dd098b47717a8 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/detached-buffer.js @@ -23,10 +23,10 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.map(callbackfn); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-destination-backed-by-immutable-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-destination-backed-by-immutable-buffer.js new file mode 100644 index 00000000000000..78a791367e7e88 --- /dev/null +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-destination-backed-by-immutable-buffer.js @@ -0,0 +1,75 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Throws a TypeError exception when the receiver constructs an instance backed + by an immutable buffer +info: | + %TypedArray%.prototype.map ( callback [ , thisArg ] ) + 1. Let O be the this value. + 2. Let taRecord be ? ValidateTypedArray(O, seq-cst). + 3. Let len be TypedArrayLength(taRecord). + 4. If IsCallable(callback) is false, throw a TypeError exception. + 5. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(len) », ~write~). + 6. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false. + + TypedArraySpeciesCreate ( exemplar, argumentList [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to ~read~. + 2. Let defaultConstructor be the intrinsic object associated with the constructor name exemplar.[[TypedArrayName]] in Table 73. + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Let result be ? TypedArrayCreateFromConstructor(constructor, argumentList, accessMode). + + TypedArrayCreateFromConstructor ( constructor, argumentList [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to ~read~. + 2. Let newTypedArray be ? Construct(constructor, argumentList). + 3. Let taRecord be ? ValidateTypedArray(newTypedArray, seq-cst, accessMode). + + ValidateTypedArray ( O, order [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to read. + 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). + 3. Assert: O has a [[ViewedArrayBuffer]] internal slot. + 4. If accessMode is ~write~ and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. +features: [Symbol.species, TypedArray, immutable-arraybuffer] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithAllTypedArrayConstructors((TA, makeCtorArg) => { + var calls = []; + + var ta = new TA(makeCtorArg(["1", "2"])); + var iab = (new TA(["3", "4"])).buffer.transferToImmutable(); + var constructor = {}; + Object.defineProperty(ta, "constructor", { + get: function() { + calls.push("get ta.constructor"); + return constructor; + } + }); + Object.defineProperty(constructor, Symbol.species, { + get: function() { + calls.push("get ta.constructor[Symbol.species]"); + return function speciesCtor() { + calls.push("construct result"); + var result = new TA(iab); + calls.push("return result"); + return result; + }; + } + }); + + assert.throws(TypeError, function() { + ta.map(function(value, index) { + calls.push("map index " + index); + return value + value; + }); + }); + var expectCalls = [ + "get ta.constructor", + "get ta.constructor[Symbol.species]", + "construct result", + "return result" + ]; + assert.compareArray(calls, expectCalls, "Must construct the result before visiting elements."); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js index af57566325d9d3..1785c6e1b1c24e 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js @@ -42,4 +42,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { }); }); assert.sameValue(callCount, 0, "callback should not be called"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-get-ctor.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-get-ctor.js index 7baee96aff3364..ea9ba0f7a71029 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-get-ctor.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-get-ctor.js @@ -51,4 +51,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { TA, "use defaultCtor on an undefined return - .constructor check" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js index 0bb552550bee35..1c03830ef428fa 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js @@ -42,4 +42,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(Test262Error, function() { sample.map(function() { return 0; }); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-get-species.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-get-species.js index b0f67c5750b9bd..8d06df752fe9c9 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-get-species.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/speciesctor-get-species.js @@ -43,4 +43,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { sample.map(function() {}); assert.sameValue(calls, 1); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/map/values-are-not-cached.js b/third_party/test262/test/built-ins/TypedArray/prototype/map/values-are-not-cached.js index 91aee73a2789c8..ff674c26d68acf 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/map/values-are-not-cached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/map/values-are-not-cached.js @@ -25,4 +25,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { return 0; }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js index a525adf06fbd98..e44cff48d15310 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js @@ -26,9 +26,9 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.reduce(function() { if (loops === 0) { @@ -39,4 +39,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }, 0); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js index d06bacd67dc457..4e46e868f30020 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js @@ -28,12 +28,12 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; - new TA().reduce(function() { + new TA(makeCtorArg(0)).reduce(function() { called++; }, undefined); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js index d34c2b8c91f258..b3d0cebb39ae37 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js @@ -46,4 +46,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7"); assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1"); assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/detached-buffer.js index 5efbe4a86d8b65..3381e3187e0f1e 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/detached-buffer.js @@ -23,10 +23,10 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.reduce(callbackfn); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js index 97d68c270804fc..e4647e0771694b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js @@ -30,12 +30,12 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var called = false; - var result = new TA().reduce(function() { + var result = new TA(makeCtorArg(0)).reduce(function() { called = true; }, 42); assert.sameValue(result, 42); assert.sameValue(called, false); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js index 17a37f79259f36..1e6dcf12efecf4 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js @@ -21,14 +21,15 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; + var ta = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { - new TA().reduce(function() { + ta.reduce(function() { called++; }); }); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js index b7a6061745f2da..9f866b86f49105 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js @@ -38,4 +38,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { v, 42n, "method does not cache values before callbackfn calls" ); }, 0); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js index dfc80fff398f5e..483f512857eaec 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js @@ -26,9 +26,9 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.reduce(function() { if (loops === 0) { @@ -39,4 +39,4 @@ testWithTypedArrayConstructors(function(TA) { }, 0); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js index 988ca67d0e45de..290ece99c74962 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js @@ -28,12 +28,12 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; - new TA().reduce(function() { + new TA(makeCtorArg(0)).reduce(function() { called++; }, undefined); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js index a041518247d1c2..a8ab14d9fc6694 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js @@ -46,4 +46,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample[0], 7, "changed values after iteration [0] == 7"); assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1"); assert.sameValue(sample[2], 2, "changed values after iteration [2] == 2"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/detached-buffer.js index 133253fa1fb4cd..18617d2b01a09e 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/detached-buffer.js @@ -23,10 +23,10 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.reduce(callbackfn); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js index b8c6dba5b4ce57..8a2e697bface28 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js @@ -30,12 +30,12 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var called = false; - var result = new TA().reduce(function() { + var result = new TA(makeCtorArg(0)).reduce(function() { called = true; }, 42); assert.sameValue(result, 42); assert.sameValue(called, false); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js index fd902fd1f08afc..1181bbedc98384 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js @@ -21,14 +21,15 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; + var ta = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { - new TA().reduce(function() { + ta.reduce(function() { called++; }); }); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/values-are-not-cached.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/values-are-not-cached.js index c3a82924fe99a6..031983b8290a31 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduce/values-are-not-cached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduce/values-are-not-cached.js @@ -38,4 +38,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { v, 42, "method does not cache values before callbackfn calls" ); }, 0); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js index d25ffa51d0f24a..ed395786eebc51 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js @@ -26,9 +26,9 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.reduceRight(function() { if (loops === 0) { @@ -39,4 +39,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }, 0); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js index 3dec96ab450d71..ca4049f618dc03 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js @@ -29,12 +29,12 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; - new TA().reduceRight(function() { + new TA(makeCtorArg(0)).reduceRight(function() { called++; }, undefined); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js index 9963bec62125ab..e7ff0179b09a0e 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js @@ -46,4 +46,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample[0], 2n, "changed values after iteration [0] == 2"); assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1"); assert.sameValue(sample[2], 7n, "changed values after iteration [2] == 7"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js index 3bad2c54ed6212..f519ea122ccb82 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js @@ -23,10 +23,10 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.reduceRight(callbackfn); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js index 7a066ea9303ab8..7380c6b09e2b31 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js @@ -31,12 +31,12 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var called = false; - var result = new TA().reduceRight(function() { + var result = new TA(makeCtorArg(0)).reduceRight(function() { called = true; }, 42); assert.sameValue(result, 42); assert.sameValue(called, false); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js index 51d93596386847..d5ff1b3d156f0c 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js @@ -21,14 +21,15 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; + var ta = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { - new TA().reduceRight(function() { + ta.reduceRight(function() { called++; }); }); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js index 0d39a9984c31be..421feff4dfa3f9 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js @@ -39,4 +39,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { v, 42n, "method does not cache values before callbackfn calls" ); }, 0); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js index c6f517c5ec91e3..eae63b762b63c5 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js @@ -26,9 +26,9 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.reduceRight(function() { if (loops === 0) { @@ -39,4 +39,4 @@ testWithTypedArrayConstructors(function(TA) { }, 0); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js index ce7443ce2b5c40..3efc294cabc846 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js @@ -29,12 +29,12 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; - new TA().reduceRight(function() { + new TA(makeCtorArg(0)).reduceRight(function() { called++; }, undefined); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js index d7279b5db34e54..105a8150bdd81f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js @@ -46,4 +46,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample[0], 2, "changed values after iteration [0] == 2"); assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1"); assert.sameValue(sample[2], 7, "changed values after iteration [2] == 7"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/detached-buffer.js index 1270aed0678aa3..320972a2b85f1e 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/detached-buffer.js @@ -29,4 +29,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { sample.reduceRight(callbackfn); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js index 512b3f77ef9aef..b39670290d7c61 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js @@ -31,12 +31,12 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var called = false; - var result = new TA().reduceRight(function() { + var result = new TA(makeCtorArg(0)).reduceRight(function() { called = true; }, 42); assert.sameValue(result, 42); assert.sameValue(called, false); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js index e0b9a72c3c13e6..7d387c6c561f4d 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js @@ -21,14 +21,15 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; + var ta = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { - new TA().reduceRight(function() { + ta.reduceRight(function() { called++; }); }); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/values-are-not-cached.js b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/values-are-not-cached.js index 3d0a5519a42ec9..be5eb0808694f2 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/values-are-not-cached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reduceRight/values-are-not-cached.js @@ -39,4 +39,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { v, 42, "method does not cache values before callbackfn calls" ); }, 0); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reverse/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/reverse/BigInt/detached-buffer.js index ddf7fee94aa4e8..6d577a080f94a7 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reverse/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reverse/BigInt/detached-buffer.js @@ -19,10 +19,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.reverse(); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js b/third_party/test262/test/built-ins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js index 2a663668ee2d7e..70402a3b3a9a7b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js @@ -32,4 +32,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(result.foo, 42, "sample.foo === 42"); assert.sameValue(result.bar, "bar", "sample.bar === 'bar'"); assert.sameValue(result[s], 1, "sample[s] === 1"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reverse/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/reverse/detached-buffer.js index f21ca1509b7084..544f0968630666 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reverse/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reverse/detached-buffer.js @@ -19,10 +19,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.reverse(); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reverse/immutable-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/reverse/immutable-buffer.js new file mode 100644 index 00000000000000..4e241ede5f77c4 --- /dev/null +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reverse/immutable-buffer.js @@ -0,0 +1,28 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Throws a TypeError exception when the backing buffer is immutable +info: | + %TypedArray%.prototype.reverse ( ) + 1. Let O be the this value. + 2. Let taRecord be ? ValidateTypedArray(O, ~seq-cst~, ~write~). + + ValidateTypedArray ( O, order [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to read. + 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). + 3. Assert: O has a [[ViewedArrayBuffer]] internal slot. + 4. If accessMode is ~write~ and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. +features: [TypedArray, immutable-arraybuffer] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithAllTypedArrayConstructors((TA, makeCtorArg) => { + var ta = new TA(makeCtorArg(["1", "2", "3", "4"])); + + assert.throws(TypeError, function() { + ta.reverse(); + }); + assert.compareArray(ta, new TA(["1", "2", "3", "4"]), "Must not mutate contents."); +}, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js b/third_party/test262/test/built-ins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js index 0632ed701f34c7..00efdaaceb9b6a 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js @@ -32,4 +32,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(result.foo, 42, "sample.foo === 42"); assert.sameValue(result.bar, "bar", "sample.bar === 'bar'"); assert.sameValue(result[s], 1, "sample[s] === 1"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js index 59f835b1ecc972..2d562409d4e536 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js @@ -32,4 +32,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(RangeError, function() { sample.set([1n], -Infinity); }, "-Infinity"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js index 7881ec2f5f929d..763b727f3b05df 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js @@ -92,4 +92,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { sample = new TA(makeCtorArg([1n, 2n])); sample.set([42n], { toString: function() {return 1;} }); assert(compareArray(sample, [1n, 42n]), "toString"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js index ef43f7c6ab5c3f..4dcae955b02822 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js @@ -46,4 +46,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var ta5 = new TA(makeCtorArg([1n, 2n])); ta5.set(4n, 1); assert.compareArray(ta5, [1n, 2n], "bigint"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js index 64f45d84424282..f975d84447221f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js @@ -30,4 +30,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(Test262Error, function() { sample.set(obj); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js index eeba8b5909b51f..78a40ef0a01e39 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js @@ -45,4 +45,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(sample, [42n, 43n, 3n, 4n]), "values are set until exception" ); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js index 7ec8091334e703..4e9607d121e030 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js @@ -27,4 +27,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(TypeError, function() { sample.set(obj); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js index 2ae67acf475155..2351f646dd0e5f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js @@ -43,4 +43,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(Test262Error, function() { sample.set(obj2); }, "toString"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js index c0bff8ccc680b8..6003013e876473 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js @@ -41,4 +41,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(sample, [42n, 43n, 3n, 4n]), "values are set until exception" ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js index a2f07e27de214f..92d4f232e3c3d6 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js @@ -45,4 +45,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(sample, [42n, 43n, 3n, 4n]), "values are set until exception" ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js index 3eebeace70cb65..d7294c6b02696f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -24,4 +24,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(TypeError, function() { sample.set([1n], s); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js index bda1b0e6edc04c..1c75869170e9c9 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js @@ -28,8 +28,8 @@ var obj2 = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.set([], obj1); @@ -38,4 +38,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { sample.set([], obj2); }, "abrupt from toString"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js index 9c3215c13a836a..bed306ceb09ed0 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js @@ -27,4 +27,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(TypeError, function() { sample.set(null); }, "null"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js index 9b6df38959d913..6a95539cfc3014 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js @@ -69,4 +69,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(calls, [0, "0,0,0,0,0", 1, "0,42,0,0,0", 2, "0,42,43,0,0"]), "values are set in order" ); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-set-values.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-set-values.js index 5386252f0e8b47..898af13bd6b521 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-set-values.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-set-values.js @@ -60,4 +60,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { result = sample.set(srcObj, 2); assert(compareArray(sample, [1n, 2n, 7n, 17n]), "offset: 2, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js index 2a4daedc18a640..aabe13fbea2616 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js @@ -46,4 +46,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(sample, expected), "sample: [" + sample + "], expected: [" + expected + "]" ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js index 239c5dfee9f57d..b03f16fb4f5e44 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js @@ -44,4 +44,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { sample.set(obj); assert(compareArray(sample, [42n, 43n, 44n, 45n, 46n])); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js index b6bc54d4995a0e..522209ebfb988d 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js @@ -21,8 +21,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(2); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(2)); var calledOffset = 0; var obj = { valueOf: function() { @@ -36,4 +36,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }); assert.sameValue(calledOffset, 1); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js index e90286fabffc8d..b59911ca667d73 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js @@ -29,8 +29,8 @@ Object.defineProperty(obj, "length", { } }); -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(2); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(2)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { @@ -40,4 +40,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { sample.set(obj); }, "IsDetachedBuffer happens before Get(src.length)"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/boolean-tobigint.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/boolean-tobigint.js index 145acd501a52d5..171c667be38492 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/boolean-tobigint.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/boolean-tobigint.js @@ -43,4 +43,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(typedArray[0], 0n, "False converts to BigInt"); assert.sameValue(typedArray[1], 1n, "True converts to BigInt"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/null-tobigint.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/null-tobigint.js index 2607350f88998e..7285917ae47a8f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/null-tobigint.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/null-tobigint.js @@ -44,4 +44,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { typedArray.set([null]); }, "abrupt completion from Null"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/number-tobigint.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/number-tobigint.js index c232e62a955c86..c0985c79b68eb9 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/number-tobigint.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/number-tobigint.js @@ -69,4 +69,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { typedArray.set([NaN]); }, "abrupt completion from Number: NaN"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-big.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-big.js index ffa2014fc3b4ed..60285073158918 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-big.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-big.js @@ -34,5 +34,5 @@ testWithBigIntTypedArrayConstructors(function(BTA1, makeCtorArg) { assert.sameValue(targetTypedArray[0], testValue, "Setting BigInt TypedArray with BigInt TypedArray should succeed.") }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js index 94a148d6084600..824e9df2825cda 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js @@ -34,4 +34,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { }); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js index 1eb65b55272d10..c26fb44a24b419 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js @@ -47,4 +47,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { typedArray.set(["definately not a number"]); }, "StringToBigInt(prim) == NaN"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/string-tobigint.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/string-tobigint.js index c1ade89f3a0baa..c31a7a37b5cd38 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/string-tobigint.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/string-tobigint.js @@ -63,4 +63,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { typedArray.set(["1e7"]); }, "Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow... exponents..."); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/symbol-tobigint.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/symbol-tobigint.js index ea11e3f658f4aa..dafea15a6d2f98 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/symbol-tobigint.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/symbol-tobigint.js @@ -47,4 +47,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { typedArray.set([s]); }, "abrupt completion from Symbol"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js index 010aeb6c100f90..93e8dd0d927231 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js @@ -16,8 +16,8 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(RangeError, function() { sample.set(sample, -1); @@ -30,4 +30,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(RangeError, function() { sample.set(sample, -Infinity); }, "-Infinity"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js index 57c0f8400e6f8d..3341e2c208af6a 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js @@ -90,4 +90,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { sample = new TA(makeCtorArg([1n, 2n])); sample.set(src, { toString: function() {return 1;} }); assert(compareArray(sample, [1n, 42n]), "toString"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js index 975f32e0179b49..ce039bab60bca5 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -17,10 +17,10 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol("1"); -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.set(sample, s); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js index 9b8daee83ed569..92dd0e0851e174 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js @@ -27,8 +27,8 @@ var obj2 = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.set(sample, obj1); @@ -37,4 +37,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { sample.set(sample, obj2); }, "abrupt from toString"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js index 658bd816ea3691..4256ed9da3a5a3 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js @@ -101,4 +101,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { result = sample.set(src, 2); assert(compareArray(sample, [1n, 2n, 42n, 43n]), "src and sample are SAB-backed, offset: 2, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js index b827fae6cbc05f..c2b3fa9e4dc47b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js @@ -45,4 +45,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { result = sample.set(src, 2); assert(compareArray(sample, [1n, 2n, 42n, 43n]), "offset: 2, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js index 359c874d7beb0d..ab1da824e553da 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js @@ -101,4 +101,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { result = sample.set(src, 2); assert(compareArray(sample, [1n, 2n, 42n, 43n]), "src and sample are SAB-backed, offset: 2, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js index e769cb25669dfb..b0f26dc3876832 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js @@ -47,4 +47,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { result = sample.set(src, 2); assert(compareArray(sample, [1n, 2n, 42n, 43n]), "offset: 2, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js index 277cbc4625251b..d1ae10702f7350 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js @@ -50,4 +50,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { result = sample.set(src, 2); assert(compareArray(sample, [1n, 2n, 1n, 2n]), "offset: 2, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js index 9a6edd04bc94c1..12ccbc10181de8 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js @@ -48,4 +48,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(RangeError, function() { sample.set(src, Infinity); }, "2 + Infinity > 2"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js index 8f46df093d1f86..07ce1269ea2302 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js @@ -20,9 +20,9 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var sample = new TA(); - var target = new TA(); + var target = new TA(makeCtorArg(0)); var calledOffset = 0; var obj = { valueOf: function() { @@ -36,4 +36,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }); assert.sameValue(calledOffset, 1); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js index 9fc4b311cda61e..048058079d6487 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js @@ -41,4 +41,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { sample.set(src3); assert.sameValue(getCalls, 0, "ignores byteoffset properties"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js index 3a486f448ad4fb..7c69b09d3cc85d 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js @@ -20,9 +20,9 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(2); - var src = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(2)); + var src = new TA(makeCtorArg(1)); var calledOffset = 0; var obj = { valueOf: function() { @@ -36,4 +36,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }); assert.sameValue(calledOffset, 1); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/undefined-tobigint.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/undefined-tobigint.js index 40baab50cbab75..f11e3fbd3fb56c 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/undefined-tobigint.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/BigInt/undefined-tobigint.js @@ -44,4 +44,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { typedArray.set([undefined]); }, "abrupt completion from undefined"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js index 90530ac7dfdf02..a8e02416740454 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js @@ -32,4 +32,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(RangeError, function() { sample.set([1], -Infinity); }, "-Infinity"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-offset-tointeger.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-offset-tointeger.js index fcbb913775d9d1..2e4913dc1ed0b1 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-offset-tointeger.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-offset-tointeger.js @@ -92,4 +92,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { sample = new TA(makeCtorArg([1, 2])); sample.set([42], { toString: function() {return 1;} }); assert(compareArray(sample, [1, 42]), "toString"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-primitive-toobject.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-primitive-toobject.js index e397b8d7b9bd18..e3abbd85ee81d7 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-primitive-toobject.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-primitive-toobject.js @@ -43,4 +43,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { var ta4 = new TA(makeCtorArg([1])); ta4.set(Symbol()); assert.compareArray(ta4, [1], "symbol"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js index 495fa07f2d70e0..bd927773222b71 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js @@ -30,4 +30,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(Test262Error, function() { sample.set(obj); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js index 5cd057e7223b1d..2bb8ed9f163bec 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js @@ -45,4 +45,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(sample, [42, 43, 3, 4]), "values are set until exception" ); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js index c2136b4c1188ef..d1ed8e8ab3c383 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js @@ -27,4 +27,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(TypeError, function() { sample.set(obj); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js index 6797a63e388cbd..d87acdb00622bc 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js @@ -43,4 +43,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(Test262Error, function() { sample.set(obj2); }, "toString"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js index 3b7b921da33710..1a6ed01e39ccb6 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js @@ -41,4 +41,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(sample, [42, 43, 3, 4]), "values are set until exception" ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js index 2f7572c5d5f18a..0f0215ff929dca 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js @@ -45,4 +45,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(sample, [42, 43, 3, 4]), "values are set until exception" ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js index c3bb22083ba04f..134526a67dcae3 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -24,4 +24,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(TypeError, function() { sample.set([1], s); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js index c6cbd416111125..62828368034f0f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js @@ -28,8 +28,8 @@ var obj2 = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.set([], obj1); @@ -38,4 +38,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { sample.set([], obj2); }, "abrupt from toString"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js index 75f063a67620f8..3da0ffd36b1c96 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js @@ -27,4 +27,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(TypeError, function() { sample.set(null); }, "null"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-set-values-in-order.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-set-values-in-order.js index cc28f1ef742f83..741799dcf024cb 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-set-values-in-order.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-set-values-in-order.js @@ -69,4 +69,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(calls, [0, "0,0,0,0,0", 1, "0,42,0,0,0", 2, "0,42,43,0,0"]), "values are set in order" ); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-set-values.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-set-values.js index cd9308e5b130d9..b0e0ba19d041c9 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-set-values.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-set-values.js @@ -60,4 +60,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { result = sample.set(srcObj, 2); assert(compareArray(sample, [1, 2, 7, 17]), "offset: 2, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js index 9013cdf89e963a..ffc3cafede8c30 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js @@ -46,4 +46,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(sample, expected), "sample: [" + sample + "], expected: [" + expected + "]" ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js index 9489cf8a7eb06b..e84f91f6819908 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js @@ -44,4 +44,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { sample.set(obj); assert(compareArray(sample, [42, 43, 44, 45, 46])); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js index a97247753335d8..b8a045689b3e91 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js @@ -8,8 +8,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA([1, 2, 3]); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg([1, 2, 3])); var obj = { length: 3, "0": 42 @@ -33,4 +33,4 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(0, sample.byteLength); assert.sameValue(0, sample.byteOffset); assert.sameValue(0, sample.length); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js index a59b405d08903c..0d4e8ebda42af3 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js @@ -21,8 +21,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(2); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(2)); var calledOffset = 0; var obj = { valueOf: function() { @@ -36,4 +36,4 @@ testWithTypedArrayConstructors(function(TA) { }); assert.sameValue(calledOffset, 1); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js index a23a66fcee2030..705d60ed0200d1 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js @@ -29,8 +29,8 @@ Object.defineProperty(obj, "length", { } }); -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(2); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(2)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { @@ -40,4 +40,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { sample.set(obj); }, "IsDetachedBuffer happens before Get(src.length)"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/bit-precision.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/bit-precision.js index 10cda34466241b..86af442f4f9e62 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/bit-precision.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/bit-precision.js @@ -19,8 +19,8 @@ includes: [nans.js, compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function body(FA) { - var source = new FA(NaNs); +testWithTypedArrayConstructors(function body(FA, makeCtorArg) { + var source = new FA(makeCtorArg(NaNs)); var target = new FA(NaNs.length); var sourceBytes, targetBytes; @@ -30,4 +30,4 @@ testWithTypedArrayConstructors(function body(FA) { targetBytes = new Uint8Array(target.buffer); assert(compareArray(sourceBytes, targetBytes)) -}, floatArrayConstructors); +}, floatArrayConstructors, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/immutable-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/immutable-buffer.js new file mode 100644 index 00000000000000..c4d1db5d1fb8a1 --- /dev/null +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/immutable-buffer.js @@ -0,0 +1,45 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.set +description: Throws a TypeError exception when the backing buffer is immutable +info: | + %TypedArray%.prototype.set ( source [ , offset ] ) + 1. Let target be the this value. + ... + 3. Perform ? RequireInternalSlot(target, [[TypedArrayName]]). + 4. Assert: target has a [[ViewedArrayBuffer]] internal slot. + 5. If IsImmutableBuffer(target.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + 6. Let targetOffset be ? ToIntegerOrInfinity(offset). +features: [TypedArray, immutable-arraybuffer] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithAllTypedArrayConstructors((TA, makeCtorArg) => { + var calls = []; + + var ta = new TA(makeCtorArg(["1", "2", "3", "4"])); + var source = { + get length() { + calls.push("get source.length"); + return 1; + }, + get 0() { + calls.push("get source[0]"); + return "8"; + }, + }; + var offset = { + valueOf() { + calls.push("offset.valueOf"); + return 1; + } + }; + + assert.throws(TypeError, function() { + ta.set(source, offset); + }); + assert.compareArray(calls, [], "Must verify mutability before reading arguments."); + assert.compareArray(ta, new TA(["1", "2", "3", "4"]), "Must not mutate contents."); +}, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/src-typedarray-big-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/src-typedarray-big-throws.js index 096204e90c3db6..1241ae22342d81 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/src-typedarray-big-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/src-typedarray-big-throws.js @@ -34,4 +34,4 @@ testWithBigIntTypedArrayConstructors(function(BTA, makeCtorArg) { }); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js index 7f66f9242cd744..58746ad3a1711b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js @@ -16,8 +16,8 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(RangeError, function() { sample.set(sample, -1); @@ -30,4 +30,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(RangeError, function() { sample.set(sample, -Infinity); }, "-Infinity"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js index 31c6b0e48e9bc6..75fc5dd2b9bd7a 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js @@ -90,4 +90,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { sample = new TA(makeCtorArg([1, 2])); sample.set(src, { toString: function() {return 1;} }); assert(compareArray(sample, [1, 42]), "toString"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js index 485a5c19cff9ae..54b97091c6bd5f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -17,10 +17,10 @@ features: [Symbol, TypedArray] var s = Symbol("1"); -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.set(sample, s); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js index 09f4b666c23dcf..14cf81ab2562b2 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js @@ -27,8 +27,8 @@ var obj2 = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.set(sample, obj1); @@ -37,4 +37,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { sample.set(sample, obj2); }, "abrupt from toString"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js index 00a8e90ebdc3de..f1be34eff243fc 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js @@ -104,4 +104,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { result = sample.set(src, 2); assert(compareArray(sample, [1, 2, 42, 43]), "src and sample are SAB-backed, offset: 2, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); -}, int_views); +}, int_views, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js index 9a10d8a29bc384..3f39010c172147 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js @@ -45,4 +45,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { result = sample.set(src, 2); assert(compareArray(sample, [1, 2, 42, 43]), "offset: 2, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js index 1158f7652effa2..fd01d5f5de727c 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js @@ -104,4 +104,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { result = sample.set(src, 2); assert(compareArray(sample, [1, 2, 42, 43]), "src and sample are SAB-backed, offset: 2, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); -}, int_views); +}, int_views, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js index f82d316f0d69fd..1ff070cc1ce1f3 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js @@ -47,4 +47,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { result = sample.set(src, 2); assert(compareArray(sample, [1, 2, 42, 43]), "offset: 2, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js index 864da2c22e2340..f625ebced7f2d2 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js @@ -57,4 +57,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert(compareArray(sample, expected[TA.name]), sample); assert.sameValue(result, undefined, "returns undefined"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js index bf15d65cece469..e5706a4148ab15 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js @@ -50,4 +50,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { result = sample.set(src, 2); assert(compareArray(sample, [1, 2, 1, 2]), "offset: 2, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js index a592458dd11bd9..2c09495e535658 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js @@ -48,4 +48,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(RangeError, function() { sample.set(src, Infinity); }, "2 + Infinity > 2"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js index f470b1eb4964eb..b1b45b05cfddbd 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js @@ -20,9 +20,9 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var sample = new TA(); - var target = new TA(); + var target = new TA(makeCtorArg(0)); var calledOffset = 0; var obj = { valueOf: function() { @@ -36,4 +36,4 @@ testWithTypedArrayConstructors(function(TA) { }); assert.sameValue(calledOffset, 1); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js index 2dfd361cda0c51..3ecb08eeb4d10c 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js @@ -20,9 +20,9 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(2); - var src = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(2)); + var src = new TA(makeCtorArg(1)); var calledOffset = 0; var obj = { valueOf: function() { @@ -36,4 +36,4 @@ testWithTypedArrayConstructors(function(TA) { }); assert.sameValue(calledOffset, 1); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js index e282d415917658..2e84ed5f648ee5 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js @@ -31,15 +31,15 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { let counter = 0; - var sample = new TA(1); + var sample = new TA(makeCtorArg(1)); sample.constructor = {}; sample.constructor[Symbol.species] = function(count) { var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array; - counter++; $DETACHBUFFER(sample.buffer); + counter++; return new other(count); }; @@ -49,4 +49,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }, '`sample.slice()` throws TypeError'); assert.sameValue(counter, 2, 'The value of `counter` is 2'); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js index 02ef04db075fc7..4c9a80c9110f28 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js @@ -31,15 +31,15 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { let counter = 0; - let sample = new TA(1); + let sample = new TA(makeCtorArg(1)); sample.constructor = {}; sample.constructor[Symbol.species] = function(count) { - counter++; $DETACHBUFFER(sample.buffer); - return new TA(count); + counter++; + return new TA(makeCtorArg(count)); }; assert.throws(TypeError, function() { @@ -48,4 +48,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }, '`sample.slice()` throws TypeError'); assert.sameValue(counter, 2, 'The value of `counter` is 2'); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js index 44e0f109af3a19..f52a353d27fe0d 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js @@ -31,14 +31,14 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { let counter = 0; - let sample = new TA(1); + let sample = new TA(makeCtorArg(1)); Object.defineProperty(sample, "constructor", { get() { - counter++; $DETACHBUFFER(sample.buffer); + counter++; } }); assert.throws(TypeError, function() { @@ -47,4 +47,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }, '`sample.slice()` throws TypeError'); assert.sameValue(counter, 2, 'The value of `counter` is 2'); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js index 11e70b69d45692..d06b74346b0340 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js @@ -30,15 +30,15 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { let counter = 0; - let sample = new TA(1); + let sample = new TA(makeCtorArg(1)); sample.constructor = {}; sample.constructor[Symbol.species] = function(count) { let other = new TA(count); - counter++; $DETACHBUFFER(other.buffer); + counter++; return other; }; @@ -48,4 +48,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }, '`sample.slice()` throws TypeError'); assert.sameValue(counter, 2, 'The value of `counter` is 2'); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js index d2000c97e2beb2..4c9b184e899bfd 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js @@ -17,19 +17,19 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { let counter = 0; let sample, result, Other, other; let ctor = {}; ctor[Symbol.species] = function(count) { - counter++; Other = TA === BigInt64Array ? BigUint64Array : BigInt64Array; $DETACHBUFFER(sample.buffer); + counter++; other = new Other(count); return other; }; - sample = new TA(0); + sample = new TA(makeCtorArg(0)); sample.constructor = ctor; result = sample.slice(); assert.sameValue(result.length, 0, 'The value of result.length is 0'); @@ -38,8 +38,8 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.sameValue(result, other, 'The value of `result` is expected to equal the value of other'); assert.sameValue(counter, 1, 'The value of `counter` is 1'); - sample = new TA(4); + sample = new TA(makeCtorArg(4)); sample.constructor = ctor; sample.slice(1, 1); // count = 0; assert.sameValue(counter, 2, 'The value of `counter` is 2'); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js index 28b42831038fc0..e81f32030805d6 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js @@ -16,18 +16,18 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { let counter = 0; let sample, result, other; let ctor = {}; ctor[Symbol.species] = function(count) { - counter++; $DETACHBUFFER(sample.buffer); - other = new TA(count); + counter++; + other = new TA(makeCtorArg(count)); return other; }; - sample = new TA(0); + sample = new TA(makeCtorArg(0)); sample.constructor = ctor; result = sample.slice(); assert.sameValue(result.length, 0, 'The value of result.length is 0'); @@ -35,7 +35,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.sameValue(result, other, 'The value of `result` is expected to equal the value of other'); assert.sameValue(counter, 1, 'The value of `counter` is 1'); - sample = new TA(4); + sample = new TA(makeCtorArg(4)); sample.constructor = ctor; result = sample.slice(1, 1); // count = 0; assert.sameValue(result.length, 0, 'The value of result.length is 0'); @@ -46,4 +46,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { ); assert.sameValue(result.constructor, TA, 'The value of result.constructor is expected to equal the value of TA'); assert.sameValue(counter, 2, 'The value of `counter` is 2'); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer.js index 6a1505a6832985..d27e10bf15e4e2 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer.js @@ -24,10 +24,10 @@ var obj = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.slice(obj, obj); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js index 4ededf13d9475c..5fa95cde553683 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js @@ -16,10 +16,10 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol("1"); -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.slice(0, s); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js index 92b322d45e2154..ac95ebfde0bcdb 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js @@ -26,8 +26,8 @@ var o2 = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.slice(0, o1); @@ -36,4 +36,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { sample.slice(0, o2); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js index 39aeda0c7c4dbd..9294630901d8b2 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js @@ -15,10 +15,10 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol("1"); -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.slice(s); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js index 031693a8310fc9..34f9cff342b375 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js @@ -25,8 +25,8 @@ var o2 = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.slice(o1); @@ -35,4 +35,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { sample.slice(o2); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js index 59a8f98fbb3b58..03617c64a27a80 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js @@ -32,8 +32,8 @@ features: [BigInt, Symbol.species, TypedArray] var arr = [42n, 43n, 44n]; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(arr); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(arr)); var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array; sample.constructor = {}; @@ -44,4 +44,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert(compareArray(result, arr), "values are set"); assert.notSameValue(result.buffer, sample.buffer, "creates a new buffer"); assert.sameValue(result.constructor, other, "used the custom ctor"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js index 7ff0f281b382fd..14f0026f174aec 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js @@ -38,4 +38,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(Test262Error, function() { sample.slice(); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js index ff4c3a55700af7..13c3a3ba4ff0c2 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js @@ -51,4 +51,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { TA, "use defaultCtor on an undefined return - .constructor check" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js index 615e9c93174cf3..da0fda3ee208e9 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js @@ -42,4 +42,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(Test262Error, function() { sample.slice(); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js index 199fb6d27522aa..0e708d56968301 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js @@ -43,4 +43,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { sample.slice(); assert.sameValue(calls, 1); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js index 55d3d3af75ddfd..b8348bb1f1fa45 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js @@ -17,15 +17,15 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { let counter = 0; - var sample = new TA(1); + var sample = new TA(makeCtorArg(1)); sample.constructor = {}; sample.constructor[Symbol.species] = function(count) { var other = TA === Int8Array ? Int16Array : Int8Array; - counter++; $DETACHBUFFER(sample.buffer); + counter++; return new other(count); }; @@ -35,4 +35,4 @@ testWithTypedArrayConstructors(function(TA) { }, '`sample.slice()` throws TypeError'); assert.sameValue(counter, 2, 'The value of `counter` is 2'); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js index 83eb3abd95ad4b..67457b2c87b4f8 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js @@ -15,15 +15,15 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { let counter = 0; - let sample = new TA(1); + let sample = new TA(makeCtorArg(1)); sample.constructor = {}; sample.constructor[Symbol.species] = function(count) { - counter++; $DETACHBUFFER(sample.buffer); - return new TA(count); + counter++; + return new TA(makeCtorArg(count)); }; assert.throws(TypeError, function() { @@ -32,4 +32,4 @@ testWithTypedArrayConstructors(function(TA) { }, '`sample.slice()` throws TypeError'); assert.sameValue(counter, 2, 'The value of `counter` is 2'); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-get-ctor.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-get-ctor.js index 2b37e081384366..131f01410ace2f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-get-ctor.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-get-ctor.js @@ -15,14 +15,14 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { let counter = 0; - let sample = new TA(1); + let sample = new TA(makeCtorArg(1)); Object.defineProperty(sample, "constructor", { get() { - counter++; $DETACHBUFFER(sample.buffer); + counter++; } }); assert.throws(TypeError, function() { @@ -31,4 +31,4 @@ testWithTypedArrayConstructors(function(TA) { }, '`sample.slice()` throws TypeError'); assert.sameValue(counter, 2, 'The value of `counter` is 2'); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js index d8abf5034b173b..60349317faaa56 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js @@ -30,15 +30,15 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { let counter = 0; - let sample = new TA(1); + let sample = new TA(makeCtorArg(1)); sample.constructor = {}; sample.constructor[Symbol.species] = function(count) { let other = new TA(count); - counter++; $DETACHBUFFER(other.buffer); + counter++; return other; }; @@ -48,4 +48,4 @@ testWithTypedArrayConstructors(function(TA) { }, '`sample.slice()` throws TypeError'); assert.sameValue(counter, 2, 'The value of `counter` is 2'); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js index 1b778ec473e890..23f7e612a950ed 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js @@ -17,19 +17,19 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { let counter = 0; let sample, result, Other, other; let ctor = {}; ctor[Symbol.species] = function(count) { - counter++; Other = TA === Int16Array ? Int8Array : Int16Array; $DETACHBUFFER(sample.buffer); + counter++; other = new Other(count); return other; }; - sample = new TA(0); + sample = new TA(makeCtorArg(0)); sample.constructor = ctor; result = sample.slice(); assert.sameValue(result.length, 0, 'The value of result.length is 0'); @@ -38,8 +38,8 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(result, other, 'The value of `result` is expected to equal the value of other'); assert.sameValue(counter, 1, 'The value of `counter` is 1'); - sample = new TA(4); + sample = new TA(makeCtorArg(4)); sample.constructor = ctor; sample.slice(1, 1); // count = 0; assert.sameValue(counter, 2, 'The value of `counter` is 2'); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js index f996487df9f5f7..5fd7ff35cda491 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js @@ -16,18 +16,18 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { let counter = 0; let sample, result, other; let ctor = {}; ctor[Symbol.species] = function(count) { - counter++; $DETACHBUFFER(sample.buffer); - other = new TA(count); + counter++; + other = new TA(makeCtorArg(count)); return other; }; - sample = new TA(0); + sample = new TA(makeCtorArg(0)); sample.constructor = ctor; result = sample.slice(); assert.sameValue(result.length, 0, 'The value of result.length is 0'); @@ -35,8 +35,8 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(result, other, 'The value of `result` is expected to equal the value of other'); assert.sameValue(counter, 1, 'The value of `counter` is 1'); - sample = new TA(4); + sample = new TA(makeCtorArg(4)); sample.constructor = ctor; sample.slice(1, 1); // count = 0; assert.sameValue(counter, 2, 'The value of `counter` is 2'); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer.js index bbbb576f36d9e8..d319836b2b98cb 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/detached-buffer.js @@ -24,10 +24,10 @@ var obj = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.slice(obj, obj); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js index 7c3fe8f77167fb..8245a0c195e5d9 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js @@ -16,10 +16,10 @@ features: [Symbol, TypedArray] var s = Symbol("1"); -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.slice(0, s); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-end.js index 58c6a54739f59b..941ef6f38d3eb4 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-end.js @@ -26,8 +26,8 @@ var o2 = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.slice(0, o1); @@ -36,4 +36,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { sample.slice(0, o2); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js index 0dbf1fee6dc907..a88f1101a9d5fb 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js @@ -15,10 +15,10 @@ features: [Symbol, TypedArray] var s = Symbol("1"); -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.slice(s); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-start.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-start.js index 57c78ef133bc7e..170164f5fc0d12 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-start.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-start.js @@ -25,8 +25,8 @@ var o2 = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.slice(o1); @@ -35,4 +35,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { sample.slice(o2); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js index e160e456345ac2..be479b5924ffa4 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js @@ -32,8 +32,8 @@ features: [Symbol.species, TypedArray] var arr = [42, 43, 44]; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(arr); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(arr)); var other = TA === Int8Array ? Uint8Array : Int8Array; sample.constructor = {}; @@ -44,4 +44,4 @@ testWithTypedArrayConstructors(function(TA) { assert(compareArray(result, arr), "values are set"); assert.notSameValue(result.buffer, sample.buffer, "creates a new buffer"); assert.sameValue(result.constructor, other, "used the custom ctor"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-destination-backed-by-immutable-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-destination-backed-by-immutable-buffer.js new file mode 100644 index 00000000000000..de34ca54be17d8 --- /dev/null +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-destination-backed-by-immutable-buffer.js @@ -0,0 +1,95 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Throws a TypeError exception when the receiver constructs an instance backed + by an immutable buffer +info: | + %TypedArray%.prototype.slice ( start, end ) + 1. Let O be the this value. + 2. Let taRecord be ? ValidateTypedArray(O, seq-cst). + 3. Let srcArrayLength be TypedArrayLength(taRecord). + 4. Let relativeStart be ? ToIntegerOrInfinity(start). + 5. If relativeStart = -∞, let startIndex be 0. + 6. Else if relativeStart < 0, let startIndex be max(srcArrayLength + relativeStart, 0). + 7. Else, let startIndex be min(relativeStart, srcArrayLength). + 8. If end is undefined, let relativeEnd be srcArrayLength; else let relativeEnd be ? ToIntegerOrInfinity(end). + 9. If relativeEnd = -∞, let endIndex be 0. + 10. Else if relativeEnd < 0, let endIndex be max(srcArrayLength + relativeEnd, 0). + 11. Else, let endIndex be min(relativeEnd, srcArrayLength). + 12. Let countBytes be max(endIndex - startIndex, 0). + 13. Let A be ? TypedArraySpeciesCreate(O, « 𝔽(countBytes) », ~write~). + 14. Assert: IsImmutableBuffer(A.[[ViewedArrayBuffer]]) is false. + + TypedArraySpeciesCreate ( exemplar, argumentList [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to ~read~. + 2. Let defaultConstructor be the intrinsic object associated with the constructor name exemplar.[[TypedArrayName]] in Table 73. + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Let result be ? TypedArrayCreateFromConstructor(constructor, argumentList, accessMode). + + TypedArrayCreateFromConstructor ( constructor, argumentList [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to ~read~. + 2. Let newTypedArray be ? Construct(constructor, argumentList). + 3. Let taRecord be ? ValidateTypedArray(newTypedArray, seq-cst, accessMode). + + ValidateTypedArray ( O, order [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to read. + 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). + 3. Assert: O has a [[ViewedArrayBuffer]] internal slot. + 4. If accessMode is ~write~ and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. +features: [Symbol.species, TypedArray, immutable-arraybuffer] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithAllTypedArrayConstructors((TA, makeCtorArg) => { + var calls = []; + + var ta = new TA(makeCtorArg(["1", "2"])); + var iab = (new TA(["3", "4"])).buffer.transferToImmutable(); + var constructor = {}; + Object.defineProperty(ta, "constructor", { + get: function() { + calls.push("get ta.constructor"); + return constructor; + } + }); + Object.defineProperty(constructor, Symbol.species, { + get: function() { + calls.push("get ta.constructor[Symbol.species]"); + return function speciesCtor() { + calls.push("construct result"); + var result = new TA(iab); + calls.push("return result"); + return result; + }; + } + }); + + var start = { + valueOf() { + calls.push("start.valueOf"); + return 0; + } + }; + var end = { + valueOf() { + calls.push("end.valueOf"); + return 2; + } + }; + + assert.throws(TypeError, function() { + ta.slice(start, end); + }); + var expectCalls = [ + "start.valueOf", + "end.valueOf", + "get ta.constructor", + "get ta.constructor[Symbol.species]", + "construct result", + "return result" + ]; + assert.compareArray(calls, expectCalls, "Must read arguments before constructing the result."); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js index 66c57ef889aca2..600bfd1c756a5b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js @@ -38,4 +38,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(Test262Error, function() { sample.slice(); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor.js index bdfd46e01410ff..5eada61fb2b0da 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor.js @@ -51,4 +51,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { TA, "use defaultCtor on an undefined return - .constructor check" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js index fe47fea383ca3d..8ec6ab7cd016e9 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js @@ -42,4 +42,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(Test262Error, function() { sample.slice(); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-get-species.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-get-species.js index bf6e20432e3e92..14ed6903ca7318 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-get-species.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-get-species.js @@ -43,4 +43,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { sample.slice(); assert.sameValue(calls, 1); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-return-same-buffer-with-offset.js b/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-return-same-buffer-with-offset.js index 46cc8085eea16e..d7770d1fb4b88b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-return-same-buffer-with-offset.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/slice/speciesctor-return-same-buffer-with-offset.js @@ -17,19 +17,19 @@ info: | 1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, uint8, true, unordered). 2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, uint8, value, true, unordered). ... -features: [TypedArray] +features: [Symbol.species, TypedArray] includes: [testTypedArray.js, compareArray.js] ---*/ -testWithTypedArrayConstructors(function(TA) { - var ta = new TA([ +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var ta = new TA(makeCtorArg([ 10, 20, 30, 40, 50, 60, - ]); + ])); ta.constructor = { [Symbol.species]: function() { @@ -42,4 +42,4 @@ testWithTypedArrayConstructors(function(TA) { assert.compareArray(result, [ 20, 20, 20, 60, ]); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js index 9aef470ec7c7cd..38c7b6b95d7e02 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js @@ -25,9 +25,9 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.some(function() { if (loops === 0) { @@ -38,4 +38,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { }); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js b/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js index d05c270e47f7b7..8afc7dfb5cc939 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js @@ -25,12 +25,12 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; - new TA().some(function() { + new TA(makeCtorArg(0)).some(function() { called++; }); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js b/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js index 0ad4f3f96fbcb2..7b369155c38ad0 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js @@ -53,4 +53,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7"); assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1"); assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/detached-buffer.js index b7b84a16549972..5be15e2dbd5f74 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/detached-buffer.js @@ -23,10 +23,10 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.some(callbackfn); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/values-are-not-cached.js b/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/values-are-not-cached.js index 82d119629b6ac6..cab518f2556e17 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/values-are-not-cached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/some/BigInt/values-are-not-cached.js @@ -37,4 +37,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { v, 42n, "method does not cache values before callbackfn calls" ); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/some/callbackfn-detachbuffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/some/callbackfn-detachbuffer.js index 35e1a91eacc579..74f63c1b18f78b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/some/callbackfn-detachbuffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/some/callbackfn-detachbuffer.js @@ -25,9 +25,9 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var loops = 0; - var sample = new TA(2); + var sample = new TA(makeCtorArg(2)); sample.some(function() { if (loops === 0) { @@ -38,4 +38,4 @@ testWithTypedArrayConstructors(function(TA) { }); assert.sameValue(loops, 2); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js b/third_party/test262/test/built-ins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js index f90690b4e0a56d..bdf59806f9e80c 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js @@ -25,12 +25,12 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { var called = 0; - new TA().some(function() { + new TA(makeCtorArg(0)).some(function() { called++; }); assert.sameValue(called, 0); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js b/third_party/test262/test/built-ins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js index 736fb7cdfcc9aa..dd673ff5064e78 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js @@ -53,4 +53,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample[0], 7, "changed values after iteration [0] == 7"); assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1"); assert.sameValue(sample[2], 2, "changed values after iteration [2] == 2"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/some/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/some/detached-buffer.js index 1ad6a7078b221f..ef3d335c9143fb 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/some/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/some/detached-buffer.js @@ -23,10 +23,10 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.some(callbackfn); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/some/values-are-not-cached.js b/third_party/test262/test/built-ins/TypedArray/prototype/some/values-are-not-cached.js index 6af2bf960b49be..14aeefee7ebfff 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/some/values-are-not-cached.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/some/values-are-not-cached.js @@ -37,4 +37,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { v, 42, "method does not cache values before callbackfn calls" ); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js index 3d8e8d3ba06e3f..30e0ba147a6e7f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js @@ -39,4 +39,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { }); assert.sameValue(calls, 1, "immediately returned"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/comparefn-calls.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/comparefn-calls.js index c9d10aa2b4b38e..218f2d6a90db8a 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/comparefn-calls.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/comparefn-calls.js @@ -39,4 +39,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(args[1][0], 42n, "x is a listed value"); assert.sameValue(args[1][0], 42n, "y is a listed value"); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js index 065ffe91b299cf..52749b5d221f23 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js @@ -20,4 +20,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.compareArray(explicit, [42n, 43n, 44n, 45n, 46n], 'The value of `explicit` is [42n, 43n, 44n, 45n, 46n]'); assert.compareArray(implicit, [42n, 43n, 44n, 45n, 46n], 'The value of `implicit` is [42n, 43n, 44n, 45n, 46n]'); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js index 30889e1ebe8e0d..0f48fb2f3e5a0c 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js @@ -52,4 +52,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(TypeError, function() { sample.sort({}); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/detached-buffer.js index 39829d049dd3c5..84bead0adfe65b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/detached-buffer.js @@ -22,10 +22,10 @@ var comparefn = function() { throw new Test262Error(); }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.sort(comparefn); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/return-same-instance.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/return-same-instance.js index 0a22834ed507ed..f71063557b9f52 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/return-same-instance.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/return-same-instance.js @@ -22,4 +22,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { result = sample.sort(function() { return 0; }); assert.sameValue(sample, result, "with comparefn"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js index bdee5328838057..3bb7ca0f44dd41 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js @@ -28,4 +28,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var result = sample.sort(); assert.sameValue(toStringCalled, false, "BigInt.prototype.toString will not be called"); assert(compareArray(result, [3n, 20n, 100n])); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/sorted-values.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/sorted-values.js index 9cfbab7ba3090d..e25ee6249fca6b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/sorted-values.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/BigInt/sorted-values.js @@ -25,7 +25,7 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { sample = new TA(makeCtorArg([3n, 4n, 3n, 1n, 0n, 1n, 2n])).sort(); assert(compareArray(sample, [0n, 1n, 1n, 2n, 3n, 3n, 4n]), "repeating numbers"); -}); +}, null, null, ["immutable"]); var sample = new BigInt64Array([-4n, 3n, 4n, -3n, 2n, -2n, 1n, 0n]).sort(); assert(compareArray(sample, [-4n, -3n, -2n, 0n, 1n, 2n, 3n, 4n]), "negative values"); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/comparefn-call-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/comparefn-call-throws.js index 78a522de84c321..028038ae758b96 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/comparefn-call-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/comparefn-call-throws.js @@ -39,4 +39,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { }); assert.sameValue(calls, 1, "immediately returned"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/comparefn-calls.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/comparefn-calls.js index 6d572a429843e2..c1e773bcc4d571 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/comparefn-calls.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/comparefn-calls.js @@ -39,4 +39,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(args[1][0], 42, "x is a listed value"); assert.sameValue(args[1][0], 42, "y is a listed value"); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/comparefn-is-undefined.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/comparefn-is-undefined.js index 860e6b30d3e998..267f2fbbede0c7 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/comparefn-is-undefined.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/comparefn-is-undefined.js @@ -20,4 +20,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.compareArray(explicit, [42, 43, 44, 45, 46], 'The value of `explicit` is [42, 43, 44, 45, 46]'); assert.compareArray(implicit, [42, 43, 44, 45, 46], 'The value of `implicit` is [42, 43, 44, 45, 46]'); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js index eed735b03d31c6..8809b550e46062 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js @@ -52,4 +52,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(TypeError, function() { sample.sort({}); }); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/detached-buffer.js index 4b1a2a6a581072..7170d5b15f03c2 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/detached-buffer.js @@ -22,10 +22,10 @@ var comparefn = function() { throw new Test262Error(); }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.sort(comparefn); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/immutable-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/immutable-buffer.js new file mode 100644 index 00000000000000..56547fc872144e --- /dev/null +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/immutable-buffer.js @@ -0,0 +1,47 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Throws a TypeError exception when the backing buffer is immutable +info: | + %TypedArray%.prototype.sort ( comparator ) + 1. If comparator is not undefined and IsCallable(comparator) is false, throw a TypeError exception. + 2. Let obj be the this value. + 3. Let taRecord be ? ValidateTypedArray(obj, ~seq-cst~, ~write~). + 4. Let len be TypedArrayLength(taRecord). + 5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30. + 6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparator and performs the following steps when called: + a. Return ? CompareTypedArrayElements(x, y, comparator). + 7. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, ~read-through-holes~). + + ValidateTypedArray ( O, order [ , accessMode ] ) + 1. If accessMode is not present, set accessMode to read. + 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). + 3. Assert: O has a [[ViewedArrayBuffer]] internal slot. + 4. If accessMode is ~write~ and IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. +features: [TypedArray, immutable-arraybuffer] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithAllTypedArrayConstructors((TA, makeCtorArg) => { + var calls = []; + + var ta = new TA(makeCtorArg(["1", "2", "3", "4"])); + function comparator() { + calls.push("compare"); + return 0; + } + + assert.throws(TypeError, function() { + ta.sort(comparator); + }); + assert.compareArray(calls, [], "Must verify mutability before comparing."); + assert.compareArray(ta, new TA(["1", "2", "3", "4"]), "Must not mutate contents."); + + calls = []; + var empty = new TA(makeCtorArg(0)); + assert.throws(TypeError, function() { + empty.sort(comparator); + }, "Must verify mutability even when receiver is length 0"); +}, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/return-same-instance.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/return-same-instance.js index b363e964f639e2..bb9c2de4fa537d 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/return-same-instance.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/return-same-instance.js @@ -22,4 +22,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { result = sample.sort(function() { return 0; }); assert.sameValue(sample, result, "with comparefn"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/sort-tonumber.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/sort-tonumber.js index 04e36760addf13..b5240c59575189 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/sort-tonumber.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/sort-tonumber.js @@ -16,8 +16,8 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var ta = new TA(4); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var ta = new TA(makeCtorArg(4)); var ab = ta.buffer; var called = false; @@ -30,4 +30,4 @@ testWithTypedArrayConstructors(function(TA) { }); assert.sameValue(true, called); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js index 57203938e0a8db..c5e347334b74fb 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js @@ -28,4 +28,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { var result = sample.sort(); assert.sameValue(toStringCalled, false, "Number.prototype.toString will not be called"); assert(compareArray(result, [3, 20, 100]), "Default sorting by value"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/sorted-values-nan.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/sorted-values-nan.js index d688ded37f2628..af77b845cb6eba 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/sorted-values-nan.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/sorted-values-nan.js @@ -35,4 +35,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample[4], Infinity, "#2 [4]"); assert.sameValue(sample[5], NaN, "#2 [5]"); assert.sameValue(sample[6], NaN, "#2 [6]"); -}, floatArrayConstructors); +}, floatArrayConstructors, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/sorted-values.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/sorted-values.js index 99c0d717eee324..667ef22310a0e6 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/sorted-values.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/sorted-values.js @@ -25,22 +25,27 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { sample = new TA(makeCtorArg([3, 4, 3, 1, 0, 1, 2])).sort(); assert(compareArray(sample, [0, 1, 1, 2, 3, 3, 4]), "repeating numbers"); -}); +}, null, null, ["immutable"]); testWithTypedArrayConstructors(function(TA, makeCtorArg) { var sample = new TA(makeCtorArg([1, 0, -0, 2])).sort(); assert(compareArray(sample, [-0, 0, 1, 2]), "0s"); -}, floatArrayConstructors); +}, floatArrayConstructors, null, ["immutable"]); testWithTypedArrayConstructors(function(TA, makeCtorArg) { var sample = new TA(makeCtorArg([1, 0, -0, 2])).sort(); assert(compareArray(sample, [0, 0, 1, 2]), "0s"); -}, intArrayConstructors); - -testWithTypedArrayConstructors(function(TA, makeCtorArg) { - var sample = new TA(makeCtorArg([-4, 3, 4, -3, 2, -2, 1, 0])).sort(); - assert(compareArray(sample, [-4, -3, -2, 0, 1, 2, 3, 4]), "negative values"); -}, floatArrayConstructors.concat([Int8Array, Int16Array, Int32Array])); +}, intArrayConstructors, null, ["immutable"]); + +testWithTypedArrayConstructors( + function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg([-4, 3, 4, -3, 2, -2, 1, 0])).sort(); + assert(compareArray(sample, [-4, -3, -2, 0, 1, 2, 3, 4]), "negative values"); + }, + floatArrayConstructors.concat([Int8Array, Int16Array, Int32Array]), + null, + ["immutable"] +); testWithTypedArrayConstructors(function(TA, makeCtorArg) { var sample; @@ -54,4 +59,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { sample = new TA(makeCtorArg([3, 4, Infinity, -Infinity, 1, 2])).sort(); assert(compareArray(sample, [-Infinity, 1, 2, 3, 4, Infinity]), "infinities"); -}, floatArrayConstructors); +}, floatArrayConstructors, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/sort/stability.js b/third_party/test262/test/built-ins/TypedArray/prototype/sort/stability.js index 47b41e6f8742c8..9b88074f1404d0 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/sort/stability.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/sort/stability.js @@ -12,11 +12,11 @@ features: [TypedArray, stable-typedarray-sort] // Treat 0..3, 4..7, etc. as equal. const compare = (a, b) => (a / 4 | 0) - (b / 4 | 0); -testWithTypedArrayConstructors(TA => { +testWithTypedArrayConstructors((TA, makeCtorArg) => { // Create an array of the form `[0, 1, …, 126, 127]`. const array = Array.from({ length: 128 }, (_, i) => i); - const typedArray1 = new TA(array); + const typedArray1 = new TA(makeCtorArg(array)); assert(compareArray( typedArray1.sort(compare), array @@ -25,7 +25,7 @@ testWithTypedArrayConstructors(TA => { // Reverse `array` in-place so it becomes `[127, 126, …, 1, 0]`. array.reverse(); - const typedArray2 = new TA(array); + const typedArray2 = new TA(makeCtorArg(array)); assert(compareArray( typedArray2.sort(compare), [ @@ -42,4 +42,4 @@ testWithTypedArrayConstructors(TA => { 123, 122, 121, 120, 127, 126, 125, 124, ] ), 'not presorted'); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/detached-buffer.js index 8cfe424305a524..6b577b84025d17 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/detached-buffer.js @@ -50,8 +50,8 @@ var o2 = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(2); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(2)); begin = false; end = false; @@ -62,4 +62,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert(begin, "observable ToInteger(begin)"); assert(end, "observable ToInteger(end)"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js index ee707f522b3ba0..83f95a08a15fa8 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js @@ -32,4 +32,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(sample, [40n, 100n, 111n, 43n]), "changes on the new instance values affect the original sample" ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js index 3b1b36cefd0f0c..573ca62d9e3f90 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js @@ -15,10 +15,10 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol("1"); -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.subarray(s); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js index 2388d05399891d..cea9a0d3e7dfc1 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js @@ -25,8 +25,8 @@ var o2 = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.subarray(o1); @@ -35,4 +35,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { sample.subarray(o2); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js index 44b1dec715ee4f..6bdfb8b9bd91cc 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js @@ -16,10 +16,10 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol("1"); -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.subarray(0, s); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js index 8b892bc903a7f3..0171394a88b152 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js @@ -26,8 +26,8 @@ var o2 = { } }; -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.subarray(0, o1); @@ -36,4 +36,4 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { sample.subarray(0, o2); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js index 48c7dbd2b890ec..8fe2989d8a2e3a 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js @@ -37,4 +37,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(Test262Error, function() { sample.subarray(0); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js index 4e257fc557a7cc..6e64824a3fa5b0 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js @@ -50,4 +50,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { TA, "use defaultCtor on an undefined return - .constructor check" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js index cf6b59386b9fb8..2ce5e3fce40f50 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js @@ -41,4 +41,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(Test262Error, function() { sample.subarray(0); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js index dcf74af431a21b..d38aacfcd5f5f4 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js @@ -42,4 +42,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { sample.subarray(0); assert.sameValue(calls, 1); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/byteoffset-with-detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/byteoffset-with-detached-buffer.js index 590e3c595801f0..e036c6c301c660 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/byteoffset-with-detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/byteoffset-with-detached-buffer.js @@ -16,12 +16,12 @@ info: | ... f. Let argumentsList be « buffer, 𝔽(beginByteOffset), 𝔽(newLength) ». 17. Return ? TypedArraySpeciesCreate(O, argumentsList). -features: [TypedArray] +features: [Symbol.species, TypedArray] includes: [testTypedArray.js, detachArrayBuffer.js] ---*/ -testWithTypedArrayConstructors(function(TA) { - var ab = new ArrayBuffer(2 * TA.BYTES_PER_ELEMENT); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var ab = makeCtorArg(2 * TA.BYTES_PER_ELEMENT); var ta = new TA(ab, TA.BYTES_PER_ELEMENT, 1); var result = new TA(0); @@ -42,4 +42,4 @@ testWithTypedArrayConstructors(function(TA) { }; assert.sameValue(ta.subarray(1, end), result); -}, null, ["passthrough"]); +}, null, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/detached-buffer.js index fb049c89074b64..97b03e0f313102 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/detached-buffer.js @@ -50,8 +50,8 @@ var o2 = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(2); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(2)); begin = false; end = false; @@ -62,4 +62,4 @@ testWithTypedArrayConstructors(function(TA) { assert(begin, "observable ToInteger(begin)"); assert(end, "observable ToInteger(end)"); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js index d250c89ca88748..e9a110669bee20 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js @@ -32,4 +32,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { compareArray(sample, [40, 100, 111, 43]), "changes on the new instance values affect the original sample" ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js index 8d9fd08906633b..1e54741d328547 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js @@ -15,10 +15,10 @@ features: [Symbol, TypedArray] var s = Symbol("1"); -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.subarray(s); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin.js index e021609dcddf8a..c62f5c150706f1 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin.js @@ -25,8 +25,8 @@ var o2 = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.subarray(o1); @@ -35,4 +35,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { sample.subarray(o2); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js index a780599ffab454..aebf96477b5e7a 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js @@ -16,10 +16,10 @@ features: [Symbol, TypedArray] var s = Symbol("1"); -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(TypeError, function() { sample.subarray(0, s); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end.js index 56a9ea4675dbdb..f3dee021525ffb 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end.js @@ -26,8 +26,8 @@ var o2 = { } }; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.throws(Test262Error, function() { sample.subarray(0, o1); @@ -36,4 +36,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { sample.subarray(0, o2); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js index 419a33780fe357..577d346fa3ccfc 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js @@ -37,4 +37,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(Test262Error, function() { sample.subarray(0); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor.js index 3ef0b4e75a6f3b..5dce4cc439d930 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor.js @@ -50,4 +50,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { TA, "use defaultCtor on an undefined return - .constructor check" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js index b6bcce9ae7a444..ed7519dcd89d6b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js @@ -41,4 +41,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(Test262Error, function() { sample.subarray(0); }); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/speciesctor-get-species.js b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/speciesctor-get-species.js index 63bcecbcf72c8a..a54d9798693038 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/subarray/speciesctor-get-species.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/subarray/speciesctor-get-species.js @@ -42,4 +42,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { sample.subarray(0); assert.sameValue(calls, 1); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js index d481f52032362d..23063d0dd7f219 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js @@ -50,9 +50,9 @@ BigInt.prototype.toLocaleString = function() { var arr = [42n, 0n]; var expected = ["hacks1", "hacks2"].join(separator); -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(arr); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(arr)); calls = 0; assert.sameValue(sample.toLocaleString(), expected, "returns expected value"); assert.sameValue(calls, 2, "toString called once for each item"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js index 75ed4c77f74b86..9fc4ec7348f20b 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js @@ -19,10 +19,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.toLocaleString(); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js index 26dd219a08ad77..32eb1cbaf5e449 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js @@ -20,7 +20,7 @@ includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.sameValue(sample.toLocaleString(), ""); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js index 1457e3a2245243..d1221082784266 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js @@ -42,12 +42,12 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; var expected = ["hacks1", "hacks2"].join(separator); -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(arr); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(arr)); calls = []; assert.sameValue(sample.toLocaleString(), expected, "returns expected value"); assert( compareArray(new TA(calls), sample), "toLocaleString called for each item" ); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js index c82a5c8c07078c..308e001a3b5dd8 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js @@ -50,9 +50,9 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; var expected = ["hacks1", "hacks2"].join(separator); -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(arr); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(arr)); calls = 0; assert.sameValue(sample.toLocaleString(), expected, "returns expected value"); assert.sameValue(calls, 2, "toString called once for each item"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js index 85d37be0602421..1edd27e689c4bd 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js @@ -48,9 +48,9 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; var expected = ["hacks1", "hacks2"].join(separator); -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(arr); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(arr)); calls = 0; assert.sameValue(sample.toLocaleString(), expected, "returns expected value"); assert.sameValue(calls, 2, "valueOf called once for each item"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/detached-buffer.js index 52740d73293347..29dedb542995e3 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/detached-buffer.js @@ -19,10 +19,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.toLocaleString(); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js index 1f64581d794de8..3fa6bb94b0f3e6 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js @@ -20,7 +20,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(0)); assert.sameValue(sample.toLocaleString(), ""); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js index 290ec32f472cf6..dbc488b32a3fe1 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js @@ -33,11 +33,11 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { calls = 0; - var sample = new TA(arr); + var sample = new TA(makeCtorArg(arr)); assert.throws(Test262Error, function() { sample.toLocaleString(); }); assert.sameValue(calls, 1, "abrupt from first element"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js index 46d352aefa31e3..cb922d25002760 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js @@ -45,11 +45,11 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(arr); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(arr)); calls = 0; assert.throws(Test262Error, function() { sample.toLocaleString(); }); assert.sameValue(calls, 1, "toString called once"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js index 9e830ae9e39dde..eb291e38e9fce2 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js @@ -46,11 +46,11 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(arr); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(arr)); calls = 0; assert.throws(Test262Error, function() { sample.toLocaleString(); }); assert.sameValue(calls, 1, "toString called once"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js index d82a9c3da9fc63..ef4e1611b05ceb 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js @@ -36,11 +36,11 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; -testWithTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA, makeCtorArg) { calls = 0; - var sample = new TA(arr); + var sample = new TA(makeCtorArg(arr)); assert.throws(Test262Error, function() { sample.toLocaleString(); }); assert.sameValue(calls, 2, "abrupt from a next element"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js index c6dd6a438664fc..afef5ba97ddfca 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js @@ -47,11 +47,11 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(arr); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(arr)); calls = 0; assert.throws(Test262Error, function() { sample.toLocaleString(); }); assert.sameValue(calls, 2, "abrupt from a nextElement"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js index 3b9697ebaac0c1..5f64a3ab9b0ec9 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js @@ -48,11 +48,11 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(arr); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(arr)); calls = 0; assert.throws(Test262Error, function() { sample.toLocaleString(); }); assert.sameValue(calls, 2, "abrupt from a nextElement"); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-result.js b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-result.js index a35a693d0f6479..7a96f46dc94fda 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-result.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toLocaleString/return-result.js @@ -35,8 +35,8 @@ var separator = ["", ""].toLocaleString(); var arr = [42, 0, 43]; -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(arr); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(arr)); var expected = sample[0].toLocaleString().toString() + separator + @@ -44,4 +44,4 @@ testWithTypedArrayConstructors(function(TA) { separator + sample[2].toLocaleString().toString(); assert.sameValue(sample.toLocaleString(), expected); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js b/third_party/test262/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js index 80172fe2e8eb46..9a7cfdca2a992d 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js @@ -17,25 +17,25 @@ info: | 2. Let constructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. ... includes: [testTypedArray.js] -features: [TypedArray, change-array-by-copy] +features: [Symbol.species, TypedArray, change-array-by-copy] ---*/ -testWithTypedArrayConstructors(TA => { - var ta = new TA(); +testWithTypedArrayConstructors((TA, makeCtorArg) => { + var ta = new TA(makeCtorArg(0)); ta.constructor = TA === Uint8Array ? Int32Array : Uint8Array; assert.sameValue(Object.getPrototypeOf(ta.toReversed()), TA.prototype); - ta = new TA(); + ta = new TA(makeCtorArg(0)); ta.constructor = { [Symbol.species]: TA === Uint8Array ? Int32Array : Uint8Array, }; assert.sameValue(Object.getPrototypeOf(ta.toReversed()), TA.prototype); - ta = new TA(); + ta = new TA(makeCtorArg(0)); Object.defineProperty(ta, "constructor", { get() { throw new Test262Error("Should not get .constructor"); } }); ta.toReversed(); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js b/third_party/test262/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js index b2c058514e8790..87806657413bca 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js @@ -27,9 +27,9 @@ testWithTypedArrayConstructors((TA, makeCtorArg) => { res = ta.toReversed(); assert.compareArray(res, [2, 1, 0]); assert.sameValue(res.length, 3); -}, null, ["passthrough"]); +}); -function setLength(length) { +function setLengthOnPrototype(length) { Object.defineProperty(TypedArray.prototype, "length", { get: () => length, }); @@ -38,13 +38,13 @@ function setLength(length) { testWithTypedArrayConstructors((TA, makeCtorArg) => { var ta = new TA(makeCtorArg([0, 1, 2])); - setLength(2); + setLengthOnPrototype(2); var res = ta.toReversed(); - setLength(3); + setLengthOnPrototype(3); assert.compareArray(res, [2, 1, 0]); - setLength(5); + setLengthOnPrototype(5); res = ta.toReversed(); - setLength(3); + setLengthOnPrototype(3); assert.compareArray(res, [2, 1, 0]); }, null, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js b/third_party/test262/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js index 329157b18647a2..03dbaa699f1a2f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js @@ -34,11 +34,11 @@ Object.entries(invalidValues).forEach(value => { }, `${value[0]} is not a valid TypedArray`); }); -testWithTypedArrayConstructors(function(TA) { - let buffer = new ArrayBuffer(8); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + let buffer = makeCtorArg(8); let sample = new TA(buffer, 0, 1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, () => { sample.toReversed(); }, `array has a detached buffer`); -}, null, ["passthrough"]); +}, null, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js b/third_party/test262/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js index 9d17f00adf753b..72fca6bb221358 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js @@ -17,25 +17,25 @@ info: | 2. Let constructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. ... includes: [testTypedArray.js] -features: [TypedArray, change-array-by-copy] +features: [Symbol.species, TypedArray, change-array-by-copy] ---*/ -testWithTypedArrayConstructors(TA => { - var ta = new TA(); +testWithTypedArrayConstructors((TA, makeCtorArg) => { + var ta = new TA(makeCtorArg(0)); ta.constructor = TA === Uint8Array ? Int32Array : Uint8Array; assert.sameValue(Object.getPrototypeOf(ta.toSorted()), TA.prototype); - ta = new TA(); + ta = new TA(makeCtorArg(0)); ta.constructor = { [Symbol.species]: TA === Uint8Array ? Int32Array : Uint8Array, }; assert.sameValue(Object.getPrototypeOf(ta.toSorted()), TA.prototype); - ta = new TA(); + ta = new TA(makeCtorArg(0)); Object.defineProperty(ta, "constructor", { get() { throw new Test262Error("Should not get .constructor"); } }); ta.toSorted(); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js b/third_party/test262/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js index e2f6eed387c481..cdb76902557acd 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js @@ -27,9 +27,9 @@ testWithTypedArrayConstructors((TA, makeCtorArg) => { res = ta.toSorted(); assert.compareArray(res, [1, 2, 3]); assert.sameValue(res.length, 3); -}, null, ["passthrough"]); +}); -function setLength(length) { +function setLengthOnPrototype(length) { Object.defineProperty(TypedArray.prototype, "length", { get: () => length, }); @@ -38,14 +38,14 @@ function setLength(length) { testWithTypedArrayConstructors((TA, makeCtorArg) => { var ta = new TA(makeCtorArg([3, 1, 2])); - setLength(2); + setLengthOnPrototype(2); var res = ta.toSorted(); - setLength(3); + setLengthOnPrototype(3); assert.compareArray(res, [1, 2, 3]); - setLength(5); + setLengthOnPrototype(5); res = ta.toSorted(); - setLength(3); + setLengthOnPrototype(3); assert.compareArray(res, [1, 2, 3]); }, null, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js b/third_party/test262/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js index 5dec68e2e60dcf..581ef3cddb025e 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js @@ -34,11 +34,11 @@ Object.entries(invalidValues).forEach(value => { }, `${value[0]} is not a valid TypedArray`); }); -testWithTypedArrayConstructors(function(TA) { - let buffer = new ArrayBuffer(8); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + let buffer = makeCtorArg(8); let sample = new TA(buffer, 0, 1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, () => { sample.toSorted(); }, `array has a detached buffer`); -}, null, ["passthrough"]); +}, null, ["arraybuffer"], ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toString/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/toString/BigInt/detached-buffer.js index 7fa87a4d2d5f5f..d1e169803586b4 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toString/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toString/BigInt/detached-buffer.js @@ -23,10 +23,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.toString(); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/toString/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/toString/detached-buffer.js index 7a0c106721b33b..72f21c7eb950be 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/toString/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/toString/detached-buffer.js @@ -23,10 +23,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.toString(); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/values/BigInt/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/values/BigInt/detached-buffer.js index 0f92f92091c66e..d2897fd24e9205 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/values/BigInt/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/values/BigInt/detached-buffer.js @@ -18,10 +18,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.values(); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/values/detached-buffer.js b/third_party/test262/test/built-ins/TypedArray/prototype/values/detached-buffer.js index 83833e55698f46..f94818d158ee8c 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/values/detached-buffer.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/values/detached-buffer.js @@ -18,10 +18,10 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(1); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var sample = new TA(makeCtorArg(1)); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { sample.values(); }); -}, null, ["passthrough"]); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/values/return-itor.js b/third_party/test262/test/built-ins/TypedArray/prototype/values/return-itor.js index 047fef4ba541d3..dba0c048e9740f 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/values/return-itor.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/values/return-itor.js @@ -14,8 +14,8 @@ features: [TypedArray] var sample = [0, 42, 64]; -testWithTypedArrayConstructors(function(TA) { - var typedArray = new TA(sample); +testWithTypedArrayConstructors(function(TA, makeCtorArg) { + var typedArray = new TA(makeCtorArg(sample)); var itor = typedArray.values(); var next = itor.next(); @@ -33,4 +33,4 @@ testWithTypedArrayConstructors(function(TA) { next = itor.next(); assert.sameValue(next.value, undefined); assert.sameValue(next.done, true); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js b/third_party/test262/test/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js index 3228caf9b17ef1..9c479854f48e06 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js @@ -28,4 +28,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.compareArray(arr.with(1, value), [3n, 4n, 2n]); assert.compareArray(arr, [3n, 1n, 2n]); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/with/early-type-coercion.js b/third_party/test262/test/built-ins/TypedArray/prototype/with/early-type-coercion.js index f2217818279b02..3dacee28b5a2c9 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/with/early-type-coercion.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/with/early-type-coercion.js @@ -28,4 +28,4 @@ testWithTypedArrayConstructors((TA, makeCtorArg) => { assert.compareArray(arr.with(1, value), [3, 4, 2]); assert.compareArray(arr, [3, 1, 2]); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/with/ignores-species.js b/third_party/test262/test/built-ins/TypedArray/prototype/with/ignores-species.js index 9f2d2f99b78324..958ef3dc647871 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/with/ignores-species.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/with/ignores-species.js @@ -17,7 +17,7 @@ info: | 2. Let constructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. ... includes: [testTypedArray.js] -features: [TypedArray, change-array-by-copy] +features: [Symbol.species, TypedArray, change-array-by-copy] ---*/ testWithTypedArrayConstructors((TA, makeCtorArg) => { @@ -38,4 +38,4 @@ testWithTypedArrayConstructors((TA, makeCtorArg) => { } }); ta.with(0, 2); -}, null, ["passthrough"]); +}); diff --git a/third_party/test262/test/built-ins/TypedArray/prototype/with/length-property-ignored.js b/third_party/test262/test/built-ins/TypedArray/prototype/with/length-property-ignored.js index 8247e43ea1212e..a776c2f427cc78 100644 --- a/third_party/test262/test/built-ins/TypedArray/prototype/with/length-property-ignored.js +++ b/third_party/test262/test/built-ins/TypedArray/prototype/with/length-property-ignored.js @@ -27,9 +27,9 @@ testWithTypedArrayConstructors((TA, makeCtorArg) => { res = ta.with(0, 0); assert.compareArray(res, [0, 1, 2]); assert.sameValue(res.length, 3); -}, null, ["passthrough"]); +}); -function setLength(length) { +function setLengthOnPrototype(length) { Object.defineProperty(TypedArray.prototype, "length", { get: () => length, }); @@ -38,13 +38,13 @@ function setLength(length) { testWithTypedArrayConstructors((TA, makeCtorArg) => { var ta = new TA(makeCtorArg([3, 1, 2])); - setLength(2); + setLengthOnPrototype(2); var res = ta.with(0, 0); - setLength(3); + setLengthOnPrototype(3); assert.compareArray(res, [0, 1, 2]); - setLength(5); + setLengthOnPrototype(5); res = ta.with(0, 0); - setLength(3); + setLengthOnPrototype(3); assert.compareArray(res, [0, 1, 2]); }, null, ["passthrough"]); diff --git a/third_party/test262/test/built-ins/TypedArrayConstructors/from/BigInt/custom-ctor-returns-other-instance.js b/third_party/test262/test/built-ins/TypedArrayConstructors/from/BigInt/custom-ctor-returns-other-instance.js index 3281dad98bbd32..56bd94303552bb 100644 --- a/third_party/test262/test/built-ins/TypedArrayConstructors/from/BigInt/custom-ctor-returns-other-instance.js +++ b/third_party/test262/test/built-ins/TypedArrayConstructors/from/BigInt/custom-ctor-returns-other-instance.js @@ -49,4 +49,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { result = TypedArray.from.call(ctor, sourceObj); assert.sameValue(result, custom, "not using iterator, higher length"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArrayConstructors/from/custom-ctor-returns-immutable-arraybuffer.js b/third_party/test262/test/built-ins/TypedArrayConstructors/from/custom-ctor-returns-immutable-arraybuffer.js new file mode 100644 index 00000000000000..54e33ba2e1bbf6 --- /dev/null +++ b/third_party/test262/test/built-ins/TypedArrayConstructors/from/custom-ctor-returns-immutable-arraybuffer.js @@ -0,0 +1,146 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.from +description: > + Throws a TypeError if species constructor returns an immutable ArrayBuffer. +info: | + %TypedArray%.from ( source [ , mapper [ , thisArg ] ] ) + 1. Let C be the this value. + 2. If IsConstructor(C) is false, throw a TypeError exception. + 3. If mapper is undefined, then + a. Let mapping be false. + 4. Else, + a. If IsCallable(mapper) is false, throw a TypeError exception. + b. Let mapping be true. + 5. Let usingIterator be ? GetMethod(source, %Symbol.iterator%). + 6. If usingIterator is not undefined, then + a. Let values be ? IteratorToList(? GetIteratorFromMethod(source, usingIterator)). + b. Let len be the number of elements in values. + c. Let targetObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write). + d. Let k be 0. + e. Repeat, while k < len, + i. Let Pk be ! ToString(𝔽(k)). + ii. Let kValue be the first element of values. + iii. Remove the first element from values. + iv. If mapping is true, then + 1. Let mappedValue be ? Call(mapper, thisArg, « kValue, 𝔽(k) »). + v. Else, + 1. Let mappedValue be kValue. + vi. Perform ? Set(targetObj, Pk, mappedValue, true). + vii. Set k to k + 1. + f. Assert: values is now an empty List. + g. Return targetObj. + 7. NOTE: source is not an iterable object, so assume it is already an array-like object. + 8. Let arrayLike be ! ToObject(source). + 9. Let len be ? LengthOfArrayLike(arrayLike). + 10. Let targetObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write). + 11. Let k be 0. + 12. Repeat, while k < len, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(arrayLike, Pk). + c. If mapping is true, then + i. Let mappedValue be ? Call(mapper, thisArg, « kValue, 𝔽(k) »). +features: [Symbol.iterator, TypedArray, immutable-arraybuffer] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithAllTypedArrayConstructors((TA, makeCtorArg) => { + var calls = []; + var expectCalls = []; + + var custom = new TA(makeCtorArg(2)); + var ctor = function(len) { + calls.push("construct(" + len + ")"); + return custom; + }; + var mapper = function(value, index) { + calls.push("map index " + index); + return value + value; + }; + + // arraylike source + calls = []; + var srcArraylike = { + get length() { + calls.push("get source.length"); + return 1; + }, + get 0() { + calls.push("get source[0]"); + return "8"; + } + }; + Object.defineProperty(srcArraylike, Symbol.iterator, { + get: function() { + calls.push("get source[Symbol.iterator]"); + return undefined; + } + }); + assert.throws(TypeError, function() { + TA.from.call(ctor, srcArraylike, mapper); + }, "arraylike source"); + expectCalls = [ + "get source[Symbol.iterator]", + "get source.length", + "construct(1)" + ]; + assert.compareArray(calls, expectCalls, + "Must construct the result before visiting arraylike source elements."); + + // iterable source + calls = []; + var srcIterable = Object.defineProperty({}, Symbol.iterator, { + get: function() { + calls.push("get source[Symbol.iterator]"); + function getIterator() { + calls.push("call source[Symbol.iterator]"); + var itor = { + get next() { + calls.push("get source iterator.next"); + var iterationResults = [ + { done: false, value: "4", msg: "yield 4" }, + { done: true, value: "8", msg: "done" }, + { done: true, value: "9", msg: "unexpected" } + ]; + function next() { + var result = iterationResults.shift(); + calls.push("source iterator " + result.msg); + var resultSpy = { + get done() { + calls.push("get iterationResult.done " + result.done); + return result.done; + }, + get value() { + calls.push("get iterationResult.value " + result.value); + return result.value; + } + }; + return resultSpy; + }; + return next; + } + }; + return itor; + } + return getIterator; + } + }); + assert.throws(TypeError, function() { + TA.from.call(ctor, srcIterable, mapper); + }, "iterable source"); + expectCalls = [ + "get source[Symbol.iterator]", + "call source[Symbol.iterator]", + "get source iterator.next", + "source iterator yield 4", + "get iterationResult.done false", + "get iterationResult.value 4", + "source iterator done", + "get iterationResult.done true", + "construct(1)" + ]; + assert.compareArray(calls, expectCalls, + "Must construct the result before visiting iterable source elements."); +}, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArrayConstructors/from/custom-ctor-returns-other-instance.js b/third_party/test262/test/built-ins/TypedArrayConstructors/from/custom-ctor-returns-other-instance.js index 82a769a4865a3e..8d490623a4cf36 100644 --- a/third_party/test262/test/built-ins/TypedArrayConstructors/from/custom-ctor-returns-other-instance.js +++ b/third_party/test262/test/built-ins/TypedArrayConstructors/from/custom-ctor-returns-other-instance.js @@ -47,4 +47,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { result = TypedArray.from.call(ctor, sourceObj); assert.sameValue(result, custom, "not using iterator, higher length"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation-consistent-nan.js b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation-consistent-nan.js index 492002f2fb2cf5..26b4b1a31c44c4 100644 --- a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation-consistent-nan.js +++ b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation-consistent-nan.js @@ -94,5 +94,4 @@ testWithTypedArrayConstructors(function(FA, makeCtorArg) { ); } } -}, floatArrayConstructors); - +}, floatArrayConstructors, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/boolean-tobigint.js b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/boolean-tobigint.js index 53680e92cbefc5..40ebe0115c4e0a 100644 --- a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/boolean-tobigint.js +++ b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/boolean-tobigint.js @@ -56,4 +56,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { typedArray[1] = true; assert.sameValue(typedArray[0], 0n, 'The value of typedArray[0] is 0n'); assert.sameValue(typedArray[1], 1n, 'The value of typedArray[1] is 1n'); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-minus-zero.js b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-minus-zero.js index 69cd7d7ec5a9f8..f8529f8b675967 100644 --- a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-minus-zero.js +++ b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-minus-zero.js @@ -21,4 +21,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { var sample = new TA(makeCtorArg([42n])); assert.sameValue(Reflect.set(sample, '-0', 1n), true, 'Reflect.set("new TA(makeCtorArg([42n]))", "-0", 1n) must return true'); assert.sameValue(sample.hasOwnProperty('-0'), false, 'sample.hasOwnProperty("-0") must return false'); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-not-integer.js b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-not-integer.js index 73a5a66c61a43e..a450c4a5c17926 100644 --- a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-not-integer.js +++ b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-not-integer.js @@ -30,4 +30,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample.hasOwnProperty('1.1'), false, 'sample.hasOwnProperty("1.1") must return false'); assert.sameValue(sample.hasOwnProperty('0.0001'), false, 'sample.hasOwnProperty("0.0001") must return false'); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-out-of-bounds.js b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-out-of-bounds.js index e62d524add2331..08d15742b76015 100644 --- a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-out-of-bounds.js +++ b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-out-of-bounds.js @@ -32,4 +32,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample.hasOwnProperty('-1'), false, 'sample.hasOwnProperty("-1") must return false'); assert.sameValue(sample.hasOwnProperty('1'), false, 'sample.hasOwnProperty("1") must return false'); assert.sameValue(sample.hasOwnProperty('2'), false, 'sample.hasOwnProperty("2") must return false'); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/string-tobigint.js b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/string-tobigint.js index 2e2ce86fdf9109..e7cb51c0237a5c 100644 --- a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/string-tobigint.js +++ b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/string-tobigint.js @@ -82,4 +82,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { assert.throws(SyntaxError, function() { typedArray[0] = '1e7'; }, '`typedArray[0] = "1e7"` throws SyntaxError'); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/conversion-operation-consistent-nan.js b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/conversion-operation-consistent-nan.js index a814e27c644248..c04983de4b63e8 100644 --- a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/conversion-operation-consistent-nan.js +++ b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/conversion-operation-consistent-nan.js @@ -101,5 +101,4 @@ testWithTypedArrayConstructors(function(FA, makeCtorArg) { ); } } -}, floatArrayConstructors); - +}, floatArrayConstructors, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-minus-zero.js b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-minus-zero.js index 4b2912c8377553..680d2eb95b2d35 100644 --- a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-minus-zero.js +++ b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-minus-zero.js @@ -24,4 +24,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(Reflect.set(sample, "-0", 1), true, 'Reflect.set(sample, "-0", 1) must return true'); assert.sameValue(sample.hasOwnProperty("-0"), false, 'sample.hasOwnProperty("-0") must return false'); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-not-integer.js b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-not-integer.js index 59c2f16efb6eef..663f628927ac1f 100644 --- a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-not-integer.js +++ b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-not-integer.js @@ -31,4 +31,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { false, 'sample.hasOwnProperty("0.0001") must return false' ); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-out-of-bounds.js b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-out-of-bounds.js index 702e89e842075a..f5c073e5d1f9e2 100644 --- a/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-out-of-bounds.js +++ b/third_party/test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-out-of-bounds.js @@ -29,4 +29,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { assert.sameValue(sample.hasOwnProperty("-1"), false, 'sample.hasOwnProperty("-1") must return false'); assert.sameValue(sample.hasOwnProperty("1"), false, 'sample.hasOwnProperty("1") must return false'); assert.sameValue(sample.hasOwnProperty("2"), false, 'sample.hasOwnProperty("2") must return false'); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor-returns-other-instance.js b/third_party/test262/test/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor-returns-other-instance.js index a893232a95ccb0..b0adf28e2e66e5 100644 --- a/third_party/test262/test/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor-returns-other-instance.js +++ b/third_party/test262/test/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor-returns-other-instance.js @@ -29,4 +29,4 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) { result = TypedArray.of.call(ctor, 1n, 2n); assert.sameValue(result, custom, "using iterator, higher length"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArrayConstructors/of/custom-ctor-returns-immutable-arraybuffer.js b/third_party/test262/test/built-ins/TypedArrayConstructors/of/custom-ctor-returns-immutable-arraybuffer.js new file mode 100644 index 00000000000000..e7a8b50ea500b5 --- /dev/null +++ b/third_party/test262/test/built-ins/TypedArrayConstructors/of/custom-ctor-returns-immutable-arraybuffer.js @@ -0,0 +1,49 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.of +description: > + Throws a TypeError if species constructor returns an immutable ArrayBuffer. +info: | + %TypedArray%.of ( ...items ) + 1. Let len be the number of elements in items. + 2. Let C be the this value. + 3. If IsConstructor(C) is false, throw a TypeError exception. + 4. Let newObj be ? TypedArrayCreateFromConstructor(C, « 𝔽(len) », write). + 5. Let k be 0. + 6. Repeat, while k < len, + a. Let kValue be items[k]. + b. Let Pk be ! ToString(𝔽(k)). + c. Perform ? Set(newObj, Pk, kValue, true). + d. Set k to k + 1. +features: [Symbol.iterator, TypedArray, immutable-arraybuffer] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithAllTypedArrayConstructors((TA, makeCtorArg) => { + var calls = []; + + var custom = new TA(makeCtorArg(2)); + var ctor = function(len) { + calls.push("construct(" + len + ")"); + return custom; + }; + + var a = { + valueOf() { + calls.push("a.valueOf"); + return "1"; + } + }; + var b = { + valueOf() { + calls.push("b.valueOf"); + return "2"; + } + }; + assert.throws(TypeError, function() { + TA.of.call(ctor, a, b); + }, "iterable source"); + assert.compareArray(calls, ["construct(2)"]); +}, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/TypedArrayConstructors/of/custom-ctor-returns-other-instance.js b/third_party/test262/test/built-ins/TypedArrayConstructors/of/custom-ctor-returns-other-instance.js index 8484dc0d760896..12cf8af04b86f8 100644 --- a/third_party/test262/test/built-ins/TypedArrayConstructors/of/custom-ctor-returns-other-instance.js +++ b/third_party/test262/test/built-ins/TypedArrayConstructors/of/custom-ctor-returns-other-instance.js @@ -29,4 +29,4 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) { result = TypedArray.of.call(ctor, 1, 2); assert.sameValue(result, custom, "using iterator, higher length"); -}); +}, null, null, ["immutable"]); diff --git a/third_party/test262/test/built-ins/Uint8Array/prototype/setFromBase64/throws-when-target-is-backed-by-immutable-arraybuffer.js b/third_party/test262/test/built-ins/Uint8Array/prototype/setFromBase64/throws-when-target-is-backed-by-immutable-arraybuffer.js new file mode 100644 index 00000000000000..62b3f4aebc66e9 --- /dev/null +++ b/third_party/test262/test/built-ins/Uint8Array/prototype/setFromBase64/throws-when-target-is-backed-by-immutable-arraybuffer.js @@ -0,0 +1,52 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-uint8array.prototype.setfrombase64 +description: Throws a TypeError exception when the backing buffer is immutable +info: | + Uint8Array.prototype.setFromBase64 ( string [ , options ] ) + 1. Let into be the this value. + 2. Perform ? ValidateUint8Array(into). + 3. If string is not a String, throw a TypeError exception. + 4. Let opts be ? GetOptionsObject(options). + 5. Let alphabet be ? Get(opts, "alphabet"). + 6. If alphabet is undefined, set alphabet to "base64". + 7. If alphabet is neither "base64" nor "base64url", throw a TypeError exception. + 8. Let lastChunkHandling be ? Get(opts, "lastChunkHandling"). +features: [TypedArray, uint8array-base64, immutable-arraybuffer] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithAllTypedArrayConstructors((TA, makeCtorArg) => { + var calls = []; + + var ta = new TA(makeCtorArg(["1", "2", "3", "4"])); + var options = { + get alphabet() { + calls.push("get options.alphabet"); + return undefined; + }, + get lastChunkHandling() { + calls.push("get options.lastChunkHandling"); + return undefined; + }, + }; + + assert.throws(TypeError, function() { + ta.setFromBase64("Zm9v", options); + }, "non-empty base64"); + assert.compareArray(calls, [], + "Must verify mutability before reading arguments (non-empty base64)."); + assert.compareArray(ta, new TA(["1", "2", "3", "4"]), + "Must not mutate contents (non-empty base64)."); + + calls = []; + assert.throws(TypeError, function() { + ta.setFromBase64("", options); + }, "empty base64"); + assert.compareArray(calls, [], + "Must verify mutability before reading arguments (empty base64)."); + assert.compareArray(ta, new TA(["1", "2", "3", "4"]), + "Must not mutate contents (empty base64)."); +}, [Uint8Array], ["immutable"]); diff --git a/third_party/test262/test/built-ins/Uint8Array/prototype/setFromHex/throws-when-target-is-backed-by-immutable-arraybuffer.js b/third_party/test262/test/built-ins/Uint8Array/prototype/setFromHex/throws-when-target-is-backed-by-immutable-arraybuffer.js new file mode 100644 index 00000000000000..b630a53baeb29c --- /dev/null +++ b/third_party/test262/test/built-ins/Uint8Array/prototype/setFromHex/throws-when-target-is-backed-by-immutable-arraybuffer.js @@ -0,0 +1,29 @@ +// Copyright (C) 2025 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-uint8array.prototype.setfromhex +description: Throws a TypeError exception when the backing buffer is immutable +info: | + Uint8Array.prototype.setFromHex ( string ) + 1. Let into be the this value. + 2. Perform ? ValidateUint8Array(into). +features: [TypedArray, uint8array-base64, immutable-arraybuffer] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithAllTypedArrayConstructors((TA, makeCtorArg) => { + var ta = new TA(makeCtorArg(["1", "2", "3", "4"])); + + assert.throws(TypeError, function() { + ta.setFromHex("666f6f"); + }, "non-empty hex"); + assert.compareArray(ta, new TA(["1", "2", "3", "4"]), + "Must not mutate contents (non-empty hex)."); + + assert.throws(TypeError, function() { + ta.setFromHex(""); + }, "empty hex"); + assert.compareArray(ta, new TA(["1", "2", "3", "4"]), + "Must not mutate contents (empty hex)."); +}, [Uint8Array], ["immutable"]); diff --git a/third_party/test262/test/harness/verifyProperty-value-error.js b/third_party/test262/test/harness/verifyProperty-value-error.js index 26e5f5422ce786..0145243db1603c 100644 --- a/third_party/test262/test/harness/verifyProperty-value-error.js +++ b/third_party/test262/test/harness/verifyProperty-value-error.js @@ -29,7 +29,7 @@ try { ); } - if (err.message !== "obj['prop'] descriptor value should be 2; obj['prop'] value should be 2") { + if (err.message !== "prop descriptor value should be 2; prop value should be 2") { throw new Error('The error thrown did not define the specified message'); } } diff --git a/third_party/test262/test/intl402/BigInt/prototype/toLocaleString/default-options-object-prototype.js b/third_party/test262/test/intl402/BigInt/prototype/toLocaleString/default-options-object-prototype.js index c46d4b0b89f40d..6d75bd1a27a8b4 100644 --- a/third_party/test262/test/intl402/BigInt/prototype/toLocaleString/default-options-object-prototype.js +++ b/third_party/test262/test/intl402/BigInt/prototype/toLocaleString/default-options-object-prototype.js @@ -3,12 +3,12 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > Monkey-patching Object.prototype does not change the default options for NumberFormat as a null prototype is used. info: | - InitializeNumberFormat ( numberFormat, locales, options ) + Intl.NumberFormat ( [ locales [ , options ] ] ) 1. If _options_ is *undefined*, then 1. Let _options_ be ObjectCreate(*null*). diff --git a/third_party/test262/test/intl402/Collator/constructor-options-throwing-getters.js b/third_party/test262/test/intl402/Collator/constructor-options-throwing-getters.js index e9d49422c627bf..5a638a302467d9 100644 --- a/third_party/test262/test/intl402/Collator/constructor-options-throwing-getters.js +++ b/third_party/test262/test/intl402/Collator/constructor-options-throwing-getters.js @@ -2,8 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializecollator +esid: sec-intl.collator description: Checks the propagation of exceptions from the options for the Collator constructor. +locale: [en] ---*/ function CustomError() {} diff --git a/third_party/test262/test/intl402/Collator/default-options-object-prototype.js b/third_party/test262/test/intl402/Collator/default-options-object-prototype.js index ae1d49d7c16796..ba83b744a29b02 100644 --- a/third_party/test262/test/intl402/Collator/default-options-object-prototype.js +++ b/third_party/test262/test/intl402/Collator/default-options-object-prototype.js @@ -2,15 +2,10 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializecollator +esid: sec-intl.collator description: > Monkey-patching Object.prototype does not change the default options for Collator as a null prototype is used. -info: | - InitializeCollator ( collator, locales, options ) - - 1. If _options_ is *undefined*, then - 1. Let _options_ be ObjectCreate(*null*). ---*/ let defaultSensitivity = new Intl.Collator("en").resolvedOptions().sensitivity; diff --git a/third_party/test262/test/intl402/Collator/proto-from-ctor-realm.js b/third_party/test262/test/intl402/Collator/proto-from-ctor-realm.js index 872fa6fc1176d8..f825c84578aebf 100644 --- a/third_party/test262/test/intl402/Collator/proto-from-ctor-realm.js +++ b/third_party/test262/test/intl402/Collator/proto-from-ctor-realm.js @@ -10,7 +10,6 @@ info: | 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget. ... 5. Let collator be ? OrdinaryCreateFromConstructor(newTarget, "%CollatorPrototype%", internalSlotsList). - 6. Return ? InitializeCollator(collator, locales, options). OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) diff --git a/third_party/test262/test/intl402/Collator/prototype/resolvedOptions/ignorePunctuation-default.js b/third_party/test262/test/intl402/Collator/prototype/resolvedOptions/ignorePunctuation-default.js index ffb80c0ba98b4a..49ce7990c88950 100644 --- a/third_party/test262/test/intl402/Collator/prototype/resolvedOptions/ignorePunctuation-default.js +++ b/third_party/test262/test/intl402/Collator/prototype/resolvedOptions/ignorePunctuation-default.js @@ -1,7 +1,7 @@ // Copyright 2023 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializecollator +esid: sec-intl.collator description: resolved ignorePunctuation come from locale default instead of false. locale: [en, th, ja] ---*/ diff --git a/third_party/test262/test/intl402/Collator/prototype/resolvedOptions/ignorePunctuation-not-default.js b/third_party/test262/test/intl402/Collator/prototype/resolvedOptions/ignorePunctuation-not-default.js index 2dabdaf96f7233..54ec7ffacbd24c 100644 --- a/third_party/test262/test/intl402/Collator/prototype/resolvedOptions/ignorePunctuation-not-default.js +++ b/third_party/test262/test/intl402/Collator/prototype/resolvedOptions/ignorePunctuation-not-default.js @@ -1,7 +1,7 @@ // Copyright 2023 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializecollator +esid: sec-intl.collator description: resolved ignorePunctuation is the same as the one specified in option bag. locale: [en, th, ja] ---*/ diff --git a/third_party/test262/test/intl402/Collator/unicode-ext-seq-in-private-tag.js b/third_party/test262/test/intl402/Collator/unicode-ext-seq-in-private-tag.js index 320717d2011df8..5abff49579d2fc 100644 --- a/third_party/test262/test/intl402/Collator/unicode-ext-seq-in-private-tag.js +++ b/third_party/test262/test/intl402/Collator/unicode-ext-seq-in-private-tag.js @@ -2,18 +2,15 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializecollator +esid: sec-intl.collator description: > Unicode extension sequence-like parts are ignored in private-use tags. info: | - 10.1.1 InitializeCollator ( collator, locales, options ) - ... - 15. For each element key of relevantExtensionKeys in List order, do - a. If key is "co", then - i. Let value be r.[[co]]. - ii. If value is null, let value be "default". - iii. Set collator.[[Collation]] to value. - ... + Intl.Collator ( [ locales [ , options ] ] ) + + 1. If _r_.[[co]] is *null*, let _collation_ be *"default"*. Otherwise, let + _collation_ be _r_.[[co]]. + 1. Set _collator_.[[Collation]] to _collation_. 10.3.5 Intl.Collator.prototype.resolvedOptions () The function returns a new object whose properties and attributes are set as if constructed diff --git a/third_party/test262/test/intl402/Collator/unicode-ext-seq-with-attribute.js b/third_party/test262/test/intl402/Collator/unicode-ext-seq-with-attribute.js index fb4daf257ed5b8..ab1f86a1bbfad0 100644 --- a/third_party/test262/test/intl402/Collator/unicode-ext-seq-with-attribute.js +++ b/third_party/test262/test/intl402/Collator/unicode-ext-seq-with-attribute.js @@ -2,18 +2,15 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializecollator +esid: sec-intl.collator description: > Attributes in Unicode extension subtags should be ignored. info: | - 10.1.1 InitializeCollator ( collator, locales, options ) - ... - 15. For each element key of relevantExtensionKeys in List order, do - a. If key is "co", then - i. Let value be r.[[co]]. - ii. If value is null, let value be "default". - iii. Set collator.[[Collation]] to value. - ... + Intl.Collator ( [ locales [ , options ] ] ) + + 1. If _r_.[[co]] is *null*, let _collation_ be *"default"*. Otherwise, let + _collation_ be _r_.[[co]]. + 1. Set _collator_.[[Collation]] to _collation_. 10.3.5 Intl.Collator.prototype.resolvedOptions () The function returns a new object whose properties and attributes are set as if constructed diff --git a/third_party/test262/test/intl402/Collator/usage-de.js b/third_party/test262/test/intl402/Collator/usage-de.js index 6af9f050b7f645..9e82513c244cff 100644 --- a/third_party/test262/test/intl402/Collator/usage-de.js +++ b/third_party/test262/test/intl402/Collator/usage-de.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializecollator +esid: sec-intl.collator description: Checks the behavior of search and sort in German. includes: [compareArray.js] locale: [de] diff --git a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-calendar-future-fallback.js b/third_party/test262/test/intl402/DateTimeFormat/constructor-options-calendar-future-fallback.js new file mode 100644 index 00000000000000..e524189dca92b4 --- /dev/null +++ b/third_party/test262/test/intl402/DateTimeFormat/constructor-options-calendar-future-fallback.js @@ -0,0 +1,45 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.datetimeformat +description: > + Tests that fallbacks for not-yet-adopted calendars are selected from one of + the values returned from `AvailableCalendars`. +locale: [en] +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode] +---*/ + +const availableCalendars = [ + "buddhist", + "chinese", + "coptic", + "dangi", + "ethioaa", + "ethiopic", + "gregory", + "hebrew", + "indian", + "islamic-civil", + "islamic-tbla", + "islamic-umalqura", + "iso8601", + "japanese", + "persian", + "roc", +]; + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + const option = new Intl.DateTimeFormat("en", { calendar }); + assert( + availableCalendars.includes(option.resolvedOptions().calendar), + `${calendar} should fall back to an available calendar` + ); + + const uExtension = new Intl.DateTimeFormat(`en-u-ca-${calendar}`); + assert( + availableCalendars.includes(uExtension.resolvedOptions().calendar), + `${calendar} should fall back to an available calendar` + ); +} diff --git a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-order-dayPeriod.js b/third_party/test262/test/intl402/DateTimeFormat/constructor-options-order-dayPeriod.js deleted file mode 100644 index 1f7010b25b1836..00000000000000 --- a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-order-dayPeriod.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2019 Googe Inc. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-createdatetimeformat -description: Checks the order of getting options of 'dayPeriod' for the DateTimeFormat constructor. -info: | - CreateDateTimeFormat ( newTarget, locales, options, required, defaults ) - ... - 36. For each row of Table 7, except the header row, in table order, do - a. Let prop be the name given in the Property column of the row. - b. If prop is "fractionalSecondDigits", then - i. Let value be ? GetNumberOption(options, "fractionalSecondDigits", 1, 3, undefined). - c. Else, - i. Let values be a List whose elements are the strings given in the Values column of the row. - ii. Let value be ? GetOption(options, prop, string, values, undefined). - d. Set formatOptions.[[]] to value. - ... -includes: [compareArray.js] -features: [Intl.DateTimeFormat-dayPeriod] - ----*/ - -// Just need to ensure dayPeriod are get between day and hour. -const expected = [ - // CreateDateTimeFormat step 36. - "day", - "dayPeriod", - "hour" -]; - -const actual = []; - -const options = { - get day() { - actual.push("day"); - return "numeric"; - }, - get dayPeriod() { - actual.push("dayPeriod"); - return "long"; - }, - get hour() { - actual.push("hour"); - return "numeric"; - }, -}; - -new Intl.DateTimeFormat("en", options); -assert.compareArray(actual, expected); diff --git a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-order-fractionalSecondDigits.js b/third_party/test262/test/intl402/DateTimeFormat/constructor-options-order-fractionalSecondDigits.js deleted file mode 100644 index a1cf9eed50bdfd..00000000000000 --- a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-order-fractionalSecondDigits.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2019 Googe Inc. All rights reserved. -// Copyright 2020 Apple Inc. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-createdatetimeformat -description: Checks the order of getting options of 'fractionalSecondDigits' for the DateTimeFormat constructor. -info: | - CreateDateTimeFormat ( newTarget, locales, options, required, defaults ) - ... - 4. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit"). - ... - 36. For each row of Table 7, except the header row, in table order, do - a. Let prop be the name given in the Property column of the row. - b. If prop is "fractionalSecondDigits", then - i. Let value be ? GetNumberOption(options, "fractionalSecondDigits", 1, 3, undefined). - c. Else, - i. Let values be a List whose elements are the strings given in the Values column of the row. - ii. Let value be ? GetOption(options, prop, string, values, undefined). - d. Set formatOptions.[[]] to value. - 37. Let matcher be ? GetOption(options, "formatMatcher", "string", « "basic", "best fit" », "best fit"). - ... -includes: [compareArray.js] -features: [Intl.DateTimeFormat-fractionalSecondDigits] ----*/ - -// Just need to ensure fractionalSecondDigits are get -// between "second" and "timeZoneName". -const expected = [ - // CreateDateTimeFormat step 4. - "localeMatcher", - // CreateDateTimeFormat step 36. - "second", - "fractionalSecondDigits", - "timeZoneName", - // CreateDateTimeFormat step 37. - "formatMatcher", -]; - -const actual = []; - -const options = { - get second() { - actual.push("second"); - return "numeric"; - }, - get fractionalSecondDigits() { - actual.push("fractionalSecondDigits"); - return undefined; - }, - get localeMatcher() { - actual.push("localeMatcher"); - return undefined; - }, - get timeZoneName() { - actual.push("timeZoneName"); - return undefined; - }, - get formatMatcher() { - actual.push("formatMatcher"); - return undefined; - }, -}; - -new Intl.DateTimeFormat("en", options); -assert.compareArray(actual, expected); diff --git a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-order-timedate-style.js b/third_party/test262/test/intl402/DateTimeFormat/constructor-options-order-timedate-style.js deleted file mode 100644 index 6ea1ed28a47d08..00000000000000 --- a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-order-timedate-style.js +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2018 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-createdatetimeformat -description: Checks the order of getting options for the DateTimeFormat constructor. -includes: [compareArray.js] -features: [Intl.DateTimeFormat-datetimestyle] ----*/ - -// To be merged into constructor-options-order.js when the feature is removed. - -const expected = [ - // CreateDateTimeFormat step 4. - "localeMatcher", - // CreateDateTimeFormat step 12. - "hour12", - // CreateDateTimeFormat step 13. - "hourCycle", - // CreateDateTimeFormat step 29. - "timeZone", - // CreateDateTimeFormat step 36. - "weekday", - "era", - "year", - "month", - "day", - "hour", - "minute", - "second", - "timeZoneName", - "formatMatcher", - // CreateDateTimeFormat step 38. - "dateStyle", - // CreateDateTimeFormat step 40. - "timeStyle", -]; - -const actual = []; - -const options = { - get dateStyle() { - actual.push("dateStyle"); - return undefined; - }, - - get day() { - actual.push("day"); - return "numeric"; - }, - - get era() { - actual.push("era"); - return "long"; - }, - - get formatMatcher() { - actual.push("formatMatcher"); - return "best fit"; - }, - - get hour() { - actual.push("hour"); - return "numeric"; - }, - - get hour12() { - actual.push("hour12"); - return true; - }, - - get hourCycle() { - actual.push("hourCycle"); - return "h24"; - }, - - get localeMatcher() { - actual.push("localeMatcher"); - return "best fit"; - }, - - get minute() { - actual.push("minute"); - return "numeric"; - }, - - get month() { - actual.push("month"); - return "numeric"; - }, - - get second() { - actual.push("second"); - return "numeric"; - }, - - get timeStyle() { - actual.push("timeStyle"); - return undefined; - }, - - get timeZone() { - actual.push("timeZone"); - return "UTC"; - }, - - get timeZoneName() { - actual.push("timeZoneName"); - return "long"; - }, - - get weekday() { - actual.push("weekday"); - return "long"; - }, - - get year() { - actual.push("year"); - return "numeric"; - }, -}; - -new Intl.DateTimeFormat("en", options); - -assert.compareArray(actual, expected); diff --git a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-order.js b/third_party/test262/test/intl402/DateTimeFormat/constructor-options-order.js index fa626f0dffcafd..0939372dbd60d8 100644 --- a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-order.js +++ b/third_party/test262/test/intl402/DateTimeFormat/constructor-options-order.js @@ -4,105 +4,103 @@ /*--- esid: sec-createdatetimeformat description: Checks the order of getting options for the DateTimeFormat constructor. -includes: [compareArray.js] +includes: [compareArray.js, temporalHelpers.js] +features: + - Intl.DateTimeFormat-dayPeriod + - Intl.DateTimeFormat-fractionalSecondDigits + - Intl.DateTimeFormat-datetimestyle +locale: [en] ---*/ const expected = [ // CreateDateTimeFormat step 4. - "localeMatcher", + "get options.localeMatcher", + "get options.localeMatcher.toString", + "call options.localeMatcher.toString", + "get options.calendar", + "get options.calendar.toString", + "call options.calendar.toString", + "get options.numberingSystem", + "get options.numberingSystem.toString", + "call options.numberingSystem.toString", // CreateDateTimeFormat step 12. - "hour12", + "get options.hour12", // CreateDateTimeFormat step 13. - "hourCycle", + "get options.hourCycle", + "get options.hourCycle.toString", + "call options.hourCycle.toString", // CreateDateTimeFormat step 29. - "timeZone", + "get options.timeZone", + "get options.timeZone.toString", + "call options.timeZone.toString", // CreateDateTimeFormat step 36. - "weekday", - "era", - "year", - "month", - "day", - "hour", - "minute", - "second", - "timeZoneName", + "get options.weekday", + "get options.weekday.toString", + "call options.weekday.toString", + "get options.era", + "get options.era.toString", + "call options.era.toString", + "get options.year", + "get options.year.toString", + "call options.year.toString", + "get options.month", + "get options.month.toString", + "call options.month.toString", + "get options.day", + "get options.day.toString", + "call options.day.toString", + "get options.dayPeriod", + "get options.dayPeriod.toString", + "call options.dayPeriod.toString", + "get options.hour", + "get options.hour.toString", + "call options.hour.toString", + "get options.minute", + "get options.minute.toString", + "call options.minute.toString", + "get options.second", + "get options.second.toString", + "call options.second.toString", + "get options.fractionalSecondDigits", + "get options.fractionalSecondDigits.valueOf", + "call options.fractionalSecondDigits.valueOf", + "get options.timeZoneName", + "get options.timeZoneName.toString", + "call options.timeZoneName.toString", // CreateDateTimeFormat step 37. - "formatMatcher", + "get options.formatMatcher", + "get options.formatMatcher.toString", + "call options.formatMatcher.toString", + // CreateDateTimeFormat step 38. + "get options.dateStyle", + // CreateDateTimeFormat step 40. + "get options.timeStyle", ]; const actual = []; -const options = { - get day() { - actual.push("day"); - return "numeric"; - }, - - get era() { - actual.push("era"); - return "long"; - }, - - get formatMatcher() { - actual.push("formatMatcher"); - return "best fit"; - }, - - get hour() { - actual.push("hour"); - return "numeric"; - }, - - get hour12() { - actual.push("hour12"); - return true; - }, - - get hourCycle() { - actual.push("hourCycle"); - return "h24"; - }, - - get localeMatcher() { - actual.push("localeMatcher"); - return "best fit"; - }, - - get minute() { - actual.push("minute"); - return "numeric"; - }, - - get month() { - actual.push("month"); - return "numeric"; - }, - - get second() { - actual.push("second"); - return "numeric"; - }, - - get timeZone() { - actual.push("timeZone"); - return "UTC"; - }, - - get timeZoneName() { - actual.push("timeZoneName"); - return "long"; - }, - - get weekday() { - actual.push("weekday"); - return "long"; - }, - - get year() { - actual.push("year"); - return "numeric"; - }, -}; +const options = TemporalHelpers.propertyBagObserver(actual, { + calendar: "gregory", + dateStyle: undefined, + day: "numeric", + dayPeriod: "long", + era: "long", + formatMatcher: "best fit", + fractionalSecondDigits: 3, + hour: "numeric", + hour12: true, + hourCycle: "h24", + localeMatcher: "best fit", + minute: "numeric", + month: "numeric", + numberingSystem: "latn", + second: "numeric", + timeStyle: undefined, + timeZone: "UTC", + timeZoneName: "long", + weekday: "long", + year: "numeric", +}, "options"); new Intl.DateTimeFormat("en", options); diff --git a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-style-conflict.js b/third_party/test262/test/intl402/DateTimeFormat/constructor-options-style-conflict.js index 3ac721e9846a11..ee5391ca1dd043 100644 --- a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-style-conflict.js +++ b/third_party/test262/test/intl402/DateTimeFormat/constructor-options-style-conflict.js @@ -6,16 +6,15 @@ esid: sec-createdatetimeformat description: > Conflicting properties of dateStyle/timeStyle must be rejected with a TypeError for the options argument to the DateTimeFormat constructor. info: | - InitializeDateTimeFormat ( dateTimeFormat, locales, options ) + CreateDateTimeFormat ( newTarget, locales, options, required, defaults ) - ... - 43. If dateStyle is not undefined or timeStyle is not undefined, then - a. If hasExplicitFormatComponents is true, then - i. Throw a TypeError exception. - b. If required is date and timeStyle is not undefined, then - i. Throw a TypeError exception. - c. If required is time and dateStyle is not undefined, then - i. Throw a TypeError exception. + 1. If _dateStyle_ is not *undefined* or _timeStyle_ is not *undefined*, then + 1. If _hasExplicitFormatComponents_ is *true*, then + 1. Throw a *TypeError* exception. + 1. If _required_ is ~date~ and _timeStyle_ is not *undefined*, then + 1. Throw a *TypeError* exception. + 1. If _required_ is ~time~ and _dateStyle_ is not *undefined*, then + 1. Throw a *TypeError* exception. ---*/ diff --git a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-throwing-getters-dayPeriod.js b/third_party/test262/test/intl402/DateTimeFormat/constructor-options-throwing-getters-dayPeriod.js deleted file mode 100644 index 789ce8562fa2f9..00000000000000 --- a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-throwing-getters-dayPeriod.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2019 Google Inc. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-createdatetimeformat -description: Checks the propagation of exceptions from the options for the DateTimeFormat constructor. -features: [Intl.DateTimeFormat-dayPeriod] ----*/ - -function CustomError() {} - -const options = [ - "dayPeriod", -]; - -for (const option of options) { - assert.throws(CustomError, () => { - new Intl.DateTimeFormat("en", { - get [option]() { - throw new CustomError(); - } - }); - }, `Exception from ${option} getter should be propagated`); -} diff --git a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-throwing-getters-fractionalSecondDigits.js b/third_party/test262/test/intl402/DateTimeFormat/constructor-options-throwing-getters-fractionalSecondDigits.js deleted file mode 100644 index 5fb76b7899f600..00000000000000 --- a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-throwing-getters-fractionalSecondDigits.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2019 Google Inc. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-createdatetimeformat -description: Checks the propagation of exceptions from the options for the DateTimeFormat constructor. -features: [Intl.DateTimeFormat-fractionalSecondDigits] ----*/ - -function CustomError() {} - -const options = [ - "fractionalSecondDigits", -]; - -for (const option of options) { - assert.throws(CustomError, () => { - new Intl.DateTimeFormat("en", { - get [option]() { - throw new CustomError(); - } - }); - }, `Exception from ${option} getter should be propagated`); -} diff --git a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-throwing-getters-timedate-style.js b/third_party/test262/test/intl402/DateTimeFormat/constructor-options-throwing-getters-timedate-style.js deleted file mode 100644 index 2c2e27197ed84b..00000000000000 --- a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-throwing-getters-timedate-style.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2018 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-createdatetimeformat -description: Checks the propagation of exceptions from the options for the DateTimeFormat constructor. -features: [Intl.DateTimeFormat-datetimestyle] ----*/ - -// To be merged into constructor-options-throwing-getters.js when the feature is removed. - -function CustomError() {} - -const options = [ - // CreateDateTimeFormat step 39 - "dateStyle", - // CreateDateTimeFormat step 41 - "timeStyle", -]; - -for (const option of options) { - assert.throws(CustomError, () => { - new Intl.DateTimeFormat("en", { - get [option]() { - throw new CustomError(); - } - }); - }, `Exception from ${option} getter should be propagated`); -} diff --git a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-throwing-getters.js b/third_party/test262/test/intl402/DateTimeFormat/constructor-options-throwing-getters.js index 93af7e9195c62e..3d6b4fa84e6c0b 100644 --- a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-throwing-getters.js +++ b/third_party/test262/test/intl402/DateTimeFormat/constructor-options-throwing-getters.js @@ -4,20 +4,31 @@ /*--- esid: sec-createdatetimeformat description: Checks the propagation of exceptions from the options for the DateTimeFormat constructor. +features: + - Intl.DateTimeFormat-datetimestyle + - Intl.DateTimeFormat-dayPeriod + - Intl.DateTimeFormat-fractionalSecondDigits +locale: [en] ---*/ function CustomError() {} const options = [ "weekday", "year", "month", "day", + "dayPeriod", "hour", "minute", "second", + "fractionalSecondDigits", "localeMatcher", + "calendar", + "numberingSystem", "hour12", "hourCycle", "timeZone", "era", "timeZoneName", "formatMatcher", + "dateStyle", + "timeStyle", ]; for (const option of options) { diff --git a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-toobject.js b/third_party/test262/test/intl402/DateTimeFormat/constructor-options-toobject.js index 26799a2e3f8dd1..ef3d70a3610af0 100644 --- a/third_party/test262/test/intl402/DateTimeFormat/constructor-options-toobject.js +++ b/third_party/test262/test/intl402/DateTimeFormat/constructor-options-toobject.js @@ -4,7 +4,7 @@ /*--- esid: sec-createdatetimeformat description: > - Tests that Intl.DateTimeFormat contructor converts the options argument + Tests that Intl.DateTimeFormat constructor converts the options argument to an object using `ToObject` (7.1.13). ---*/ diff --git a/third_party/test262/test/intl402/DateTimeFormat/intl-legacy-constructed-symbol-on-unwrap.js b/third_party/test262/test/intl402/DateTimeFormat/intl-legacy-constructed-symbol-on-unwrap.js index 7536139e373556..8b01b9beb5ea99 100644 --- a/third_party/test262/test/intl402/DateTimeFormat/intl-legacy-constructed-symbol-on-unwrap.js +++ b/third_party/test262/test/intl402/DateTimeFormat/intl-legacy-constructed-symbol-on-unwrap.js @@ -12,21 +12,14 @@ features: [intl-normative-optional] let object = new Intl.DateTimeFormat(); let newObject = Intl.DateTimeFormat.call(object); let symbol = null; -let error = null; -try { - let proxy = new Proxy(newObject, { - get(target, property) { - symbol = property; - return target[property]; - } - }); - Intl.DateTimeFormat.prototype.resolvedOptions.call(proxy); -} catch (e) { - // If normative optional is not implemented, an error will be thrown. - error = e; - assert(error instanceof TypeError); -} -if (error === null) { - assert.sameValue(typeof symbol, "symbol"); - assert.sameValue(symbol.description, "IntlLegacyConstructedSymbol"); -} + +let proxy = new Proxy(newObject, { + get(target, property) { + symbol = property; + return target[property]; + } +}); +Intl.DateTimeFormat.prototype.resolvedOptions.call(proxy); + +assert.sameValue(typeof symbol, "symbol"); +assert.sameValue(symbol.description, "IntlLegacyConstructedSymbol"); diff --git a/third_party/test262/test/intl402/DateTimeFormat/intl-legacy-constructed-symbol-property.js b/third_party/test262/test/intl402/DateTimeFormat/intl-legacy-constructed-symbol-property.js new file mode 100644 index 00000000000000..eacf6924406df7 --- /dev/null +++ b/third_party/test262/test/intl402/DateTimeFormat/intl-legacy-constructed-symbol-property.js @@ -0,0 +1,37 @@ +// Copyright 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.datetimeformat +description: Property descriptor of %Intl%.[[FallbackSymbol]] +info: | + ChainDateTimeFormat ( dateTimeFormat, newTarget, this ) + + 1.a. Perform ? DefinePropertyOrThrow(_this_, %Intl%.[[FallbackSymbol]], + PropertyDescriptor{ [[Value]]: _dateTimeFormat_, [[Writable]]: *false*, + [[Enumerable]]: *false*, [[Configurable]]: *false* }). +includes: [propertyHelper.js] +features: [intl-normative-optional] +---*/ + +const object = Object.create(Intl.DateTimeFormat.prototype); +const fallbackDTF = Intl.DateTimeFormat.call(object); +assert.sameValue(object, fallbackDTF, "return value of Intl.DateTimeFormat constructor"); + +const symbolProps = Object.getOwnPropertySymbols(fallbackDTF); +const fallbackSymbol = symbolProps.find((sym) => sym.description === "IntlLegacyConstructedSymbol"); + +assert( + fallbackDTF[fallbackSymbol] instanceof Intl.DateTimeFormat, + "value of legacy symbol property must be an Intl.DateTimeFormat" +); +verifyProperty( + fallbackDTF, + fallbackSymbol, + { + writable: false, + enumerable: false, + configurable: false + }, + { label: "%Intl%.[[FallbackSymbol]]" } +); diff --git a/third_party/test262/test/intl402/DateTimeFormat/intl-legacy-constructed-symbol.js b/third_party/test262/test/intl402/DateTimeFormat/intl-legacy-constructed-symbol.js index 1050c902fa093d..ee057b4875b10b 100644 --- a/third_party/test262/test/intl402/DateTimeFormat/intl-legacy-constructed-symbol.js +++ b/third_party/test262/test/intl402/DateTimeFormat/intl-legacy-constructed-symbol.js @@ -12,7 +12,5 @@ features: [intl-normative-optional] let object = new Intl.DateTimeFormat(); let newObject = Intl.DateTimeFormat.call(object); let symbols = Object.getOwnPropertySymbols(newObject); -if (symbols.length !== 0) { - assert.sameValue(symbols.length, 1); - assert.sameValue(symbols[0].description, "IntlLegacyConstructedSymbol"); -} + +assert(symbols.some((symbol) => symbol.description === "IntlLegacyConstructedSymbol")); diff --git a/third_party/test262/test/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js b/third_party/test262/test/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js index 666bd8f7103a84..6512c7ec55e2d4 100644 --- a/third_party/test262/test/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js +++ b/third_party/test262/test/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializedatetimeformat +esid: sec-createdatetimeformat description: Checks basic handling of dayPeriod, short format. features: [Intl.DateTimeFormat-dayPeriod] locale: [en] diff --git a/third_party/test262/test/intl402/DateTimeFormat/timezone-case-insensitive.js b/third_party/test262/test/intl402/DateTimeFormat/timezone-case-insensitive.js index 46354004b8d182..d733b63a8e22ae 100644 --- a/third_party/test262/test/intl402/DateTimeFormat/timezone-case-insensitive.js +++ b/third_party/test262/test/intl402/DateTimeFormat/timezone-case-insensitive.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializedatetimeformat +esid: sec-createdatetimeformat description: Time zone identifiers are case-normalized features: [canonical-tz] ---*/ diff --git a/third_party/test262/test/intl402/DateTimeFormat/timezone-legacy-non-iana.js b/third_party/test262/test/intl402/DateTimeFormat/timezone-legacy-non-iana.js index e0adeca9996a8c..9d53e13b241ef2 100644 --- a/third_party/test262/test/intl402/DateTimeFormat/timezone-legacy-non-iana.js +++ b/third_party/test262/test/intl402/DateTimeFormat/timezone-legacy-non-iana.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializedatetimeformat +esid: sec-createdatetimeformat description: Only IANA time zone identifiers are allowed. ---*/ diff --git a/third_party/test262/test/intl402/DateTimeFormat/timezone-not-canonicalized.js b/third_party/test262/test/intl402/DateTimeFormat/timezone-not-canonicalized.js index e2964f617f626d..795df85e70fb3b 100644 --- a/third_party/test262/test/intl402/DateTimeFormat/timezone-not-canonicalized.js +++ b/third_party/test262/test/intl402/DateTimeFormat/timezone-not-canonicalized.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializedatetimeformat +esid: sec-createdatetimeformat description: Time zone identifiers are not canonicalized before storing in internal slots features: [canonical-tz] ---*/ diff --git a/third_party/test262/test/intl402/DurationFormat/constructor-option-read-order.js b/third_party/test262/test/intl402/DurationFormat/constructor-option-read-order.js deleted file mode 100644 index a37cf5ed59ae84..00000000000000 --- a/third_party/test262/test/intl402/DurationFormat/constructor-option-read-order.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2023 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-Intl.DurationFormat -description: Checks the order of option read. -features: [Intl.DurationFormat] -includes: [compareArray.js] ----*/ - -let optionKeys = Object.keys((new Intl.DurationFormat()).resolvedOptions()); -let opt = {}; -let readKeys = new Array(); -// For each item returned by resolvedOptions of default, add a getter -// to track the reading order. -optionKeys.forEach((property) => - Object.defineProperty(opt, property, { - get() { - readKeys[readKeys.length] = property; - return undefined; - }, - })); -let p = new Intl.DurationFormat(undefined, opt); -assert.compareArray( - readKeys, - ['numberingSystem', - 'style', - 'years', - 'yearsDisplay', - 'months', - 'monthsDisplay', - 'weeks', - 'weeksDisplay', - 'days', - 'daysDisplay', - 'hours', - 'hoursDisplay', - 'minutes', - 'minutesDisplay', - 'seconds', - 'secondsDisplay', - 'milliseconds', - 'millisecondsDisplay', - 'microseconds', - 'microsecondsDisplay', - 'nanoseconds', - 'nanosecondsDisplay']); diff --git a/third_party/test262/test/intl402/DurationFormat/constructor-options-order.js b/third_party/test262/test/intl402/DurationFormat/constructor-options-order.js index 7f91288b31d91d..c4a7c8b0a09c1a 100644 --- a/third_party/test262/test/intl402/DurationFormat/constructor-options-order.js +++ b/third_party/test262/test/intl402/DurationFormat/constructor-options-order.js @@ -10,32 +10,40 @@ info: | 5. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit"). 6. Let numberingSystem be ? GetOption(options, "numberingSystem", "string", undefined, undefined). 13. Let style be ? GetOption(options, "style", "string", « "long", "short", "narrow", "digital" », "long"). -includes: [compareArray.js] +includes: [compareArray.js, temporalHelpers.js] features: [Intl.DurationFormat] ---*/ var actual = []; -const options = { - get localeMatcher() { - actual.push("localeMatcher"); - return undefined; - }, - get numberingSystem() { - actual.push("numberingSystem"); - return undefined; - }, - get style() { - actual.push("style"); - return undefined; - }, -}; - const expected = [ - "localeMatcher", - "numberingSystem", - "style" + "get options.localeMatcher", + "get options.numberingSystem", + "get options.style", + "get options.years", + "get options.yearsDisplay", + "get options.months", + "get options.monthsDisplay", + "get options.weeks", + "get options.weeksDisplay", + "get options.days", + "get options.daysDisplay", + "get options.hours", + "get options.hoursDisplay", + "get options.minutes", + "get options.minutesDisplay", + "get options.seconds", + "get options.secondsDisplay", + "get options.milliseconds", + "get options.millisecondsDisplay", + "get options.microseconds", + "get options.microsecondsDisplay", + "get options.nanoseconds", + "get options.nanosecondsDisplay", + "get options.fractionalDigits", ]; +const options = TemporalHelpers.propertyBagObserver(actual, {}, "options"); + let nf = new Intl.DurationFormat(undefined, options); assert.compareArray(actual, expected); diff --git a/third_party/test262/test/intl402/FallbackSymbol/description.js b/third_party/test262/test/intl402/FallbackSymbol/description.js new file mode 100644 index 00000000000000..b32b72117694e0 --- /dev/null +++ b/third_party/test262/test/intl402/FallbackSymbol/description.js @@ -0,0 +1,22 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: intl-object +description: "%Intl%.[[FallbackSymbol]] description" +info: | + The Intl object: + - has a [[FallbackSymbol]] internal slot, which is a new %Symbol% in the + current realm with the [[Description]] *"IntlLegacyConstructedSymbol"*. +features: [intl-normative-optional] +---*/ + +const fallbackDTF = Intl.DateTimeFormat.call(Object.create(Intl.DateTimeFormat.prototype)); +const symbolProps = Object.getOwnPropertySymbols(fallbackDTF); +const fallbackSymbol = symbolProps.find((sym) => sym.description === "IntlLegacyConstructedSymbol"); + +assert.notSameValue( + fallbackSymbol, + undefined, + "%Intl%.[[FallbackSymbol]] with description IntlLegacyConstructedSymbol should exist" +); diff --git a/third_party/test262/test/intl402/FallbackSymbol/per-realm.js b/third_party/test262/test/intl402/FallbackSymbol/per-realm.js new file mode 100644 index 00000000000000..66c64064d62e36 --- /dev/null +++ b/third_party/test262/test/intl402/FallbackSymbol/per-realm.js @@ -0,0 +1,29 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: intl-object +description: "%Intl%.[[FallbackSymbol]] is per-realm" +info: | + The Intl object: + - has a [[FallbackSymbol]] internal slot, which is a new %Symbol% in the + current realm with the [[Description]] *"IntlLegacyConstructedSymbol"*. +features: [intl-normative-optional] +---*/ + +const fallbackDTF = Intl.DateTimeFormat.call(Object.create(Intl.DateTimeFormat.prototype)); +const symbolProps = Object.getOwnPropertySymbols(fallbackDTF); +const fallbackSymbol = symbolProps.find((sym) => sym.description === "IntlLegacyConstructedSymbol"); + +assert.notSameValue(fallbackSymbol, undefined, "%Intl%.[[FallbackSymbol]] should exist in original realm"); + +const other = $262.createRealm(); +const otherFallbackSymbol = other.evalScript(` + const fallbackDTF = Intl.DateTimeFormat.call(Object.create(Intl.DateTimeFormat.prototype)); + const symbolProps = Object.getOwnPropertySymbols(fallbackDTF); + symbolProps.find((sym) => sym.description === "IntlLegacyConstructedSymbol"); +`); + +assert.notSameValue(otherFallbackSymbol, undefined, "%Intl%.[[FallbackSymbol]] should exist in new realm"); + +assert.notSameValue(fallbackSymbol, otherFallbackSymbol, "%Intl%.[[FallbackSymbol]] should be different per-realm"); diff --git a/third_party/test262/test/intl402/Locale/constructor-options-throwing-getters.js b/third_party/test262/test/intl402/Locale/constructor-options-throwing-getters.js index ba5fb0b4f61b16..4c0936f7f9057b 100644 --- a/third_party/test262/test/intl402/Locale/constructor-options-throwing-getters.js +++ b/third_party/test262/test/intl402/Locale/constructor-options-throwing-getters.js @@ -4,7 +4,8 @@ /*--- esid: sec-Intl.Locale description: Checks the propagation of exceptions from the options for the Locale constructor. -features: [Intl.Locale] +features: [Intl.Locale, Intl.Locale-info] +locale: [en] ---*/ function CustomError() {} @@ -16,6 +17,7 @@ const options = [ "variants", "calendar", "collation", + "firstDayOfWeek", "hourCycle", "caseFirst", "numeric", diff --git a/third_party/test262/test/intl402/Number/prototype/toLocaleString/default-options-object-prototype.js b/third_party/test262/test/intl402/Number/prototype/toLocaleString/default-options-object-prototype.js index 8fc923078b18ef..a8198d99014f72 100644 --- a/third_party/test262/test/intl402/Number/prototype/toLocaleString/default-options-object-prototype.js +++ b/third_party/test262/test/intl402/Number/prototype/toLocaleString/default-options-object-prototype.js @@ -2,12 +2,12 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > Monkey-patching Object.prototype does not change the default options for NumberFormat as a null prototype is used. info: | - InitializeNumberFormat ( numberFormat, locales, options ) + Intl.NumberFormat ( [ locales [ , options ] ] ) 1. If _options_ is *undefined*, then 1. Let _options_ be ObjectCreate(*null*). diff --git a/third_party/test262/test/intl402/NumberFormat/casing-numbering-system-options.js b/third_party/test262/test/intl402/NumberFormat/casing-numbering-system-options.js index 79d780e85651d5..92bb7ecc8171a7 100644 --- a/third_party/test262/test/intl402/NumberFormat/casing-numbering-system-options.js +++ b/third_party/test262/test/intl402/NumberFormat/casing-numbering-system-options.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > Tests that the options numberingSystem are mapped to lower case. author: Caio Lima diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-compactDisplay-compact.js b/third_party/test262/test/intl402/NumberFormat/constructor-compactDisplay-compact.js index fe578299bfebe5..7af2abfab26c05 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-compactDisplay-compact.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-compactDisplay-compact.js @@ -2,16 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: Checks handling of the compactDisplay option to the NumberFormat constructor. info: | - InitializeNumberFormat ( numberFormat, locales, options ) + Intl.NumberFormat ( [ locales [ , options ] ] ) - 19. Let compactDisplay be ? GetOption(options, "compactDisplay", "string", « "short", "long" », "short"). - 20. If notation is "compact", then - a. Set numberFormat.[[CompactDisplay]] to compactDisplay. + 1. Let _compactDisplay_ be ? GetOption(_options_, *"compactDisplay"*, + ~string~, « *"short"*, *"long"* », *"short"*). + 1. If _notation_ is *"compact"*, then + 1. Set _numberFormat_.[[CompactDisplay]] to _compactDisplay_. -includes: [compareArray.js] features: [Intl.NumberFormat-unified] ---*/ @@ -22,23 +22,8 @@ const values = [ ]; for (const [value, expected = value] of values) { - const callOrder = []; - const nf = new Intl.NumberFormat([], { - get notation() { - callOrder.push("notation"); - return "compact"; - }, - get compactDisplay() { - callOrder.push("compactDisplay"); - return value; - } - }); + const nf = new Intl.NumberFormat([], { notation: "compact", compactDisplay: value }); const resolvedOptions = nf.resolvedOptions(); assert.sameValue("compactDisplay" in resolvedOptions, true); assert.sameValue(resolvedOptions.compactDisplay, expected); - - assert.compareArray(callOrder, [ - "notation", - "compactDisplay", - ]); } diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-compactDisplay-no-compact.js b/third_party/test262/test/intl402/NumberFormat/constructor-compactDisplay-no-compact.js index af94ac1c2fe642..6a9063ce74f05e 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-compactDisplay-no-compact.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-compactDisplay-no-compact.js @@ -2,52 +2,24 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: Checks handling of the compactDisplay option to the NumberFormat constructor. info: | - InitializeNumberFormat ( numberFormat, locales, options ) + Intl.NumberFormat ( [ locales [ , options ] ] ) - 19. Let compactDisplay be ? GetOption(options, "compactDisplay", "string", « "short", "long" », "short"). - 20. If notation is "compact", then - a. Set numberFormat.[[CompactDisplay]] to compactDisplay. + 1. Let _compactDisplay_ be ? GetOption(_options_, *"compactDisplay"*, + ~string~, « *"short"*, *"long"* », *"short"*). + 1. If _notation_ is *"compact"*, then + 1. Set _numberFormat_.[[CompactDisplay]] to _compactDisplay_. -includes: [compareArray.js] features: [Intl.NumberFormat-unified] ---*/ -const values = [ - [undefined, "short"], - ["short"], - ["long"], -]; - -const notations = [ - undefined, - "standard", - "scientific", - "engineering", -]; - -for (const notation of notations) { - for (const [value, expected = value] of values) { - const callOrder = []; - const nf = new Intl.NumberFormat([], { - get notation() { - callOrder.push("notation"); - return notation; - }, - get compactDisplay() { - callOrder.push("compactDisplay"); - return value; - } - }); +for (const notation of [undefined, "standard", "scientific", "engineering"]) { + for (const value of [undefined, "short", "long"]) { + const nf = new Intl.NumberFormat([], { notation, compactDisplay: value }); const resolvedOptions = nf.resolvedOptions(); assert.sameValue("compactDisplay" in resolvedOptions, false); assert.sameValue(resolvedOptions.compactDisplay, undefined); - - assert.compareArray(callOrder, [ - "notation", - "compactDisplay", - ]); } } diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-default-value.js b/third_party/test262/test/intl402/NumberFormat/constructor-default-value.js index 01634ed5e6d70b..fc63680bdb6c98 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-default-value.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-default-value.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > Tests that the constructor for Intl.NumberFormat uses appropriate default values for its arguments (locales and options). diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-locales-arraylike.js b/third_party/test262/test/intl402/NumberFormat/constructor-locales-arraylike.js index d065d26c4f6075..b3d13452b963ac 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-locales-arraylike.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-locales-arraylike.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > Tests that the Intl.NumberFormat constructor accepts Array-like values for the locales argument and treats them well. diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-locales-get-tostring.js b/third_party/test262/test/intl402/NumberFormat/constructor-locales-get-tostring.js index a8e3f4898a5fbf..2b8d0bf79228d5 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-locales-get-tostring.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-locales-get-tostring.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > Tests that Get(O, P) and ToString(arg) are properly called within the constructor for Intl.NumberFormat diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-locales-hasproperty.js b/third_party/test262/test/intl402/NumberFormat/constructor-locales-hasproperty.js index e0d0e39464a66f..b5f574f3a7266e 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-locales-hasproperty.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-locales-hasproperty.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > Tests that HasProperty(O, Pk) is properly called within the constructor for Intl.NumberFormat diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-locales-string.js b/third_party/test262/test/intl402/NumberFormat/constructor-locales-string.js index b0baa3a0843f09..8b2aea2c4f3743 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-locales-string.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-locales-string.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > Tests that passing a string value to the Intl.NumberFormat constructor is equivalent to passing an Array containing the same string value. diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-locales-toobject.js b/third_party/test262/test/intl402/NumberFormat/constructor-locales-toobject.js index 3d2625191bee83..04b007a21951d1 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-locales-toobject.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-locales-toobject.js @@ -2,9 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > - Tests that Intl.NumberFormat contructor converts the locales argument + Tests that Intl.NumberFormat constructor converts the locales argument to an object using `ToObject` (7.1.13). info: | 9.2.1 CanonicalizeLocaleList diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-notation.js b/third_party/test262/test/intl402/NumberFormat/constructor-notation.js index 1aa16ff391740f..2f7f3fa2a51914 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-notation.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-notation.js @@ -2,13 +2,15 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: Checks handling of the notation option to the NumberFormat constructor. info: | - InitializeNumberFormat ( numberFormat, locales, options ) + Intl.NumberFormat ( [ locales [ , options ] ] ) - 16. Let notation be ? GetOption(options, "notation", "string", « "standard", "scientific", "engineering", "compact" », "standard"). - 17. Set numberFormat.[[Notation]] to notation. + 1. Let _notation_ be ? GetOption(_options_, *"notation"*, ~string~, + « *"standard"*, *"scientific"*, *"engineering"*, *"compact"* », + *"standard"*). + 1. Set _numberFormat_.[[Notation]] to _notation_. features: [Intl.NumberFormat-unified] ---*/ diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-numberingSystem-order.js b/third_party/test262/test/intl402/NumberFormat/constructor-numberingSystem-order.js deleted file mode 100644 index b99b037f39272e..00000000000000 --- a/third_party/test262/test/intl402/NumberFormat/constructor-numberingSystem-order.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2019 Google Inc. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-initializenumberformat -description: > - Checks the order of getting "numberingSystem" option in the - NumberFormat is between "localeMatcher" and "style" options. -info: | - InitializeNumberFormat ( _numberFormat_, _locales_, _options_ ) - - 5. Let _matcher_ be ? GetOption(_options_, `"localeMatcher"`, `"string"`, « `"lookup"`, `"best fit"` », `"best fit"`). - ... - 7. Let _numberingSystem_ be ? GetOption(_options_, `"numberingSystem"`, `"string"`, *undefined*, *undefined*). - ... - 17. Let _style_ be ? GetOption(_options_, `"style"`, `"string"`, « `"decimal"`, `"percent"`, `"currency"` », `"decimal"`). -includes: [compareArray.js] ----*/ - -var actual = []; - -const options = { - get localeMatcher() { - actual.push("localeMatcher"); - return undefined; - }, - get numberingSystem() { - actual.push("numberingSystem"); - return undefined; - }, - get style() { - actual.push("style"); - return undefined; - }, -}; - -const expected = [ - "localeMatcher", - "numberingSystem", - "style" -]; - -let nf = new Intl.NumberFormat(undefined, options); -assert.compareArray(actual, expected); diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-option-read-order.js b/third_party/test262/test/intl402/NumberFormat/constructor-option-read-order.js index 7eff141a9cccf2..f76af33916e780 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-option-read-order.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-option-read-order.js @@ -2,54 +2,44 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat -description: Checks the order of option read. -features: [Intl.NumberFormat-v3] -includes: [compareArray.js] +esid: sec-intl.numberformat +description: Checks the order of options read. +features: [Intl.NumberFormat-unified, Intl.NumberFormat-v3] +includes: [compareArray.js, temporalHelpers.js] ---*/ let optionKeys = [ - // Inside InitializeNumberFormat - "localeMatcher", - "numberingSystem", + // Inside new NumberFormat() + "get options.localeMatcher", + "get options.numberingSystem", // Inside SetNumberFormatUnitOptions - "style", - "currency", - "currencyDisplay", - "currencySign", - "unit", - "unitDisplay", + "get options.style", + "get options.currency", + "get options.currencyDisplay", + "get options.currencySign", + "get options.unit", + "get options.unitDisplay", // End of SetNumberFormatUnitOptions - // Back to InitializeNumberFormat - "notation", + // Back to new NumberFormat() + "get options.notation", // Inside SetNumberFormatDigitOptions - "minimumIntegerDigits", - "minimumFractionDigits", - "maximumFractionDigits", - "minimumSignificantDigits", - "maximumSignificantDigits", - "roundingIncrement", - "roundingMode", - "roundingPriority", - "trailingZeroDisplay", + "get options.minimumIntegerDigits", + "get options.minimumFractionDigits", + "get options.maximumFractionDigits", + "get options.minimumSignificantDigits", + "get options.maximumSignificantDigits", + "get options.roundingIncrement", + "get options.roundingMode", + "get options.roundingPriority", + "get options.trailingZeroDisplay", // End of SetNumberFormatDigitOptions - // Back to InitializeNumberFormat - "compactDisplay", - "useGrouping", - "signDisplay" + // Back to new NumberFormat() + "get options.compactDisplay", + "get options.useGrouping", + "get options.signDisplay" ]; -// Use getters to track the order of reading known properties. -// TODO: Should we use a Proxy to detect *unexpected* property reads? -let reads = new Array(); -let options = {}; -optionKeys.forEach((key) => { - Object.defineProperty(options, key, { - get() { - reads.push(key); - return undefined; - }, - }); -}); +let reads = []; +let options = TemporalHelpers.propertyBagObserver(reads, {}, "options"); new Intl.NumberFormat(undefined, options); assert.compareArray(reads, optionKeys, "Intl.NumberFormat options read order"); diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-options-numberingSystem-invalid.js b/third_party/test262/test/intl402/NumberFormat/constructor-options-numberingSystem-invalid.js index bb9167e5bb5360..103f4e467ade00 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-options-numberingSystem-invalid.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-options-numberingSystem-invalid.js @@ -2,15 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > Checks error cases for the options argument to the NumberFormat constructor. info: | - InitializeNumberFormat ( numberFormat, locales, options ) + ResolveOptions ( constructor, localeData, locales, options [ , specialBehaviours [ , modifyResolutionOptions ] ] ) - ... - 8. If numberingSystem is not undefined, then - a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. + 1. If _value_ is not *undefined*, then + 1. ... + 1. If _value_ cannot be matched by the `type` Unicode locale nonterminal, + throw a *RangeError* exception. ---*/ /* diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-options-roundingMode-invalid.js b/third_party/test262/test/intl402/NumberFormat/constructor-options-roundingMode-invalid.js index 3fea7f7c6bcee1..500d52582221f7 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-options-roundingMode-invalid.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-options-roundingMode-invalid.js @@ -1,7 +1,7 @@ // Copyright 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: Abrupt completion from invalid values for `roundingMode` features: [Intl.NumberFormat-v3] ---*/ diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-options-throwing-getters-rounding-increment.js b/third_party/test262/test/intl402/NumberFormat/constructor-options-throwing-getters-rounding-increment.js deleted file mode 100644 index 9e3d024c794de6..00000000000000 --- a/third_party/test262/test/intl402/NumberFormat/constructor-options-throwing-getters-rounding-increment.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-initializenumberformat -description: > - Exception from accessing the "roundingIncrement" option for the NumberFormat - constructor should be propagated to the caller -features: [Intl.NumberFormat-v3] ----*/ - -assert.throws(Test262Error, function() { - new Intl.NumberFormat('en', { - get roundingIncrement() { - throw new Test262Error(); - } - }); -}); diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-options-throwing-getters-rounding-mode.js b/third_party/test262/test/intl402/NumberFormat/constructor-options-throwing-getters-rounding-mode.js deleted file mode 100644 index a6eedd84f20349..00000000000000 --- a/third_party/test262/test/intl402/NumberFormat/constructor-options-throwing-getters-rounding-mode.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-initializenumberformat -description: > - Exception from accessing the "roundingMode" option for the NumberFormat - constructor should be propagated to the caller -features: [Intl.NumberFormat-v3] ----*/ - -assert.throws(Test262Error, function() { - new Intl.NumberFormat('en', { - get roundingMode() { - throw new Test262Error(); - } - }); -}); diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-options-throwing-getters-rounding-priority.js b/third_party/test262/test/intl402/NumberFormat/constructor-options-throwing-getters-rounding-priority.js deleted file mode 100644 index 7225dd2f777849..00000000000000 --- a/third_party/test262/test/intl402/NumberFormat/constructor-options-throwing-getters-rounding-priority.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-initializenumberformat -description: > - Exception from accessing the "roundingPriority" option for the NumberFormat - constructor should be propagated to the caller -features: [Intl.NumberFormat-v3] ----*/ - -assert.throws(Test262Error, function() { - new Intl.NumberFormat('en', { - get roundingPriority() { - throw new Test262Error(); - } - }); -}); diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-options-throwing-getters-trailing-zero-display.js b/third_party/test262/test/intl402/NumberFormat/constructor-options-throwing-getters-trailing-zero-display.js deleted file mode 100644 index 8c361fefb65da3..00000000000000 --- a/third_party/test262/test/intl402/NumberFormat/constructor-options-throwing-getters-trailing-zero-display.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-initializenumberformat -description: > - Exception from accessing the "trailingZeroDisplay" option for the - NumberFormat constructor should be propagated to the caller -features: [Intl.NumberFormat-v3] ----*/ - -assert.throws(Test262Error, function() { - new Intl.NumberFormat('en', { - get trailingZeroDisplay() { - throw new Test262Error(); - } - }); -}); diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-options-throwing-getters.js b/third_party/test262/test/intl402/NumberFormat/constructor-options-throwing-getters.js index 2fa894b5e6726e..a0e36a1dcef889 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-options-throwing-getters.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-options-throwing-getters.js @@ -2,8 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: Checks the propagation of exceptions from the options for the NumberFormat constructor. +features: [Intl.NumberFormat-v3] ---*/ function CustomError() {} @@ -14,12 +15,22 @@ const options = [ "style", "currency", "currencyDisplay", + "currencySign", + "unit", + "unitDisplay", + "notation", "minimumIntegerDigits", "minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits", + "roundingIncrement", + "roundingMode", + "roundingPriority", + "trailingZeroDisplay", "useGrouping", + "compactDisplay", + "signDisplay", ]; for (const option of options) { diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-options-toobject.js b/third_party/test262/test/intl402/NumberFormat/constructor-options-toobject.js index 43f5d10edf1bbb..a85088d7c6462a 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-options-toobject.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-options-toobject.js @@ -2,14 +2,10 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > - Tests that Intl.NumberFormat contructor converts the options argument - to an object using `ToObject` (7.1.13). -info: | - 11.1.2 InitializeNumberFormat - - 3.a. Let options be ? ToObject(options). + Tests that Intl.NumberFormat constructor converts the options argument to an + object. ---*/ const toObjectResults = [ diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-order.js b/third_party/test262/test/intl402/NumberFormat/constructor-order.js index 4cf169034590a3..85e454e81ff93e 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-order.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-order.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: Checks handling of the unit option with the currency style. info: | SetNumberFormatUnitOptions ( intlObj, options ) diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-roundingIncrement-invalid.js b/third_party/test262/test/intl402/NumberFormat/constructor-roundingIncrement-invalid.js index e92266498e423b..19d38b58ce6af7 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-roundingIncrement-invalid.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-roundingIncrement-invalid.js @@ -2,7 +2,7 @@ // Copyright (C) 2022 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: Rejects invalid values for roundingIncrement option. features: [Intl.NumberFormat-v3] ---*/ diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-roundingIncrement.js b/third_party/test262/test/intl402/NumberFormat/constructor-roundingIncrement.js index 95a4bd5ce28440..055d689da4ac7a 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-roundingIncrement.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-roundingIncrement.js @@ -1,7 +1,7 @@ // Copyright 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: Checks handling of the roundingIncrement option to the NumberFormat constructor. includes: [compareArray.js] features: [Intl.NumberFormat-v3] diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-signDisplay-negative.js b/third_party/test262/test/intl402/NumberFormat/constructor-signDisplay-negative.js index 224dc028e43bef..ae3926194f1c31 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-signDisplay-negative.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-signDisplay-negative.js @@ -1,13 +1,15 @@ // Copyright 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: Checks handling of the compactDisplay option to the NumberFormat constructor. info: | - InitializeNumberFormat ( numberFormat, locales, options ) + Intl.NumberFormat ( [ locales [ , options ] ] ) - 32. Let signDisplay be ? GetOption(options, "signDisplay", "string", « "auto", "never", "always", "exceptZero", "negative" », "auto"). - 33. Set numberFormat.[[SignDisplay]] to signDisplay. + 1. Let _signDisplay_ be ? GetOption(_options_, *"signDisplay"*, ~string~, + « *"auto"*, *"never"*, *"always"*, *"exceptZero"*, *"negative"* », + *"auto"*). + 1. Set _numberFormat_.[[SignDisplay]] to _signDisplay_. includes: [propertyHelper.js] features: [Intl.NumberFormat-v3] ---*/ diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-signDisplay.js b/third_party/test262/test/intl402/NumberFormat/constructor-signDisplay.js index e0b6825cbf0fee..3a9014d5ae9ded 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-signDisplay.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-signDisplay.js @@ -2,13 +2,15 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: Checks handling of the compactDisplay option to the NumberFormat constructor. info: | - InitializeNumberFormat ( numberFormat, locales, options ) + Intl.NumberFormat ( [ locales [ , options ] ] ) - 23. Let signDisplay be ? GetOption(options, "signDisplay", "string", « "auto", "never", "always", "exceptZero" », "auto"). - 24. Set numberFormat.[[SignDisplay]] to signDisplay. + 1. Let _signDisplay_ be ? GetOption(_options_, *"signDisplay"*, ~string~, + « *"auto"*, *"never"*, *"always"*, *"exceptZero"*, *"negative"* », + *"auto"*). + 1. Set _numberFormat_.[[SignDisplay]] to _signDisplay_. features: [Intl.NumberFormat-unified] ---*/ diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-trailingZeroDisplay-invalid.js b/third_party/test262/test/intl402/NumberFormat/constructor-trailingZeroDisplay-invalid.js index 15a5a2269c8b43..b7ec3cb2e20f76 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-trailingZeroDisplay-invalid.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-trailingZeroDisplay-invalid.js @@ -1,7 +1,7 @@ // Copyright 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: Rejects invalid values for trailingZeroDisplay option. features: [Intl.NumberFormat-v3] ---*/ diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-trailingZeroDisplay.js b/third_party/test262/test/intl402/NumberFormat/constructor-trailingZeroDisplay.js index 92ab90ad3b80fc..9546c43ecfb4cb 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-trailingZeroDisplay.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-trailingZeroDisplay.js @@ -1,7 +1,7 @@ // Copyright 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: Checks handling of the trailingZeroDisplay option to the NumberFormat constructor. includes: [compareArray.js] features: [Intl.NumberFormat-v3] diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-unit.js b/third_party/test262/test/intl402/NumberFormat/constructor-unit.js index 555a07641033d2..fc25e6d5bb8b70 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-unit.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-unit.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: Checks handling of the unit style. includes: [testIntl.js] features: [Intl.NumberFormat-unified] diff --git a/third_party/test262/test/intl402/NumberFormat/constructor-unitDisplay.js b/third_party/test262/test/intl402/NumberFormat/constructor-unitDisplay.js index 033705ebef98e7..0a454c1ad747c3 100644 --- a/third_party/test262/test/intl402/NumberFormat/constructor-unitDisplay.js +++ b/third_party/test262/test/intl402/NumberFormat/constructor-unitDisplay.js @@ -2,14 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat -description: Checks handling of the compactDisplay option to the NumberFormat constructor. -info: | - InitializeNumberFormat ( numberFormat, locales, options ) - - 23. Let signDisplay be ? GetOption(options, "signDisplay", "string", « "auto", "never", "always", "exceptZero" », "auto"). - 24. Set numberFormat.[[SignDisplay]] to signDisplay. - +esid: sec-intl.numberformat +description: > + Checks handling of the unitDisplay option to the NumberFormat constructor. features: [Intl.NumberFormat-unified] ---*/ diff --git a/third_party/test262/test/intl402/NumberFormat/default-options-object-prototype.js b/third_party/test262/test/intl402/NumberFormat/default-options-object-prototype.js index 11356ea45781cf..e1c35a6792ab1c 100644 --- a/third_party/test262/test/intl402/NumberFormat/default-options-object-prototype.js +++ b/third_party/test262/test/intl402/NumberFormat/default-options-object-prototype.js @@ -2,12 +2,12 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > Monkey-patching Object.prototype does not change the default options for NumberFormat as a null prototype is used. info: | - InitializeNumberFormat ( numberFormat, locales, options ) + Intl.NumberFormat ( [ locales [ , options ] ] ) 1. If _options_ is *undefined*, then 1. Let _options_ be ObjectCreate(*null*). diff --git a/third_party/test262/test/intl402/NumberFormat/intl-legacy-constructed-symbol-on-unwrap.js b/third_party/test262/test/intl402/NumberFormat/intl-legacy-constructed-symbol-on-unwrap.js index f38c12fbb1ff16..283be9c666b42d 100644 --- a/third_party/test262/test/intl402/NumberFormat/intl-legacy-constructed-symbol-on-unwrap.js +++ b/third_party/test262/test/intl402/NumberFormat/intl-legacy-constructed-symbol-on-unwrap.js @@ -12,21 +12,14 @@ features: [intl-normative-optional] let object = new Intl.NumberFormat(); let newObject = Intl.NumberFormat.call(object); let symbol = null; -let error = null; -try { - let proxy = new Proxy(newObject, { - get(target, property) { - symbol = property; - return target[property]; - } - }); - Intl.NumberFormat.prototype.resolvedOptions.call(proxy); -} catch (e) { - // If normative optional is not implemented, an error will be thrown. - error = e; - assert(error instanceof TypeError); -} -if (error === null) { - assert.sameValue(typeof symbol, "symbol"); - assert.sameValue(symbol.description, "IntlLegacyConstructedSymbol"); -} + +let proxy = new Proxy(newObject, { + get(target, property) { + symbol = property; + return target[property]; + } +}); +Intl.NumberFormat.prototype.resolvedOptions.call(proxy); + +assert.sameValue(typeof symbol, "symbol"); +assert.sameValue(symbol.description, "IntlLegacyConstructedSymbol"); diff --git a/third_party/test262/test/intl402/NumberFormat/intl-legacy-constructed-symbol-property.js b/third_party/test262/test/intl402/NumberFormat/intl-legacy-constructed-symbol-property.js new file mode 100644 index 00000000000000..b297e3a909a563 --- /dev/null +++ b/third_party/test262/test/intl402/NumberFormat/intl-legacy-constructed-symbol-property.js @@ -0,0 +1,37 @@ +// Copyright 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.numberformat +description: Property descriptor of %Intl%.[[FallbackSymbol]] +info: | + ChainNumberFormat ( numberFormat, newTarget, this ) + + 1.a. Perform ? DefinePropertyOrThrow(_this_, %Intl%.[[FallbackSymbol]], + PropertyDescriptor{ [[Value]]: _numberFormat_, [[Writable]]: *false*, + [[Enumerable]]: *false*, [[Configurable]]: *false* }). +includes: [propertyHelper.js] +features: [intl-normative-optional] +---*/ + +const object = Object.create(Intl.NumberFormat.prototype); +const fallbackNF = Intl.NumberFormat.call(object); +assert.sameValue(object, fallbackNF, "return value of Intl.NumberFormat constructor"); + +const symbolProps = Object.getOwnPropertySymbols(fallbackNF); +const fallbackSymbol = symbolProps.find((sym) => sym.description === "IntlLegacyConstructedSymbol"); + +assert( + fallbackNF[fallbackSymbol] instanceof Intl.NumberFormat, + "value of legacy symbol property must be an Intl.NumberFormat" +); +verifyProperty( + fallbackNF, + fallbackSymbol, + { + writable: false, + enumerable: false, + configurable: false + }, + { label: "%Intl%.[[FallbackSymbol]]" } +); diff --git a/third_party/test262/test/intl402/NumberFormat/intl-legacy-constructed-symbol.js b/third_party/test262/test/intl402/NumberFormat/intl-legacy-constructed-symbol.js index 13726abf99aa97..747a7566567690 100644 --- a/third_party/test262/test/intl402/NumberFormat/intl-legacy-constructed-symbol.js +++ b/third_party/test262/test/intl402/NumberFormat/intl-legacy-constructed-symbol.js @@ -12,7 +12,5 @@ features: [intl-normative-optional] let object = new Intl.NumberFormat(); let newObject = Intl.NumberFormat.call(object); let symbols = Object.getOwnPropertySymbols(newObject); -if (symbols.length !== 0) { - assert.sameValue(symbols.length, 1); - assert.sameValue(symbols[0].description, "IntlLegacyConstructedSymbol"); -} + +assert(symbols.some((symbol) => symbol.description === "IntlLegacyConstructedSymbol")); diff --git a/third_party/test262/test/intl402/NumberFormat/numbering-system-options.js b/third_party/test262/test/intl402/NumberFormat/numbering-system-options.js index e1ecf45a390c08..04a768991ec2ae 100644 --- a/third_party/test262/test/intl402/NumberFormat/numbering-system-options.js +++ b/third_party/test262/test/intl402/NumberFormat/numbering-system-options.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > Tests that the options numberingSystem and calendar can be set through either the locale or the options. diff --git a/third_party/test262/test/intl402/NumberFormat/test-option-useGrouping-extended.js b/third_party/test262/test/intl402/NumberFormat/test-option-useGrouping-extended.js index 2cec7fb601d1cb..08ca512fb81460 100644 --- a/third_party/test262/test/intl402/NumberFormat/test-option-useGrouping-extended.js +++ b/third_party/test262/test/intl402/NumberFormat/test-option-useGrouping-extended.js @@ -4,7 +4,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: Tests that the option useGrouping is processed correctly. info: | The "Intl.NumberFormat v3" proposal contradicts the behavior required by the diff --git a/third_party/test262/test/intl402/NumberFormat/throws-for-maximumFractionDigits-over-limit.js b/third_party/test262/test/intl402/NumberFormat/throws-for-maximumFractionDigits-over-limit.js index f1eaedfa227cac..27d81b825d1b8a 100644 --- a/third_party/test262/test/intl402/NumberFormat/throws-for-maximumFractionDigits-over-limit.js +++ b/third_party/test262/test/intl402/NumberFormat/throws-for-maximumFractionDigits-over-limit.js @@ -2,17 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > Tests that the options maximumFractionDigits limit to the range 0 - 100. info: | - InitializeNumberFormat ( numberFormat, locales, options ) + SetNumberFormatDigitOptions ( intlObj, options, mnfdDefault, mxfdDefault, notation ) - 25.a.ii. Set mxfd to ? DefaultNumberOption(mxfd, 0, 100, undefined). + 23.a.ii. Set _mxfd_ to ? DefaultNumberOption(_mxfd_, 0, 100, *undefined*). - DefaultNumberOption ( value, minimum, maximum, fallback ) + DefaultNumberOption ( value, minimum, maximum, fallback ) - 3. If value is NaN or less than minimum or greater than maximum, throw a RangeError exception. + 3. If _value_ is not finite or ℝ(_value_) < _minimum_ or ℝ(_value_) > + _maximum_, throw a *RangeError* exception. ---*/ let wontThrow = new Intl.NumberFormat(undefined, {maximumFractionDigits: 100}); diff --git a/third_party/test262/test/intl402/NumberFormat/throws-for-maximumFractionDigits-under-limit.js b/third_party/test262/test/intl402/NumberFormat/throws-for-maximumFractionDigits-under-limit.js index 760735699e97bd..a2995c2c924564 100644 --- a/third_party/test262/test/intl402/NumberFormat/throws-for-maximumFractionDigits-under-limit.js +++ b/third_party/test262/test/intl402/NumberFormat/throws-for-maximumFractionDigits-under-limit.js @@ -2,17 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > Tests that the options maximumFractionDigits limit to the range 0 - 100. info: | - InitializeNumberFormat ( numberFormat, locales, options ) + SetNumberFormatDigitOptions ( intlObj, options, mnfdDefault, mxfdDefault, notation ) - 25.a.ii. Set mxfd to ? DefaultNumberOption(mxfd, 0, 100, undefined). + 23.a.ii. Set _mxfd_ to ? DefaultNumberOption(_mxfd_, 0, 100, *undefined*). - DefaultNumberOption ( value, minimum, maximum, fallback ) + DefaultNumberOption ( value, minimum, maximum, fallback ) - 3. If value is NaN or less than minimum or greater than maximum, throw a RangeError exception. + 3. If _value_ is not finite or ℝ(_value_) < _minimum_ or ℝ(_value_) > + _maximum_, throw a *RangeError* exception. ---*/ let wontThrow = new Intl.NumberFormat(undefined, {maximumFractionDigits: 0}); diff --git a/third_party/test262/test/intl402/NumberFormat/throws-for-minimumFractionDigits-over-limit.js b/third_party/test262/test/intl402/NumberFormat/throws-for-minimumFractionDigits-over-limit.js index 59905731dc16e7..ca8d8aaeb31170 100644 --- a/third_party/test262/test/intl402/NumberFormat/throws-for-minimumFractionDigits-over-limit.js +++ b/third_party/test262/test/intl402/NumberFormat/throws-for-minimumFractionDigits-over-limit.js @@ -2,17 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > Tests that the options minimumFractionDigits limit to the range 0 - 100. info: | - InitializeNumberFormat ( numberFormat, locales, options ) + SetNumberFormatDigitOptions ( intlObj, options, mnfdDefault, mxfdDefault, notation ) - 25.a.ii. Set mxfd to ? DefaultNumberOption(mxfd, 0, 100, undefined). + 23.a.i. Set _mnfd_ to ? DefaultNumberOption(_mnfd_, 0, 100, *undefined*). - DefaultNumberOption ( value, minimum, maximum, fallback ) + DefaultNumberOption ( value, minimum, maximum, fallback ) - 3. If value is NaN or less than minimum or greater than maximum, throw a RangeError exception. + 3. If _value_ is not finite or ℝ(_value_) < _minimum_ or ℝ(_value_) > + _maximum_, throw a *RangeError* exception. ---*/ let wontThrow = new Intl.NumberFormat(undefined, {minimumFractionDigits: 100}); diff --git a/third_party/test262/test/intl402/NumberFormat/throws-for-minimumFractionDigits-under-limit.js b/third_party/test262/test/intl402/NumberFormat/throws-for-minimumFractionDigits-under-limit.js index 80e286a93e6e52..c7605b13490139 100644 --- a/third_party/test262/test/intl402/NumberFormat/throws-for-minimumFractionDigits-under-limit.js +++ b/third_party/test262/test/intl402/NumberFormat/throws-for-minimumFractionDigits-under-limit.js @@ -2,17 +2,18 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializenumberformat +esid: sec-intl.numberformat description: > Tests that the options minimumFractionDigits limit to the range 0 - 100. info: | - InitializeNumberFormat ( numberFormat, locales, options ) + SetNumberFormatDigitOptions ( intlObj, options, mnfdDefault, mxfdDefault, notation ) - 25.a.ii. Set mxfd to ? DefaultNumberOption(mxfd, 0, 100, undefined). + 23.a.i. Set _mnfd_ to ? DefaultNumberOption(_mnfd_, 0, 100, *undefined*). - DefaultNumberOption ( value, minimum, maximum, fallback ) + DefaultNumberOption ( value, minimum, maximum, fallback ) - 3. If value is NaN or less than minimum or greater than maximum, throw a RangeError exception. + 3. If _value_ is not finite or ℝ(_value_) < _minimum_ or ℝ(_value_) > + _maximum_, throw a *RangeError* exception. ---*/ let wontThrow = new Intl.NumberFormat(undefined, {minimumFractionDigits: 0}); diff --git a/third_party/test262/test/intl402/PluralRules/compactDisplay-undefined-unless-notation-compact.js b/third_party/test262/test/intl402/PluralRules/compactDisplay-undefined-unless-notation-compact.js new file mode 100644 index 00000000000000..abd5b8cb368253 --- /dev/null +++ b/third_party/test262/test/intl402/PluralRules/compactDisplay-undefined-unless-notation-compact.js @@ -0,0 +1,50 @@ +// Copyright 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.pluralrules +description: compactDisplay option is only set when notation is compact +info: | + 17.4 Properties of Intl.PluralRules Instances + - [[CompactDisplay]] is one of *"short"*, *"long"*, or *undefined*, specifying + whether to display compact notation affixes in short form ("5K") or long + form ("5 thousand") if formatting with the *"compact"* notation, as this can + in some cases influence plural form selection. It is only *undefined* when + [[Notation]] has a value other than *"compact"*. +---*/ + +for (const compactDisplay of ["long", "short"]) { + const compact = new Intl.PluralRules(undefined, { notation: "compact", compactDisplay }); + const compactResolved = compact.resolvedOptions(); + + assert.sameValue(compactResolved.notation, "compact", `notation (compact, ${compactDisplay})`); + assert.sameValue(compactResolved.compactDisplay, compactDisplay, `compactDisplay (compact, ${compactDisplay})`); + + const undefinedNotation = new Intl.PluralRules(undefined, { compactDisplay }); + const undefinedResolved = undefinedNotation.resolvedOptions(); + + assert.sameValue(undefinedResolved.notation, "standard", "notation (standard is the default)"); + assert(!('compactDisplay' in undefinedResolved), `compactDisplay not defined for standard notation (undefined, ${compactDisplay})`); +} + +for (const notation of ["standard", "scientific", "engineering"]) { + for (const compactDisplay of ["long", "short", undefined]) { + const pr = new Intl.PluralRules(undefined, { notation, compactDisplay }); + const resolved = pr.resolvedOptions(); + + assert.sameValue(resolved.notation, notation, `notation (${notation}, ${compactDisplay})`); + assert(!('compactDisplay' in resolved), `compactDisplay not defined (${notation}, ${compactDisplay})`); + } +} + +const compactUndefined = new Intl.PluralRules(undefined, { notation: "compact" }); +const compactUndefinedResolved = compactUndefined.resolvedOptions(); + +assert.sameValue(compactUndefinedResolved.notation, "compact", `notation (compact, undefined)`); +assert.sameValue(compactUndefinedResolved.compactDisplay, "short", "compactDisplay (short is the default)"); + +const allUndefined = new Intl.PluralRules(); +const allUndefinedResolved = allUndefined.resolvedOptions(); + +assert.sameValue(allUndefinedResolved.notation, "standard", "notation (standard is the default)"); +assert(!('compactDisplay' in allUndefinedResolved), "compactDisplay not defined for standard notation"); diff --git a/third_party/test262/test/intl402/PluralRules/constructor-option-read-order.js b/third_party/test262/test/intl402/PluralRules/constructor-option-read-order.js index 3a3ca0912fa8d4..96d11ce6b86dc2 100644 --- a/third_party/test262/test/intl402/PluralRules/constructor-option-read-order.js +++ b/third_party/test262/test/intl402/PluralRules/constructor-option-read-order.js @@ -2,41 +2,32 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializepluralrules -description: Checks the order of option read. +esid: sec-intl.pluralrules +description: Checks the order of options read. features: [Intl.NumberFormat-v3] -includes: [compareArray.js] +includes: [compareArray.js, temporalHelpers.js] ---*/ let optionKeys = [ - // Inside InitializePluralRules - "localeMatcher", - "type", - "notation", + // Inside new PluralRules() + "get options.localeMatcher", + "get options.type", + "get options.notation", + "get options.compactDisplay", // Inside SetNumberFormatDigitOptions - "minimumIntegerDigits", - "minimumFractionDigits", - "maximumFractionDigits", - "minimumSignificantDigits", - "maximumSignificantDigits", - "roundingIncrement", - "roundingMode", - "roundingPriority", - "trailingZeroDisplay", + "get options.minimumIntegerDigits", + "get options.minimumFractionDigits", + "get options.maximumFractionDigits", + "get options.minimumSignificantDigits", + "get options.maximumSignificantDigits", + "get options.roundingIncrement", + "get options.roundingMode", + "get options.roundingPriority", + "get options.trailingZeroDisplay", // End of SetNumberFormatDigitOptions ]; -// Use getters to track the order of reading known properties. -// TODO: Should we use a Proxy to detect *unexpected* property reads? -let reads = new Array(); -let options = {}; -optionKeys.forEach((key) => { - Object.defineProperty(options, key, { - get() { - reads.push(key); - return undefined; - }, - }); -}); +const reads = []; +const options = TemporalHelpers.propertyBagObserver(reads, {}, "options"); new Intl.PluralRules(undefined, options); assert.compareArray(reads, optionKeys, "Intl.PluralRules options read order"); diff --git a/third_party/test262/test/intl402/PluralRules/constructor-options-throwing-getters.js b/third_party/test262/test/intl402/PluralRules/constructor-options-throwing-getters.js index c240cfc037cb91..293eab9a4cf605 100644 --- a/third_party/test262/test/intl402/PluralRules/constructor-options-throwing-getters.js +++ b/third_party/test262/test/intl402/PluralRules/constructor-options-throwing-getters.js @@ -2,8 +2,11 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializepluralrules -description: Checks the propagation of exceptions from the options for the NumberFormat constructor. +esid: sec-intl.pluralrules +description: > + Checks the propagation of exceptions from the options for the PluralRules + constructor. +locale: [en] ---*/ function CustomError() {} @@ -12,11 +15,16 @@ const options = [ "localeMatcher", "type", "notation", + "compactDisplay", "minimumIntegerDigits", "minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits", + "roundingIncrement", + "roundingMode", + "roundingPriority", + "trailingZeroDisplay", ]; for (const option of options) { diff --git a/third_party/test262/test/intl402/PluralRules/default-options-object-prototype.js b/third_party/test262/test/intl402/PluralRules/default-options-object-prototype.js index 270ed8790ca53a..9cc7628f08a76e 100644 --- a/third_party/test262/test/intl402/PluralRules/default-options-object-prototype.js +++ b/third_party/test262/test/intl402/PluralRules/default-options-object-prototype.js @@ -2,15 +2,10 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializepluralrules +esid: sec-intl.pluralrules description: > Monkey-patching Object.prototype does not change the default options for PluralRules as a null prototype is used. -info: | - InitializePluralRules ( collator, locales, options ) - - 1. If _options_ is *undefined*, then - 1. Let _options_ be ObjectCreate(*null*). ---*/ Object.prototype.type = "ordinal"; diff --git a/third_party/test262/test/intl402/PluralRules/notation.js b/third_party/test262/test/intl402/PluralRules/notation.js index a0957aa511bd49..4a447eb534d400 100644 --- a/third_party/test262/test/intl402/PluralRules/notation.js +++ b/third_party/test262/test/intl402/PluralRules/notation.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializepluralrules +esid: sec-intl.pluralrules description: Checks that the notation option is picked up correctly. info: | Intl.PluralRules ( [ _locales_ [ , _options_ ] ] ) diff --git a/third_party/test262/test/intl402/PluralRules/proto-from-ctor-realm.js b/third_party/test262/test/intl402/PluralRules/proto-from-ctor-realm.js index 7cc7a934d73844..6c21914d7da11a 100644 --- a/third_party/test262/test/intl402/PluralRules/proto-from-ctor-realm.js +++ b/third_party/test262/test/intl402/PluralRules/proto-from-ctor-realm.js @@ -9,7 +9,6 @@ info: | 1. If NewTarget is undefined, throw a TypeError exception. 2. Let pluralRules be ? OrdinaryCreateFromConstructor(newTarget, "%PluralRulesPrototype%", « ... »). - 3. Return ? InitializePluralRules(pluralRules, locales, options). OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) diff --git a/third_party/test262/test/intl402/PluralRules/prototype/select/tainting.js b/third_party/test262/test/intl402/PluralRules/prototype/select/tainting.js index e69732839b9025..3684bc96942cd5 100644 --- a/third_party/test262/test/intl402/PluralRules/prototype/select/tainting.js +++ b/third_party/test262/test/intl402/PluralRules/prototype/select/tainting.js @@ -7,9 +7,10 @@ description: > Tests that the behavior of a Record is not affected by adversarial changes to Object.prototype. info: | - 1.1.1. InitializePluralRules (pluralRules, locales, options) - (...) - 1.1.1_6. Let t be ? GetOption(options, "type", "string", « "cardinal", "ordinal" », "cardinal"). + Intl.PluralRules ( [ locales [ , options ] ] ) + + 1. Let _t_ be ? GetOption(_options_, *"type"*, ~string~, « *"cardinal"*, + *"ordinal"* », *"cardinal"*). author: Zibi Braniecki includes: [testIntl.js] ---*/ diff --git a/third_party/test262/test/intl402/String/prototype/localeCompare/default-options-object-prototype.js b/third_party/test262/test/intl402/String/prototype/localeCompare/default-options-object-prototype.js index 3ef0b8606f6ba9..6fbfe9b295ec45 100644 --- a/third_party/test262/test/intl402/String/prototype/localeCompare/default-options-object-prototype.js +++ b/third_party/test262/test/intl402/String/prototype/localeCompare/default-options-object-prototype.js @@ -2,15 +2,10 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializecollator +esid: sec-intl.collator description: > Monkey-patching Object.prototype does not change the default options for Collator as a null prototype is used. -info: | - InitializeCollator ( collator, locales, options ) - - 1. If _options_ is *undefined*, then - 1. Let _options_ be ObjectCreate(*null*). ---*/ if (new Intl.Collator("en").resolvedOptions().locale === "en") { diff --git a/third_party/test262/test/intl402/Temporal/Duration/prototype/round/rounding-increment-relativeto.js b/third_party/test262/test/intl402/Temporal/Duration/prototype/round/rounding-increment-relativeto.js new file mode 100644 index 00000000000000..b50c5d7e3cb1a3 --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/Duration/prototype/round/rounding-increment-relativeto.js @@ -0,0 +1,16 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.round +description: Test a specific buggy case from temporal_rs +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const relativeTo = Temporal.ZonedDateTime.from('2025-03-09T03:00:00-07:00[America/Vancouver]'); +TemporalHelpers.assertDuration(new Temporal.Duration(0, 1, 0, 30).round({ + smallestUnit: "months", + roundingIncrement: 2, + relativeTo, +}), 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, `1m30d to 2m with relativeTo 2025-03-09T03:00:00-07:00[America/Vancouver]`); diff --git a/third_party/test262/test/intl402/Temporal/PlainDate/compare/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainDate/compare/future-calendar.js new file mode 100644 index 00000000000000..91e02b7e67e855 --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainDate/compare/future-calendar.js @@ -0,0 +1,26 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.compare +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +const okDate = new Temporal.PlainDate(1970, 1, 1); + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + Temporal.PlainDate.compare(`1970-01-01[u-ca=${calendar}]`, okDate); + }, `${calendar} is not yet supported (first argument, string)`); + assert.throws(RangeError, function () { + Temporal.PlainDate.compare({ year: 1970, month: 1, day: 1, calendar }, okDate); + }, `${calendar} is not yet supported (first argument, property bag)`); + assert.throws(RangeError, function () { + Temporal.PlainDate.compare(okDate, `1970-01-01[u-ca=${calendar}]`); + }, `${calendar} is not yet supported (second argument, string)`); + assert.throws(RangeError, function () { + Temporal.PlainDate.compare(okDate, { year: 1970, month: 1, day: 1, calendar }); + }, `${calendar} is not yet supported (second argument, property bag)`); +} diff --git a/third_party/test262/test/intl402/Temporal/PlainDate/from/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainDate/from/future-calendar.js new file mode 100644 index 00000000000000..c34c2013672bef --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainDate/from/future-calendar.js @@ -0,0 +1,18 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.from +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + Temporal.PlainDate.from(`1970-01-01[u-ca=${calendar}]`); + }, `${calendar} is not yet supported (string)`); + assert.throws(RangeError, function () { + Temporal.PlainDate.from({ year: 1970, month: 1, day: 1, calendar }); + }, `${calendar} is not yet supported (property bag)`); +} diff --git a/third_party/test262/test/intl402/Temporal/PlainDate/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainDate/future-calendar.js new file mode 100644 index 00000000000000..74815358e0dd6d --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainDate/future-calendar.js @@ -0,0 +1,15 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + new Temporal.PlainDate(1970, 1, 1, calendar); + }, `${calendar} is not yet supported`); +} diff --git a/third_party/test262/test/intl402/Temporal/PlainDate/prototype/equals/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainDate/prototype/equals/future-calendar.js new file mode 100644 index 00000000000000..045201b56b33a0 --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainDate/prototype/equals/future-calendar.js @@ -0,0 +1,20 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.equals +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +const okDate = new Temporal.PlainDate(1970, 1, 1); + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + okDate.equals(`1970-01-01[u-ca=${calendar}]`); + }, `${calendar} is not yet supported (string)`); + assert.throws(RangeError, function () { + okDate.equals({ year: 1970, month: 1, day: 1, calendar }); + }, `${calendar} is not yet supported (property bag)`); +} diff --git a/third_party/test262/test/intl402/Temporal/PlainDate/prototype/withCalendar/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainDate/prototype/withCalendar/future-calendar.js new file mode 100644 index 00000000000000..6ef223a8aeeb63 --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainDate/prototype/withCalendar/future-calendar.js @@ -0,0 +1,17 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.withcalendar +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +const okDate = new Temporal.PlainDate(1970, 1, 1); + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + okDate.withCalendar(calendar); + }, `${calendar} is not yet supported`); +} diff --git a/third_party/test262/test/intl402/Temporal/PlainDateTime/compare/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainDateTime/compare/future-calendar.js new file mode 100644 index 00000000000000..fdfe8f7f8b6c03 --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainDateTime/compare/future-calendar.js @@ -0,0 +1,26 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.compare +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +const okDate = new Temporal.PlainDateTime(1970, 1, 1); + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + Temporal.PlainDateTime.compare(`1970-01-01[u-ca=${calendar}]`, okDate); + }, `${calendar} is not yet supported (first argument, string)`); + assert.throws(RangeError, function () { + Temporal.PlainDateTime.compare({ year: 1970, month: 1, day: 1, calendar }, okDate); + }, `${calendar} is not yet supported (first argument, property bag)`); + assert.throws(RangeError, function () { + Temporal.PlainDateTime.compare(okDate, `1970-01-01[u-ca=${calendar}]`); + }, `${calendar} is not yet supported (second argument, string)`); + assert.throws(RangeError, function () { + Temporal.PlainDateTime.compare(okDate, { year: 1970, month: 1, day: 1, calendar }); + }, `${calendar} is not yet supported (second argument, property bag)`); +} diff --git a/third_party/test262/test/intl402/Temporal/PlainDateTime/from/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainDateTime/from/future-calendar.js new file mode 100644 index 00000000000000..ef2a5b4391ab11 --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainDateTime/from/future-calendar.js @@ -0,0 +1,18 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.from +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + Temporal.PlainDateTime.from(`1970-01-01[u-ca=${calendar}]`); + }, `${calendar} is not yet supported (string)`); + assert.throws(RangeError, function () { + Temporal.PlainDateTime.from({ year: 1970, month: 1, day: 1, calendar }); + }, `${calendar} is not yet supported (property bag)`); +} diff --git a/third_party/test262/test/intl402/Temporal/PlainDateTime/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainDateTime/future-calendar.js new file mode 100644 index 00000000000000..7a8e28cb9bec54 --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainDateTime/future-calendar.js @@ -0,0 +1,15 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + new Temporal.PlainDateTime(1970, 1, 1, 0, 0, 0, 0, 0, 0, calendar); + }, `${calendar} is not yet supported`); +} diff --git a/third_party/test262/test/intl402/Temporal/PlainDateTime/prototype/equals/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainDateTime/prototype/equals/future-calendar.js new file mode 100644 index 00000000000000..edbbd5ba0df1c4 --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainDateTime/prototype/equals/future-calendar.js @@ -0,0 +1,20 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.equals +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +const okDate = new Temporal.PlainDateTime(1970, 1, 1); + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + okDate.equals(`1970-01-01[u-ca=${calendar}]`); + }, `${calendar} is not yet supported (string)`); + assert.throws(RangeError, function () { + okDate.equals({ year: 1970, month: 1, day: 1, calendar }); + }, `${calendar} is not yet supported (property bag)`); +} diff --git a/third_party/test262/test/intl402/Temporal/PlainDateTime/prototype/withCalendar/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainDateTime/prototype/withCalendar/future-calendar.js new file mode 100644 index 00000000000000..3c04c90f8891f3 --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainDateTime/prototype/withCalendar/future-calendar.js @@ -0,0 +1,17 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.withcalendar +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +const okDate = new Temporal.PlainDateTime(1970, 1, 1); + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + okDate.withCalendar(calendar); + }, `${calendar} is not yet supported`); +} diff --git a/third_party/test262/test/intl402/Temporal/PlainMonthDay/from/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainMonthDay/from/future-calendar.js new file mode 100644 index 00000000000000..67822b6486ab91 --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainMonthDay/from/future-calendar.js @@ -0,0 +1,18 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.from +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + Temporal.PlainMonthDay.from(`1970-01-01[u-ca=${calendar}]`); + }, `${calendar} is not yet supported (string)`); + assert.throws(RangeError, function () { + Temporal.PlainMonthDay.from({ monthCode: "M01", day: 1, calendar }); + }, `${calendar} is not yet supported (property bag)`); +} diff --git a/third_party/test262/test/intl402/Temporal/PlainMonthDay/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainMonthDay/future-calendar.js new file mode 100644 index 00000000000000..3e790b941712dc --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainMonthDay/future-calendar.js @@ -0,0 +1,15 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + new Temporal.PlainMonthDay(1, 1, calendar, 1970); + }, `${calendar} is not yet supported`); +} diff --git a/third_party/test262/test/intl402/Temporal/PlainMonthDay/prototype/equals/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainMonthDay/prototype/equals/future-calendar.js new file mode 100644 index 00000000000000..cada985c9227cf --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainMonthDay/prototype/equals/future-calendar.js @@ -0,0 +1,20 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.equals +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +const okDate = new Temporal.PlainMonthDay(1, 1); + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + okDate.equals(`1970-01-01[u-ca=${calendar}]`); + }, `${calendar} is not yet supported (string)`); + assert.throws(RangeError, function () { + okDate.equals({ monthCode: "M01", day: 1, calendar }); + }, `${calendar} is not yet supported (property bag)`); +} diff --git a/third_party/test262/test/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/basic.js b/third_party/test262/test/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/basic.js index 6227fd6e5a37c5..26c47dddbe3353 100644 --- a/third_party/test262/test/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/basic.js +++ b/third_party/test262/test/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/basic.js @@ -28,6 +28,7 @@ info: | d. Perform ! CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), O). e. Increment n by 1. 5. Return result. +features: [Temporal] locale: [en-US, de-AT] ---*/ diff --git a/third_party/test262/test/intl402/Temporal/PlainYearMonth/compare/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainYearMonth/compare/future-calendar.js new file mode 100644 index 00000000000000..b866e7675ba91f --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainYearMonth/compare/future-calendar.js @@ -0,0 +1,26 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.compare +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +const okDate = new Temporal.PlainYearMonth(1970, 1); + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + Temporal.PlainYearMonth.compare(`1970-01-01[u-ca=${calendar}]`, okDate); + }, `${calendar} is not yet supported (first argument, string)`); + assert.throws(RangeError, function () { + Temporal.PlainYearMonth.compare({ year: 1970, month: 1, calendar }, okDate); + }, `${calendar} is not yet supported (first argument, property bag)`); + assert.throws(RangeError, function () { + Temporal.PlainYearMonth.compare(okDate, `1970-01-01[u-ca=${calendar}]`); + }, `${calendar} is not yet supported (second argument, string)`); + assert.throws(RangeError, function () { + Temporal.PlainYearMonth.compare(okDate, { year: 1970, month: 1, calendar }); + }, `${calendar} is not yet supported (second argument, property bag)`); +} diff --git a/third_party/test262/test/intl402/Temporal/PlainYearMonth/from/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainYearMonth/from/future-calendar.js new file mode 100644 index 00000000000000..7b5f62bfbd7d7c --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainYearMonth/from/future-calendar.js @@ -0,0 +1,18 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.from +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + Temporal.PlainYearMonth.from(`1970-01-01[u-ca=${calendar}]`); + }, `${calendar} is not yet supported (string)`); + assert.throws(RangeError, function () { + Temporal.PlainYearMonth.from({ year: 1970, month: 1, calendar }); + }, `${calendar} is not yet supported (property bag)`); +} diff --git a/third_party/test262/test/intl402/Temporal/PlainYearMonth/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainYearMonth/future-calendar.js new file mode 100644 index 00000000000000..88cd89d014f0c7 --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainYearMonth/future-calendar.js @@ -0,0 +1,15 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + new Temporal.PlainYearMonth(1970, 1, calendar, 1); + }, `${calendar} is not yet supported`); +} diff --git a/third_party/test262/test/intl402/Temporal/PlainYearMonth/prototype/equals/future-calendar.js b/third_party/test262/test/intl402/Temporal/PlainYearMonth/prototype/equals/future-calendar.js new file mode 100644 index 00000000000000..7d348e8008dd74 --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/PlainYearMonth/prototype/equals/future-calendar.js @@ -0,0 +1,20 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.equals +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +const okDate = new Temporal.PlainYearMonth(1970, 1); + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + okDate.equals(`1970-01-01[u-ca=${calendar}]`); + }, `${calendar} is not yet supported (string)`); + assert.throws(RangeError, function () { + okDate.equals({ year: 1970, month: 1, calendar }); + }, `${calendar} is not yet supported (property bag)`); +} diff --git a/third_party/test262/test/intl402/Temporal/ZonedDateTime/compare/future-calendar.js b/third_party/test262/test/intl402/Temporal/ZonedDateTime/compare/future-calendar.js new file mode 100644 index 00000000000000..eae30935d5a914 --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/ZonedDateTime/compare/future-calendar.js @@ -0,0 +1,26 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.compare +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +const okDate = new Temporal.ZonedDateTime(0n, "UTC"); + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + Temporal.ZonedDateTime.compare(`1970-01-01[UTC][u-ca=${calendar}]`, okDate); + }, `${calendar} is not yet supported (first argument, string)`); + assert.throws(RangeError, function () { + Temporal.ZonedDateTime.compare({ year: 1970, month: 1, day: 1, timeZone: "UTC", calendar }, okDate); + }, `${calendar} is not yet supported (first argument, property bag)`); + assert.throws(RangeError, function () { + Temporal.ZonedDateTime.compare(okDate, `1970-01-01[UTC][u-ca=${calendar}]`); + }, `${calendar} is not yet supported (second argument, string)`); + assert.throws(RangeError, function () { + Temporal.ZonedDateTime.compare(okDate, { year: 1970, month: 1, day: 1, timeZone: "UTC", calendar }); + }, `${calendar} is not yet supported (second argument, property bag)`); +} diff --git a/third_party/test262/test/intl402/Temporal/ZonedDateTime/from/future-calendar.js b/third_party/test262/test/intl402/Temporal/ZonedDateTime/from/future-calendar.js new file mode 100644 index 00000000000000..3cad10c270e947 --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/ZonedDateTime/from/future-calendar.js @@ -0,0 +1,18 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.from +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + Temporal.ZonedDateTime.from(`1970-01-01[UTC][u-ca=${calendar}]`); + }, `${calendar} is not yet supported (string)`); + assert.throws(RangeError, function () { + Temporal.ZonedDateTime.from({ year: 1970, month: 1, day: 1, timeZone: "UTC", calendar }); + }, `${calendar} is not yet supported (property bag)`); +} diff --git a/third_party/test262/test/intl402/Temporal/ZonedDateTime/future-calendar.js b/third_party/test262/test/intl402/Temporal/ZonedDateTime/future-calendar.js new file mode 100644 index 00000000000000..682fbeeeb0d8fa --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/ZonedDateTime/future-calendar.js @@ -0,0 +1,15 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + new Temporal.ZonedDateTime(0n, "UTC", calendar); + }, `${calendar} is not yet supported`); +} diff --git a/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/equals/future-calendar.js b/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/equals/future-calendar.js new file mode 100644 index 00000000000000..66af5eef3825b0 --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/equals/future-calendar.js @@ -0,0 +1,20 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.equals +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +const okDate = new Temporal.ZonedDateTime(0n, "UTC"); + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + okDate.equals(`1970-01-01[UTC][u-ca=${calendar}]`); + }, `${calendar} is not yet supported (string)`); + assert.throws(RangeError, function () { + okDate.equals({ year: 1970, month: 1, day: 1, timeZone: "UTC", calendar }); + }, `${calendar} is not yet supported (property bag)`); +} diff --git a/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/hoursInDay/same-date-starts-twice.js b/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/hoursInDay/same-date-starts-twice.js index 743dd3be44ca32..a02eb3741aed39 100644 --- a/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/hoursInDay/same-date-starts-twice.js +++ b/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/hoursInDay/same-date-starts-twice.js @@ -4,6 +4,7 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.hoursinday description: Handles dates with offset transitions where midnight occurs twice. +includes: [temporalHelpers.js] features: [Temporal] ---*/ @@ -17,3 +18,23 @@ const zdt3 = Temporal.ZonedDateTime.from('2010-11-08T23:00:00-03:30[America/St_J assert.sameValue(zdt1.hoursInDay, 24); assert.sameValue(zdt2.hoursInDay, 25); assert.sameValue(zdt3.hoursInDay, 24); + +const zdt4 = Temporal.ZonedDateTime.from("2010-03-04T23:10:00+11:00[Antarctica/Casey]"); +const zdt5 = Temporal.ZonedDateTime.from("2010-03-05T00:45:00+11:00[Antarctica/Casey]"); +// 3h backwards shift from +11 to +08 at 2010-03-05 02:00 +const zdt6 = Temporal.ZonedDateTime.from("2010-03-04T23:10:00+08:00[Antarctica/Casey]"); +const zdt7 = Temporal.ZonedDateTime.from("2010-03-05T00:45:00+08:00[Antarctica/Casey]"); + +assert.sameValue(zdt4.hoursInDay, 24, "March 4 has 24 hours (excluding discontiguous piece)"); +assert.sameValue(zdt5.hoursInDay, 27, "March 5 has 27 hours (calculated from discontiguous piece)"); +assert.sameValue(zdt6.hoursInDay, 24, "March 4 has 24 hours (calculated from discontiguous piece)"); +assert.sameValue(zdt7.hoursInDay, 27, "March 5 has 27 hours (including discontiguous piece of March 4)"); + +const startOfMarch4 = Temporal.ZonedDateTime.from("2010-03-04T00:00:00+11:00[Antarctica/Casey]"); +const startOfMarch5 = Temporal.ZonedDateTime.from("2010-03-05T00:00:00+11:00[Antarctica/Casey]"); + +TemporalHelpers.assertZonedDateTimesEqual( + startOfMarch4.add({ hours: startOfMarch4.hoursInDay }), + startOfMarch5, + "start of day + hours in day = start of next day" +); diff --git a/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/round/same-date-starts-twice.js b/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/round/same-date-starts-twice.js new file mode 100644 index 00000000000000..e0941c2ce5d45a --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/round/same-date-starts-twice.js @@ -0,0 +1,52 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.round +description: Always rounds to a startOfDay, even when midnight occurs twice +info: | + https://github.com/tc39/proposal-temporal/issues/2938 + https://github.com/tc39/proposal-temporal/issues/3312 +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const zdt1 = Temporal.ZonedDateTime.from('2010-03-04T23:10:00+11:00[Antarctica/Casey]'); +const zdt2 = Temporal.ZonedDateTime.from('2010-03-05T00:45:00+11:00[Antarctica/Casey]'); +// 3h backwards shift from +11 to +08 at 2010-03-05 02:00 +const zdt3 = Temporal.ZonedDateTime.from('2010-03-04T23:10:00+08:00[Antarctica/Casey]'); +const zdt4 = Temporal.ZonedDateTime.from('2010-03-05T00:45:00+08:00[Antarctica/Casey]'); + +const startOfMarch4 = Temporal.ZonedDateTime.from("2010-03-04T00:00:00+11:00[Antarctica/Casey]"); +const startOfMarch5 = Temporal.ZonedDateTime.from("2010-03-05T00:00:00+11:00[Antarctica/Casey]"); +const startOfMarch6 = Temporal.ZonedDateTime.from("2010-03-06T00:00:00+08:00[Antarctica/Casey]"); + +// Rounding down + +for (const roundingMode of ["floor", "trunc"]) { + const options = { smallestUnit: "days", roundingMode }; + TemporalHelpers.assertZonedDateTimesEqual(zdt1.round(options), startOfMarch4, `${zdt1} ${roundingMode}`); + TemporalHelpers.assertZonedDateTimesEqual(zdt2.round(options), startOfMarch5, `${zdt2} ${roundingMode}`); + TemporalHelpers.assertZonedDateTimesEqual(zdt3.round(options), startOfMarch4, `${zdt3} ${roundingMode}`); + TemporalHelpers.assertZonedDateTimesEqual(zdt4.round(options), startOfMarch5, `${zdt4} ${roundingMode}`); +} + +// Rounding to nearest + +for (const roundingMode of ["halfCeil", "halfEven", "halfExpand", "halfFloor", "halfTrunc"]) { + const options = { smallestUnit: "days", roundingMode }; + TemporalHelpers.assertZonedDateTimesEqual(zdt1.round(options), startOfMarch5, `${zdt1} ${roundingMode}`); + TemporalHelpers.assertZonedDateTimesEqual(zdt2.round(options), startOfMarch5, `${zdt2} ${roundingMode}`); + TemporalHelpers.assertZonedDateTimesEqual(zdt3.round(options), startOfMarch5, `${zdt3} ${roundingMode}`); + TemporalHelpers.assertZonedDateTimesEqual(zdt4.round(options), startOfMarch5, `${zdt4} ${roundingMode}`); +} + +// Rounding up + +for (const roundingMode of ["ceil", "expand"]) { + const options = { smallestUnit: "days", roundingMode }; + TemporalHelpers.assertZonedDateTimesEqual(zdt1.round(options), startOfMarch5, `${zdt1} ${roundingMode}`); + TemporalHelpers.assertZonedDateTimesEqual(zdt2.round(options), startOfMarch6, `${zdt2} ${roundingMode}`); + TemporalHelpers.assertZonedDateTimesEqual(zdt3.round(options), startOfMarch5, `${zdt3} ${roundingMode}`); + TemporalHelpers.assertZonedDateTimesEqual(zdt4.round(options), startOfMarch6, `${zdt4} ${roundingMode}`); +} diff --git a/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/startOfDay/same-date-starts-twice.js b/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/startOfDay/same-date-starts-twice.js index 1a43cc0a3f71c3..3d0d7c8a3f44e7 100644 --- a/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/startOfDay/same-date-starts-twice.js +++ b/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/startOfDay/same-date-starts-twice.js @@ -21,3 +21,17 @@ const startOfDay3 = Temporal.ZonedDateTime.from('2010-11-08T00:00:00-03:30[Ameri TemporalHelpers.assertZonedDateTimesEqual(zdt1.startOfDay(), zdt1); TemporalHelpers.assertZonedDateTimesEqual(zdt2.startOfDay(), startOfDay2); TemporalHelpers.assertZonedDateTimesEqual(zdt3.startOfDay(), startOfDay3); + +const zdt4 = Temporal.ZonedDateTime.from("2010-03-04T23:10:00+11:00[Antarctica/Casey]"); +const zdt5 = Temporal.ZonedDateTime.from("2010-03-05T00:45:00+11:00[Antarctica/Casey]"); +// 3h backwards shift from +11 to +08 at 2010-03-05 02:00 +const zdt6 = Temporal.ZonedDateTime.from("2010-03-04T23:10:00+08:00[Antarctica/Casey]"); +const zdt7 = Temporal.ZonedDateTime.from("2010-03-05T00:45:00+08:00[Antarctica/Casey]"); + +const startOfMarch4 = Temporal.ZonedDateTime.from("2010-03-04T00:00:00+11:00[Antarctica/Casey]"); +const startOfMarch5 = Temporal.ZonedDateTime.from("2010-03-05T00:00:00+11:00[Antarctica/Casey]"); + +TemporalHelpers.assertZonedDateTimesEqual(zdt4.startOfDay(), startOfMarch4, "start of March 4"); +TemporalHelpers.assertZonedDateTimesEqual(zdt5.startOfDay(), startOfMarch5, "start of March 5, calculated from discontiguous piece"); +TemporalHelpers.assertZonedDateTimesEqual(zdt6.startOfDay(), startOfMarch4, "start of March 4, calculated from discontiguous piece"); +TemporalHelpers.assertZonedDateTimesEqual(zdt7.startOfDay(), startOfMarch5, "start of March 5"); diff --git a/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/future-calendar.js b/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/future-calendar.js new file mode 100644 index 00000000000000..ee1ccd3db0fc24 --- /dev/null +++ b/third_party/test262/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/future-calendar.js @@ -0,0 +1,17 @@ +// Copyright (C) 2026 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withcalendar +description: Not-yet-adopted calendar IDs are rejected +includes: [temporalHelpers.js] +features: [Intl.Era-monthcode, Temporal] +---*/ + +const okDate = new Temporal.ZonedDateTime(0n, "UTC"); + +for (const calendar of TemporalHelpers.NotYetSupportedCalendars) { + assert.throws(RangeError, function () { + okDate.withCalendar(calendar); + }, `${calendar} is not yet supported`); +} diff --git a/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-async-generator.js b/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-async-generator.js index a1a056c69acd5f..e4b8a642f2cb5b 100644 --- a/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-async-generator.js +++ b/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-async-generator.js @@ -112,7 +112,7 @@ var c = new C(); var other = new C(); hasProp(C.prototype, '#m', false, 'method is not defined in the prototype'); -hasProp(C, '#m', false, 'method is not defined in the contructor'); +hasProp(C, '#m', false, 'method is not defined in the constructor'); hasProp(c, '#m', false, 'method cannot be seen outside of the class'); /*** diff --git a/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-async-method.js b/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-async-method.js index e9600518b5182b..bf550f23531a95 100644 --- a/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-async-method.js +++ b/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-async-method.js @@ -109,7 +109,7 @@ var c = new C(); var other = new C(); hasProp(C.prototype, '#m', false, 'method is not defined in the prototype'); -hasProp(C, '#m', false, 'method is not defined in the contructor'); +hasProp(C, '#m', false, 'method is not defined in the constructor'); hasProp(c, '#m', false, 'method cannot be seen outside of the class'); /*** diff --git a/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-generator.js b/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-generator.js index 16e61183d08517..867dbb52482b97 100644 --- a/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-generator.js +++ b/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-generator.js @@ -107,7 +107,7 @@ var c = new C(); var other = new C(); hasProp(C.prototype, '#m', false, 'method is not defined in the prototype'); -hasProp(C, '#m', false, 'method is not defined in the contructor'); +hasProp(C, '#m', false, 'method is not defined in the constructor'); hasProp(c, '#m', false, 'method cannot be seen outside of the class'); /*** diff --git a/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-method-initialize-order.js b/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-method-initialize-order.js index 1eccf62f430fb3..31321889463474 100644 --- a/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-method-initialize-order.js +++ b/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-method-initialize-order.js @@ -125,7 +125,7 @@ var c = new C(); var other = new C(); hasProp(C.prototype, '#m', false, 'method is not defined in the prototype'); -hasProp(C, '#m', false, 'method is not defined in the contructor'); +hasProp(C, '#m', false, 'method is not defined in the constructor'); hasProp(c, '#m', false, 'method cannot be seen outside of the class'); /*** diff --git a/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-method.js b/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-method.js index d4ffde2416e2f3..b32b929ea21105 100644 --- a/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-method.js +++ b/third_party/test262/test/language/expressions/class/elements/private-methods/prod-private-method.js @@ -105,7 +105,7 @@ var c = new C(); var other = new C(); hasProp(C.prototype, '#m', false, 'method is not defined in the prototype'); -hasProp(C, '#m', false, 'method is not defined in the contructor'); +hasProp(C, '#m', false, 'method is not defined in the constructor'); hasProp(c, '#m', false, 'method cannot be seen outside of the class'); /*** diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-assignment-expression-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-assignment-expression-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..8ddc27f61021ef --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-assignment-expression-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-arrow-assignment-expression.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +let f = () => new import.defer('./empty_FIXTURE.js').prop; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-assignment-expression-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-assignment-expression-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..e532e239076426 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-assignment-expression-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-arrow-assignment-expression.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +let f = () => new import.source('').prop; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-assignment-expression-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-assignment-expression-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..6a39703438ea00 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-assignment-expression-no-new-call-expression-prop-access.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-arrow-assignment-expression.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +let f = () => new import('').prop; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..d1ddf9d4e3aeab --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-arrow.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +let f = () => { + new import.defer('./empty_FIXTURE.js').prop; +}; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..abfd548ebec62e --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-arrow.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +let f = () => { + new import.source('').prop; +}; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..437539a006fd6d --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-arrow-no-new-call-expression-prop-access.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-arrow.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +let f = () => { + new import('').prop; +}; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-await-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-await-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..dc26458ef6cbfc --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-await-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-arrow-fn-await.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested in async arrow function, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +(async () => { + await new import.defer('./empty_FIXTURE.js').prop +}); diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-await-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-await-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..d8141a043db2f8 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-await-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-arrow-fn-await.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested in async arrow function, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +(async () => { + await new import.source('').prop +}); diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-await-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-await-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..1c2fe85b71d1b2 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-await-no-new-call-expression-prop-access.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-arrow-fn-await.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested in async arrow function, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +(async () => { + await new import('').prop +}); diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..dbd67482c6724d --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-arrow-fn-return-await.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested in async arrow function, returned) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +(async () => await new import.defer('./empty_FIXTURE.js').prop) diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..7643e397eb2fe1 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-arrow-fn-return-await.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested in async arrow function, returned) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +(async () => await new import.source('').prop) diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..ac025456672795 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-no-new-call-expression-prop-access.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-arrow-fn-return-await.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested in async arrow function, returned) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +(async () => await new import('').prop) diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-await-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-await-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..0f9a5f04a4a5cf --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-await-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-function-await.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +async function f() { + await new import.defer('./empty_FIXTURE.js').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-await-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-await-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..6b27129e63681b --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-await-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-function-await.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +async function f() { + await new import.source('').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-await-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-await-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..932f4ad84c4ac5 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-await-no-new-call-expression-prop-access.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-function-await.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +async function f() { + await new import('').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..5069f80612d91a --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-function.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +async function f() { + new import.defer('./empty_FIXTURE.js').prop; +} + diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..16a35f8a8d0a52 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-function.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +async function f() { + new import.source('').prop; +} + diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..04b6a5887af5ae --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-function.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +async function f() { + new import('').prop; +} + diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-return-await-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-return-await-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..e2768232524411 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-return-await-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-function-return-await.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +async function f() { + return await new import.defer('./empty_FIXTURE.js').prop; +} + diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-return-await-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-return-await-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..81038afa256e48 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-return-await-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-function-return-await.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +async function f() { + return await new import.source('').prop; +} + diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-return-await-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-return-await-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..b0959fc9c7d643 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-function-return-await-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-function-return-await.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +async function f() { + return await new import('').prop; +} + diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-gen-await-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-gen-await-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..a0b57e0fd9261e --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-gen-await-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-generator-await.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +async function * f() { + await new import.defer('./empty_FIXTURE.js').prop +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-gen-await-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-gen-await-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..c9d8b4beb80b59 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-gen-await-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-generator-await.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +async function * f() { + await new import.source('').prop +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-gen-await-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-gen-await-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..daaccbd5739323 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-async-gen-await-no-new-call-expression-prop-access.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-async-generator-await.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +async function * f() { + await new import('').prop +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..39b365ca73c341 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-block.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +{ + new import.defer('./empty_FIXTURE.js').prop; +}; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..4222edb06c4432 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-block.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +{ + new import.source('').prop; +}; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-labeled-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-labeled-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..e567ecb7a06287 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-labeled-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-block-labeled.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +label: { + new import.defer('./empty_FIXTURE.js').prop; +}; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-labeled-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-labeled-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..0c7db01a5288ed --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-labeled-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-block-labeled.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +label: { + new import.source('').prop; +}; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-labeled-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-labeled-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..fc169ae77e450c --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-labeled-no-new-call-expression-prop-access.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-block-labeled.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +label: { + new import('').prop; +}; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..e2831019e728c9 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-block-no-new-call-expression-prop-access.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-block.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +{ + new import('').prop; +}; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-do-while-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-do-while-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..997bee15d3410f --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-do-while-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-do-while.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested do while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +do { + new import.defer('./empty_FIXTURE.js').prop; +} while (false); diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-do-while-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-do-while-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..b472f981a2b36e --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-do-while-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-do-while.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested do while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +do { + new import.source('').prop; +} while (false); diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-do-while-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-do-while-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..d7a9489afd63c8 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-do-while-no-new-call-expression-prop-access.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-do-while.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested do while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +do { + new import('').prop; +} while (false); diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-braceless-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-braceless-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..c968dbba396c89 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-braceless-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-else-braceless.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested else syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +if (false) { + +} else new import.defer('./empty_FIXTURE.js').prop; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-braceless-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-braceless-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..8472d74ae13c5a --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-braceless-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-else-braceless.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested else syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +if (false) { + +} else new import.source('').prop; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-braceless-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-braceless-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..e6699eb3803d0f --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-braceless-no-new-call-expression-prop-access.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-else-braceless.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested else syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +if (false) { + +} else new import('').prop; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..c1d4cb261b39bb --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-else.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested else syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +if (false) { + +} else { + new import.defer('./empty_FIXTURE.js').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..973773257f6de8 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-else.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested else syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +if (false) { + +} else { + new import.source('').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..47eeedf38113c3 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-else-no-new-call-expression-prop-access.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-else.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested else syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +if (false) { + +} else { + new import('').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..0397c64991151c --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-function.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested function syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +function fn() { + new import.defer('./empty_FIXTURE.js').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..d27e7010486bdd --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-function.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested function syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +function fn() { + new import.source('').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..06575b171c894e --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-no-new-call-expression-prop-access.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-function.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested function syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +function fn() { + new import('').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-return-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-return-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..b9bfec14d1663f --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-return-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-function-return.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested function syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +function fn() { + return new import.defer('./empty_FIXTURE.js').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-return-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-return-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..de89b50a8f35c0 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-return-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-function-return.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested function syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +function fn() { + return new import.source('').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-return-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-return-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..bf8584bb2fab25 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-function-return-no-new-call-expression-prop-access.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-function-return.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested function syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +function fn() { + return new import('').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-braceless-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-braceless-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..8072a46487f794 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-braceless-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-if-braceless.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested if syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +if (true) new import.defer('./empty_FIXTURE.js').prop; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-braceless-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-braceless-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..0e19e53cb11e76 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-braceless-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-if-braceless.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested if syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +if (true) new import.source('').prop; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-braceless-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-braceless-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..5003372810baf1 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-braceless-no-new-call-expression-prop-access.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-if-braceless.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested if syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +if (true) new import('').prop; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..5faf5679d55152 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-if.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested if syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +if (true) { + new import.defer('./empty_FIXTURE.js').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..6c7125b7c5fd62 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-if.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested if syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +if (true) { + new import.source('').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..ff4fc58f160cf5 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-if-no-new-call-expression-prop-access.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-if.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested if syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +if (true) { + new import('').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-while-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-while-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..ae47e95d78d364 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-while-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-while.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +let x = 0; +while (!x) { + x++; + new import.defer('./empty_FIXTURE.js').prop; +}; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-while-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-while-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..6981e3f6f3f5ae --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-while-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-while.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +let x = 0; +while (!x) { + x++; + new import.source('').prop; +}; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-while-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-while-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..3d39417b7aacaf --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-while-no-new-call-expression-prop-access.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-while.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +let x = 0; +while (!x) { + x++; + new import('').prop; +}; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-expression-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-expression-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..d0ed27582cac60 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-expression-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-with-expression.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested with syntax in the expression position) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated, noStrict] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +with (new import.defer('./empty_FIXTURE.js').prop) {} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-expression-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-expression-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..7f89926970a895 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-expression-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-with-expression.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested with syntax in the expression position) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated, noStrict] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +with (new import.source('').prop) {} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-expression-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-expression-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..f52023f555fc73 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-expression-no-new-call-expression-prop-access.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-with-expression.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested with syntax in the expression position) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, noStrict] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +with (new import('').prop) {} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..a20c4549ff3850 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-with.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested with syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated, noStrict] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +with ({}) { + new import.defer('./empty_FIXTURE.js').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..669cbdee4c7573 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-with.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested with syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated, noStrict] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +with ({}) { + new import.source('').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..fc9f7f0977fb6d --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/nested-with-no-new-call-expression-prop-access.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/nested-with.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (nested with syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated, noStrict] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +with ({}) { + new import('').prop; +} diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/top-level-import-defer-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/top-level-import-defer-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..a718b448c7d7e6 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/top-level-import-defer-no-new-call-expression-prop-access.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-defer-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/top-level.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (top level syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-defer, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . defer ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +new import.defer('./empty_FIXTURE.js').prop; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/top-level-import-source-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/top-level-import-source-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..e0e48b9037284d --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/top-level-import-source-no-new-call-expression-prop-access.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-source-no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/top-level.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (top level syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [source-phase-imports, source-phase-imports-module-source, dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import . source ( AssignmentExpression[+In, ?Yield, ?Await] ) + + NewExpression : + MemberExpression + new NewExpression + +---*/ + +$DONOTEVALUATE(); + +new import.source('').prop; diff --git a/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/top-level-no-new-call-expression-prop-access.js b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/top-level-no-new-call-expression-prop-access.js new file mode 100644 index 00000000000000..6eda9a9a806a03 --- /dev/null +++ b/third_party/test262/test/language/expressions/dynamic-import/syntax/invalid/top-level-no-new-call-expression-prop-access.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/no-new-call-expression-prop-access.case +// - src/dynamic-import/syntax/invalid/top-level.template +/*--- +description: ImportCall is a CallExpression, it can't be preceded by the new keyword (property access) (top level syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [dynamic-import] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ImportCall : + import( AssignmentExpression ) + + + CallExpression: + ImportCall + CallExpression . IdentifierName + + ImportCall : + import( AssignmentExpression[+In, ?Yield] ) + + NewExpression : + MemberExpression + new NewExpression +---*/ + +$DONOTEVALUATE(); + +new import('').prop; diff --git a/third_party/test262/test/language/module-code/ambiguous-export-bindings/namespace-import-source-and-export-1_FIXTURE.js b/third_party/test262/test/language/module-code/ambiguous-export-bindings/namespace-import-source-and-export-1_FIXTURE.js new file mode 100644 index 00000000000000..da46f44a8b5084 --- /dev/null +++ b/third_party/test262/test/language/module-code/ambiguous-export-bindings/namespace-import-source-and-export-1_FIXTURE.js @@ -0,0 +1,5 @@ +// Copyright (C) 2026 Guy Bedford. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +import source mod from ''; +export { mod }; diff --git a/third_party/test262/test/language/module-code/ambiguous-export-bindings/namespace-import-source-and-export-2_FIXTURE.js b/third_party/test262/test/language/module-code/ambiguous-export-bindings/namespace-import-source-and-export-2_FIXTURE.js new file mode 100644 index 00000000000000..da46f44a8b5084 --- /dev/null +++ b/third_party/test262/test/language/module-code/ambiguous-export-bindings/namespace-import-source-and-export-2_FIXTURE.js @@ -0,0 +1,5 @@ +// Copyright (C) 2026 Guy Bedford. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +import source mod from ''; +export { mod }; diff --git a/third_party/test262/test/language/module-code/ambiguous-export-bindings/namespace-import-source-and-export-reexport_FIXTURE.js b/third_party/test262/test/language/module-code/ambiguous-export-bindings/namespace-import-source-and-export-reexport_FIXTURE.js new file mode 100644 index 00000000000000..116974655c1d9a --- /dev/null +++ b/third_party/test262/test/language/module-code/ambiguous-export-bindings/namespace-import-source-and-export-reexport_FIXTURE.js @@ -0,0 +1,5 @@ +// Copyright (C) 2026 Guy Bedford. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export * from './namespace-import-source-and-export-1_FIXTURE.js'; +export * from './namespace-import-source-and-export-2_FIXTURE.js'; diff --git a/third_party/test262/test/language/module-code/ambiguous-export-bindings/namespace-unambiguous-if-import-source-and-export.js b/third_party/test262/test/language/module-code/ambiguous-export-bindings/namespace-unambiguous-if-import-source-and-export.js new file mode 100644 index 00000000000000..64c552aa69ba19 --- /dev/null +++ b/third_party/test262/test/language/module-code/ambiguous-export-bindings/namespace-unambiguous-if-import-source-and-export.js @@ -0,0 +1,57 @@ +// Copyright (C) 2026 Guy Bedford. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Re-exporting the same source-phase import via `import source mod from + ''; export { mod }` from two different modules produces an + unambiguous binding. +esid: sec-resolveexport +info: | + When ParseModule encounters `export { mod }` where `mod` is a local binding + introduced by `import source mod from "..."`, the ExportEntry is + reclassified as an indirect ExportEntry whose [[ImportName]] is ~source~. + + ResolveExport ( exportName, resolveSet ) + + [...] + For each ExportEntry Record e of module.[[IndirectExportEntries]], do + a. If e.[[ExportName]] is exportName, then + [...] + iii. If e.[[ImportName]] is namespace, then [...] + iv. Else if e.[[ImportName]] is source, then + 1. Assert: module does not provide the direct binding for this export. + 2. Return ResolvedBinding Record { [[Module]]: importedModule, + [[BindingName]]: source }. + [...] + + [...] + For each ExportEntry Record e of module.[[StarExportEntries]], do + a. Let importedModule be GetImportedModule(module, e.[[ModuleRequest]]). + b. Let resolution be ? importedModule.ResolveExport(exportName, resolveSet). + c. If resolution is ambiguous, return ambiguous. + d. If resolution is not null, then + i. If starResolution is null, set starResolution to resolution. + ii. Else, + 1. Assert: there is more than one * import that includes the requested name. + 2. If resolution.[[Module]] and starResolution.[[Module]] are not the + same Module Record, return ambiguous. + 3. If resolution.[[BindingName]] is not starResolution.[[BindingName]], + return ambiguous. + + Both fixtures contain `import source mod from ''; export { mod };`. + The host resolves '' to the same Module Record in both, so + the two ResolveExport results carry the same [[Module]] and the same + [[BindingName]] (~source~). The star-export ambiguity check therefore + succeeds, the named import of `mod` from the re-export resolves to a + ResolvedBinding Record with [[BindingName]] ~source~, and InitializeEnvironment + initializes `mod` to the underlying [[ModuleSource]]. +features: [source-phase-imports, source-phase-imports-module-source] +flags: [module] +---*/ + +import { mod } from './namespace-import-source-and-export-reexport_FIXTURE.js'; + +assert.sameValue(typeof mod, 'object', + 'Re-exported source-phase binding should resolve to a ModuleSource object'); +assert(mod instanceof $262.AbstractModuleSource, + '`mod` should be an instance of %AbstractModuleSource%'); diff --git a/third_party/test262/test/language/module-code/source-phase-import/reexport-source-binding-named-import.js b/third_party/test262/test/language/module-code/source-phase-import/reexport-source-binding-named-import.js new file mode 100644 index 00000000000000..80cd1f9a29c130 --- /dev/null +++ b/third_party/test262/test/language/module-code/source-phase-import/reexport-source-binding-named-import.js @@ -0,0 +1,41 @@ +// Copyright (C) 2026 Guy Bedford. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + A named import of a re-exported source-phase binding is initialized to the + imported module's ModuleSource object. +esid: sec-source-text-module-record-initialize-environment +info: | + When a module does `import source x from "..."; export { x };`, ParseModule + reclassifies the local re-export to an indirect ExportEntry whose + [[ImportName]] is ~source~. ResolveExport on the re-exporting module returns + a ResolvedBinding Record with [[BindingName]] ~source~ and [[Module]] set to + the source-phase target module. + + InitializeEnvironment ( ) + + 7. For each ImportEntry Record in of module.[[ImportEntries]], do + [...] + d. Else, + i. Assert: in.[[ImportName]] is a String. + ii. Let resolution be importedModule.ResolveExport(in.[[ImportName]]). + iii. If resolution is either null or ambiguous, throw a SyntaxError. + iv. If resolution.[[BindingName]] is namespace, then [...] + v. Else if resolution.[[BindingName]] is source, then + 1. Let moduleSourceObject be resolution.[[Module]].[[ModuleSource]]. + 2. If moduleSourceObject is empty, throw a SyntaxError exception. + 3. Perform ! env.CreateImmutableBinding(in.[[LocalName]], true). + 4. Perform ! env.InitializeBinding(in.[[LocalName]], moduleSourceObject). + + The named import `x` is therefore bound directly to the ModuleSource object + of the underlying module, an instance of %AbstractModuleSource%. +features: [source-phase-imports, source-phase-imports-module-source] +flags: [module] +---*/ + +import { x } from './reexport-source-binding_FIXTURE.js'; + +assert.sameValue(typeof x, 'object', + 'Named import of a re-exported source binding should be bound to an object'); +assert(x instanceof $262.AbstractModuleSource, + 'x should be a %AbstractModuleSource% instance (the underlying ModuleSource)'); diff --git a/third_party/test262/test/language/module-code/source-phase-import/reexport-source-binding-namespace-get.js b/third_party/test262/test/language/module-code/source-phase-import/reexport-source-binding-namespace-get.js new file mode 100644 index 00000000000000..8cff020abd6e85 --- /dev/null +++ b/third_party/test262/test/language/module-code/source-phase-import/reexport-source-binding-namespace-get.js @@ -0,0 +1,38 @@ +// Copyright (C) 2026 Guy Bedford. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Namespace [[Get]] of a re-exported source-phase binding returns the + imported module's ModuleSource object. +esid: sec-module-namespace-exotic-objects-get-p-receiver +info: | + When a module does `import source x from "..."; export { x };`, ParseModule + reclassifies the local re-export to an indirect ExportEntry whose + [[ImportName]] is ~source~. ResolveExport on the re-exporting module returns + a ResolvedBinding Record with [[BindingName]] ~source~ and [[Module]] set to + the source-phase target module. + + Module Namespace Exotic Object [[Get]] ( P, Receiver ) + + [...] + 7. If binding.[[BindingName]] is namespace, then + a. Return GetModuleNamespace(targetModule). + 8. If binding.[[BindingName]] is source, then + a. Let moduleSourceObject be targetModule.[[ModuleSource]]. + b. If moduleSourceObject is empty, throw a ReferenceError exception. + c. Return moduleSourceObject. + 9. [...] + + Accessing the re-exported binding via `ns.x` therefore returns the + ModuleSource object of the underlying module, an instance of + %AbstractModuleSource%. +features: [source-phase-imports, source-phase-imports-module-source] +flags: [module] +---*/ + +import * as ns from './reexport-source-binding_FIXTURE.js'; + +assert.sameValue(typeof ns.x, 'object', + 'Namespace [[Get]] of a re-exported source binding should return an object'); +assert(ns.x instanceof $262.AbstractModuleSource, + 'ns.x should be a %AbstractModuleSource% instance (the underlying ModuleSource)'); diff --git a/third_party/test262/test/language/module-code/source-phase-import/reexport-source-binding_FIXTURE.js b/third_party/test262/test/language/module-code/source-phase-import/reexport-source-binding_FIXTURE.js new file mode 100644 index 00000000000000..3f5d4ba216cc2d --- /dev/null +++ b/third_party/test262/test/language/module-code/source-phase-import/reexport-source-binding_FIXTURE.js @@ -0,0 +1,5 @@ +// Copyright (C) 2026 Guy Bedford. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +import source x from ''; +export { x }; diff --git a/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-async-generator.js b/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-async-generator.js index 829b9242ca8b7f..75e9804fa07cba 100644 --- a/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-async-generator.js +++ b/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-async-generator.js @@ -111,7 +111,7 @@ var c = new C(); var other = new C(); hasProp(C.prototype, '#m', false, 'method is not defined in the prototype'); -hasProp(C, '#m', false, 'method is not defined in the contructor'); +hasProp(C, '#m', false, 'method is not defined in the constructor'); hasProp(c, '#m', false, 'method cannot be seen outside of the class'); /*** diff --git a/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-async-method.js b/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-async-method.js index 59bf71e7a0b300..a84358595d7d8b 100644 --- a/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-async-method.js +++ b/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-async-method.js @@ -108,7 +108,7 @@ var c = new C(); var other = new C(); hasProp(C.prototype, '#m', false, 'method is not defined in the prototype'); -hasProp(C, '#m', false, 'method is not defined in the contructor'); +hasProp(C, '#m', false, 'method is not defined in the constructor'); hasProp(c, '#m', false, 'method cannot be seen outside of the class'); /*** diff --git a/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-generator.js b/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-generator.js index 4e45792c85f8ee..0432e06be31efd 100644 --- a/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-generator.js +++ b/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-generator.js @@ -106,7 +106,7 @@ var c = new C(); var other = new C(); hasProp(C.prototype, '#m', false, 'method is not defined in the prototype'); -hasProp(C, '#m', false, 'method is not defined in the contructor'); +hasProp(C, '#m', false, 'method is not defined in the constructor'); hasProp(c, '#m', false, 'method cannot be seen outside of the class'); /*** diff --git a/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-method-initialize-order.js b/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-method-initialize-order.js index 51f70e2b6c0f68..e5b64784874cd4 100644 --- a/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-method-initialize-order.js +++ b/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-method-initialize-order.js @@ -124,7 +124,7 @@ var c = new C(); var other = new C(); hasProp(C.prototype, '#m', false, 'method is not defined in the prototype'); -hasProp(C, '#m', false, 'method is not defined in the contructor'); +hasProp(C, '#m', false, 'method is not defined in the constructor'); hasProp(c, '#m', false, 'method cannot be seen outside of the class'); /*** diff --git a/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-method.js b/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-method.js index 7f4d1e2a0ad8f1..04af993cb3df97 100644 --- a/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-method.js +++ b/third_party/test262/test/language/statements/class/elements/private-methods/prod-private-method.js @@ -104,7 +104,7 @@ var c = new C(); var other = new C(); hasProp(C.prototype, '#m', false, 'method is not defined in the prototype'); -hasProp(C, '#m', false, 'method is not defined in the contructor'); +hasProp(C, '#m', false, 'method is not defined in the constructor'); hasProp(c, '#m', false, 'method cannot be seen outside of the class'); /*** diff --git a/third_party/test262/test/staging/set-is-subset-of-empty-index.js b/third_party/test262/test/staging/set-is-subset-of-empty-index.js new file mode 100644 index 00000000000000..07706fe9dc0fc9 --- /dev/null +++ b/third_party/test262/test/staging/set-is-subset-of-empty-index.js @@ -0,0 +1,18 @@ +// Copyright (C) 2023 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: https://github.com/tc39/proposal-set-methods/pull/102 +features: [set-methods] +---*/ + +let firstSet = new Set('a', 'b'); +let secondSet = { + size: 3, + has() { + firstSet.delete('b'); + firstSet.add('c'); + return true; + }, + * keys() {} +}; +assert.sameValue(firstSet.isSubsetOf(secondSet), true); diff --git a/third_party/test262/test/staging/sm/Atomics/cross-compartment.js b/third_party/test262/test/staging/sm/Atomics/cross-compartment.js index 2606709b850ad6..4dd3fe77775b65 100644 --- a/third_party/test262/test/staging/sm/Atomics/cross-compartment.js +++ b/third_party/test262/test/staging/sm/Atomics/cross-compartment.js @@ -5,6 +5,7 @@ description: | pending esid: pending +features: [Atomics, SharedArrayBuffer] ---*/ const otherGlobal = $262.createRealm().global; @@ -111,4 +112,3 @@ for (let TA of intArrayConstructors) { assert.sameValue(val, 3); assert.sameValue(ta[0], 2); } - diff --git a/third_party/test262/test/staging/sm/Atomics/detached-buffers.js b/third_party/test262/test/staging/sm/Atomics/detached-buffers.js index 9d0e605c2793c7..d1b1bf3ce31a8e 100644 --- a/third_party/test262/test/staging/sm/Atomics/detached-buffers.js +++ b/third_party/test262/test/staging/sm/Atomics/detached-buffers.js @@ -6,6 +6,7 @@ includes: [detachArrayBuffer.js] description: | pending esid: pending +features: [Atomics] ---*/ const intArrayConstructors = [ @@ -97,4 +98,3 @@ for (let TA of intArrayConstructors) { assert.throws(TypeError, () => Atomics.xor(ta, badValue(ta), 0)); assert.throws(TypeError, () => Atomics.xor(ta, 0, badValue(ta))); } - diff --git a/third_party/test262/test/staging/sm/Error/constructor-proto.js b/third_party/test262/test/staging/sm/Error/constructor-proto.js deleted file mode 100644 index 8893d43ebd8f48..00000000000000 --- a/third_party/test262/test/staging/sm/Error/constructor-proto.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Mozilla Corporation. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: | - pending -esid: pending ----*/ -const nativeErrors = [ - EvalError, - RangeError, - ReferenceError, - SyntaxError, - TypeError, - URIError -]; - -assert.sameValue(Reflect.getPrototypeOf(Error), Function.prototype) - -for (const error of nativeErrors) - assert.sameValue(Reflect.getPrototypeOf(error), Error); - diff --git a/third_party/test262/test/staging/sm/Error/prototype-properties.js b/third_party/test262/test/staging/sm/Error/prototype-properties.js deleted file mode 100644 index 983b3885f38f1d..00000000000000 --- a/third_party/test262/test/staging/sm/Error/prototype-properties.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2024 Mozilla Corporation. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: | - pending -esid: pending ----*/ -const nativeErrors = [ - EvalError, - RangeError, - ReferenceError, - SyntaxError, - TypeError, - URIError -]; - -const ownKeys = Reflect.ownKeys(Error.prototype); -for (const expected of ["constructor", "message", "name", "toString"]) { - assert.sameValue(ownKeys.includes(expected), true, "Error.prototype should have a key named " + expected); -} -assert.sameValue(Error.prototype.name, "Error"); -assert.sameValue(Error.prototype.message, ""); - -for (const error of nativeErrors) { - assert.sameValue(Reflect.ownKeys(error.prototype).sort().toString(), "constructor,message,name"); - assert.sameValue(error.prototype.name, error.name); - assert.sameValue(error.prototype.message, ""); - assert.sameValue(error.prototype.constructor, error); -} - diff --git a/third_party/test262/test/staging/sm/Error/prototype.js b/third_party/test262/test/staging/sm/Error/prototype.js deleted file mode 100644 index a590505c30f8b2..00000000000000 --- a/third_party/test262/test/staging/sm/Error/prototype.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2024 Mozilla Corporation. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: | - pending -esid: pending ----*/ -const nativeErrors = [ - EvalError, - RangeError, - ReferenceError, - SyntaxError, - TypeError, - URIError -]; - -assert.sameValue(Reflect.getPrototypeOf(Error.prototype), Object.prototype) - -for (const error of nativeErrors) { - assert.sameValue(Reflect.getPrototypeOf(error.prototype), Error.prototype); -} - diff --git a/third_party/test262/test/staging/sm/Function/builtin-no-construct.js b/third_party/test262/test/staging/sm/Function/builtin-no-construct.js index 9b32ff399b13e7..d8563ad6b07b88 100644 --- a/third_party/test262/test/staging/sm/Function/builtin-no-construct.js +++ b/third_party/test262/test/staging/sm/Function/builtin-no-construct.js @@ -7,6 +7,7 @@ description: | pending esid: pending +includes: [nativeErrors.js] ---*/ function checkMethod(method) { @@ -33,9 +34,8 @@ checkMethods(Math); checkMethods(Proxy); var builtin_ctors = [ - Object, Function, Array, String, Boolean, Number, Date, RegExp, Error, - EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError, -]; + Object, Function, Array, String, Boolean, Number, Date, RegExp +].concat(nativeErrors); for (var i = 0; i < builtin_ctors.length; i++) { checkMethods(builtin_ctors[i]); diff --git a/third_party/test262/test/staging/sm/Function/builtin-no-prototype.js b/third_party/test262/test/staging/sm/Function/builtin-no-prototype.js index 9a059fabada334..5a9d1310accc3f 100644 --- a/third_party/test262/test/staging/sm/Function/builtin-no-prototype.js +++ b/third_party/test262/test/staging/sm/Function/builtin-no-prototype.js @@ -7,6 +7,7 @@ description: | pending esid: pending +includes: [nativeErrors.js] ---*/ assert.sameValue(undefined, void 0); @@ -14,9 +15,8 @@ assert.sameValue(Function.prototype.hasOwnProperty('prototype'), false); assert.sameValue(Function.prototype.prototype, undefined); var builtin_ctors = [ - Object, Function, Array, String, Boolean, Number, Date, RegExp, Error, - EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError -]; + Object, Function, Array, String, Boolean, Number, Date, RegExp +].concat(nativeErrors); for (var i = 0; i < builtin_ctors.length; i++) { var c = builtin_ctors[i]; diff --git a/third_party/test262/test/staging/sm/TypedArray/sort-negative-nan.js b/third_party/test262/test/staging/sm/TypedArray/sort-negative-nan.js index 00e1c6c070c298..c5e0f433017679 100644 --- a/third_party/test262/test/staging/sm/TypedArray/sort-negative-nan.js +++ b/third_party/test262/test/staging/sm/TypedArray/sort-negative-nan.js @@ -6,6 +6,7 @@ includes: [sm/non262-TypedArray-shell.js] description: | pending esid: pending +features: [Float16Array, Float32Array, Float64Array] ---*/ // Test with all floating point typed arrays. const floatConstructors = anyTypedArrayConstructors.filter(isFloatConstructor); @@ -136,4 +137,3 @@ for (const [TA, taLength] of prod(floatConstructors, typedArrayLengths)) { assert.sameValue(fta[nanOffset + i], NaN, `At offset: ${nanOffset + i}`); } } - diff --git a/third_party/test262/test/staging/sm/TypedArray/toString.js b/third_party/test262/test/staging/sm/TypedArray/toString.js index 29adb9038ba34b..2b4d27d99a9067 100644 --- a/third_party/test262/test/staging/sm/TypedArray/toString.js +++ b/third_party/test262/test/staging/sm/TypedArray/toString.js @@ -6,6 +6,7 @@ includes: [sm/non262-TypedArray-shell.js, propertyHelper.js] description: | pending esid: pending +features: [Float16Array] ---*/ const TypedArrayPrototype = Object.getPrototypeOf(Int8Array.prototype); diff --git a/third_party/test262/vendored.toml b/third_party/test262/vendored.toml index 11954844c86b41..6d1062978bc586 100644 --- a/third_party/test262/vendored.toml +++ b/third_party/test262/vendored.toml @@ -1,3 +1,3 @@ [test262] source = "https://github.com/tc39/test262" -rev = "b66872a92487694396fb082343e08dd7cca5ddf4" +rev = "de8e621cdba4f40cff3cf244e6cfb8cb48746b4a"