Debian Codegraph @

js/src/tests/test262/built-ins/SharedArrayBuffer/options-maxbytelength-negative.js

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