From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- ...axbytelength-compared-before-object-creation.js | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 js/src/tests/test262/built-ins/SharedArrayBuffer/options-maxbytelength-compared-before-object-creation.js (limited to 'js/src/tests/test262/built-ins/SharedArrayBuffer/options-maxbytelength-compared-before-object-creation.js') diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/options-maxbytelength-compared-before-object-creation.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/options-maxbytelength-compared-before-object-creation.js new file mode 100644 index 0000000000..89544d6fa3 --- /dev/null +++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/options-maxbytelength-compared-before-object-creation.js @@ -0,0 +1,43 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!this.hasOwnProperty('SharedArrayBuffer')||!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- SharedArrayBuffer,resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sharedarraybuffer-length +description: > + The byteLength argument is validated before OrdinaryCreateFromConstructor. +info: | + SharedArrayBuffer ( length [ , options ] ) + + ... + 4. Return ? AllocateSharedArrayBuffer(NewTarget, byteLength, requestedMaxByteLength). + + AllocateSharedArrayBuffer ( constructor, byteLength [ , maxByteLength ] ) + + ... + 3. If allocatingGrowableBuffer is true, then + a. If byteLength > maxByteLength, throw a RangeError exception. + ... + 5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%SharedArrayBuffer.prototype%", slots). + ... + +features: [SharedArrayBuffer, resizable-arraybuffer, Reflect.construct] +---*/ + +let newTarget = Object.defineProperty(function(){}.bind(null), "prototype", { + get() { + throw new Test262Error(); + } +}); + +assert.throws(RangeError, function() { + let byteLength = 10; + let options = { + maxByteLength: 0, + }; + + // Throws a RangeError, because `byteLength` is larger than `options.maxByteLength`. + Reflect.construct(SharedArrayBuffer, [byteLength, options], newTarget); +}); + +reportCompare(0, 0); -- cgit v1.2.3