Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/DataView/custom-proto-if-object-is-used-sab.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // Copyright (C) 2017 Mozilla Corporation. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 es6id: 24.2.2.1
7 esid: sec-dataview-buffer-byteoffset-bytelength
8 description: >
9 Use newTarget's custom constructor prototype if Object
10 info: |
11 24.2.2.1 DataView (buffer, byteOffset, byteLength )
12
13 ...
14 12. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%DataViewPrototype%",
15 « [[DataView]], [[ViewedArrayBuffer]], [[ByteLength]], [[ByteOffset]] »).
16 ...
17 17. Return O.
18
19 9.1.13 OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ ,
20 internalSlotsList ] )
21
22 ...
23 2. Let proto be ? GetPrototypeFromConstructor(constructor,
24 intrinsicDefaultProto).
25 3. Return ObjectCreate(proto, internalSlotsList).
26
27 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
28
29 ...
30 3. Let proto be ? Get(constructor, "prototype").
31 4. If Type(proto) is not Object, then
32 a. Let realm be ? GetFunctionRealm(constructor).
33 b. Let proto be realm's intrinsic object named intrinsicDefaultProto.
34 5. Return proto.
35 ...
36 features: [Reflect.construct, SharedArrayBuffer]
37 ---*/
38
39 var buffer = new SharedArrayBuffer(8);
40
41 function newTarget() {}
42 var proto = {};
43 newTarget.prototype = proto;
44
45 var sample = Reflect.construct(DataView, [buffer, 0], newTarget);
46
47 assert.sameValue(sample.constructor, Object);
48 assert.sameValue(Object.getPrototypeOf(sample), proto);