Debian Codegraph @

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

raw
1 // Copyright (C) 2015 André Bargull. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-arraybuffer-length
6 description: >
7 The new ArrayBuffer instance is created prior to allocating the Data Block.
8 info: |
9 ArrayBuffer( length )
10
11 ...
12 6. Return AllocateArrayBuffer(NewTarget, byteLength).
13
14 AllocateArrayBuffer( constructor, byteLength )
15 1. Let obj be OrdinaryCreateFromConstructor(constructor, "%ArrayBufferPrototype%",
16 «[[ArrayBufferData]], [[ArrayBufferByteLength]]» ).
17 2. ReturnIfAbrupt(obj).
18 ...
19 4. Let block be CreateByteDataBlock(byteLength).
20 5. ReturnIfAbrupt(block).
21 ...
22 features: [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(ArrayBuffer, [7 * 1125899906842624], newTarget);
38 });
39
40 reportCompare(0, 0);