1 // |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
2 // Copyright (C) 2024 André Bargull. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
6 esid: sec-sharedarraybuffer-length
8 The new SharedArrayBuffer instance is created prior to allocating the Data Block.
10 SharedArrayBuffer ( length [ , options ] )
13 4. Return ? AllocateSharedArrayBuffer(NewTarget, byteLength, requestedMaxByteLength).
15 AllocateSharedArrayBuffer( constructor, byteLength )
18 5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%SharedArrayBuffer.prototype%", slots).
20 7. Let block be ? CreateSharedByteDataBlock(allocLength).
23 features: [SharedArrayBuffer, resizable-arraybuffer, Reflect.construct]
26 function DummyError() {}
28 let newTarget = Object.defineProperty(function(){}.bind(null), "prototype", {
30 throw new DummyError();
34 assert.throws(DummyError, function() {
37 maxByteLength: 7 * 1125899906842624
40 // Allocating 7 PiB should fail with a RangeError.
41 // Math.pow(1024, 5) = 1125899906842624
42 Reflect.construct(SharedArrayBuffer, [], newTarget);