Debian Codegraph @

js/src/tests/test262/built-ins/SharedArrayBuffer/data-allocation-after-object-creation.js

raw
1 // |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally
2 // Copyright (C) 2015 André Bargull. All rights reserved.
3 // Copyright (C) 2017 Mozilla Corporation. All rights reserved.
4 // This code is governed by the BSD license found in the LICENSE file.
5
6 /*---
7 esid: sec-sharedarraybuffer-length
8 description: >
9 The new SharedArrayBuffer instance is created prior to allocating the Data Block.
10 info: |
11 SharedArrayBuffer( length )
12
13 ...
14 3. Return AllocateSharedArrayBuffer(NewTarget, byteLength).
15
16 AllocateSharedArrayBuffer( constructor, byteLength )
17 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%SharedArrayBufferPrototype%",
18 «[[ArrayBufferData]], [[ArrayBufferByteLength]]» ).
19 ...
20 3. Let block be ? CreateByteDataBlock(byteLength).
21 ...
22 features: [SharedArrayBuffer, Reflect.construct]
23 ---*/
24
25 function DummyError() {}
26
27 var newTarget = function() {}.bind(null);
28 Object.defineProperty(newTarget, "prototype", {
29 get: function() {
30 throw new DummyError();
31 }
32 });
33
34 assert.throws(DummyError, function() {
35 // Allocating 7 PiB should fail with a RangeError.
36 // Math.pow(1024, 5) = 1125899906842624
37 Reflect.construct(SharedArrayBuffer, [7 * 1125899906842624], newTarget);
38 });
39
40 reportCompare(0, 0);