proto-from-ctor-realm-sab.js (1275B)
1 // |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally 2 // Copyright (C) 2016 the V8 project authors. 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 esid: sec-dataview-buffer-byteoffset-bytelength 7 description: Default [[Prototype]] value derived from realm of the newTarget 8 info: | 9 [...] 10 12. Let O be ? OrdinaryCreateFromConstructor(NewTarget, 11 "%DataViewPrototype%", « [[DataView]], [[ViewedArrayBuffer]], 12 [[ByteLength]], [[ByteOffset]] »). 13 [...] 14 15 9.1.14 GetPrototypeFromConstructor 16 17 [...] 18 3. Let proto be ? Get(constructor, "prototype"). 19 4. If Type(proto) is not Object, then 20 a. Let realm be ? GetFunctionRealm(constructor). 21 b. Let proto be realm's intrinsic object named intrinsicDefaultProto. 22 [...] 23 features: [cross-realm, Reflect, SharedArrayBuffer] 24 ---*/ 25 26 var other = $262.createRealm().global; 27 var C = new other.Function(); 28 C.prototype = null; 29 var buffer = new SharedArrayBuffer(0); 30 31 var o = Reflect.construct(DataView, [buffer, 0], C); 32 33 assert.sameValue(Object.getPrototypeOf(o), other.DataView.prototype); 34 35 reportCompare(0, 0);