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