1 // |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- 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-arraybuffer-length
8 Throws a RangeError if the requested Data Block is too large.
10 ArrayBuffer ( length [ , options ] )
13 4. Return ? AllocateArrayBuffer(NewTarget, byteLength, requestedMaxByteLength).
15 AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] )
18 5. Let block be ? CreateByteDataBlock(byteLength).
21 CreateByteDataBlock ( size )
24 2. Let db be a new Data Block value consisting of size bytes. If it is
25 impossible to create such a Data Block, throw a RangeError exception.
28 features: [resizable-arraybuffer]
31 assert.throws(RangeError, function() {
32 // Allocating 7 PiB should fail with a RangeError.
33 // Math.pow(1024, 5) = 1125899906842624
34 new ArrayBuffer(0, {maxByteLength: 7 * 1125899906842624});
35 }, "`maxByteLength` option is 7 PiB");
37 assert.throws(RangeError, function() {
38 // Allocating almost 8 PiB should fail with a RangeError.
39 // Math.pow(2, 53) = 9007199254740992
40 new ArrayBuffer(0, {maxByteLength: 9007199254740992 - 1});
41 }, "`maxByteLength` option is Math.pow(2, 53) - 1");