Debian Codegraph @

js/src/tests/test262/built-ins/DataView/custom-proto-if-object-is-used.js

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