tor-browser

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

trap-is-undefined-proto-from-newtarget-realm.js (1795B)


      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 esid: sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget
      5 description: >
      6  If trap is undefined, propagate [[Construct]] to target,
      7  passing correct newTarget parameter
      8 info: |
      9  [[Construct]] ( argumentsList, newTarget )
     10 
     11  [...]
     12  7. If trap is undefined, then
     13    b. Return ? Construct(target, argumentsList, newTarget).
     14 
     15  Construct ( F [ , argumentsList [ , newTarget ] ] )
     16 
     17  [...]
     18  5. Return ? F.[[Construct]](argumentsList, newTarget).
     19 
     20  [[Construct]] ( argumentsList, newTarget )
     21 
     22  [...]
     23  5. If kind is "base", then
     24    a. Let thisArgument be ? OrdinaryCreateFromConstructor(newTarget, "%ObjectPrototype%").
     25 
     26  OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
     27 
     28  [...]
     29  2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
     30  3. Return ObjectCreate(proto, internalSlotsList).
     31 
     32  GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
     33 
     34  [...]
     35  3. Let proto be ? Get(constructor, "prototype").
     36  4. If Type(proto) is not Object, then
     37    a. Let realm be ? GetFunctionRealm(constructor).
     38    b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
     39  5. Return proto.
     40 
     41  GetFunctionRealm ( obj )
     42 
     43  [...]
     44  2. If obj has a [[Realm]] internal slot, then
     45    a. Return obj.[[Realm]].
     46 features: [cross-realm, Proxy, Reflect, Reflect.construct]
     47 ---*/
     48 
     49 var other = $262.createRealm().global;
     50 var C = new other.Function();
     51 C.prototype = null;
     52 
     53 var P = new Proxy(function() {}, {});
     54 var p = Reflect.construct(P, [], C);
     55 
     56 assert.sameValue(Object.getPrototypeOf(p), other.Object.prototype);
     57 
     58 reportCompare(0, 0);