Debian Codegraph @

js/src/tests/test262/built-ins/ArrayBuffer/options-maxbytelength-excessive.js

raw
1 // Copyright (C) 2021 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-arraybuffer-constructor
5 description: |
6 Invoked with an options object whose `maxByteLength` property exceeds the
7 maximum length value
8 info: |
9 ArrayBuffer( length [ , options ] )
10
11 1. If NewTarget is undefined, throw a TypeError exception.
12 2. Let byteLength be ? ToIndex(length).
13 3. Let requestedMaxByteLength be ? GetArrayBufferMaxByteLengthOption(options).
14 [...]
15
16 1.1.5 GetArrayBufferMaxByteLengthOption ( options )
17
18 1. If Type(options) is not Object, return empty.
19 2. Let maxByteLength be ? Get(options, "maxByteLength").
20 3. If maxByteLength is undefined, return empty.
21 4. Return ? ToIndex(maxByteLength).
22 features: [resizable-arraybuffer]
23 ---*/
24
25 assert.throws(RangeError, function() {
26 // Math.pow(2, 53) = 9007199254740992
27 new ArrayBuffer(0, { maxByteLength: 9007199254740992 });
28 });
29
30 reportCompare(0, 0);