tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

proto-from-ctor-realm.js (1114B)


      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 /*---
      7 esid: sec-sharedarraybuffer-length
      8 description: Default [[Prototype]] value derived from realm of the newTarget
      9 info: |
     10    [...]
     11    3. Return ? AllocateSharedArrayBuffer(NewTarget, byteLength).
     12 
     13    9.1.14 GetPrototypeFromConstructor
     14 
     15    [...]
     16    3. Let proto be ? Get(constructor, "prototype").
     17    4. If Type(proto) is not Object, then
     18       a. Let realm be ? GetFunctionRealm(constructor).
     19       b. Let proto be realm's intrinsic object named intrinsicDefaultProto.
     20    [...]
     21 features: [SharedArrayBuffer, cross-realm, Reflect]
     22 ---*/
     23 
     24 var other = $262.createRealm().global;
     25 var C = new other.Function();
     26 C.prototype = null;
     27 
     28 var o = Reflect.construct(SharedArrayBuffer, [], C);
     29 
     30 assert.sameValue(Object.getPrototypeOf(o), other.SharedArrayBuffer.prototype);
     31 
     32 reportCompare(0, 0);