tor-browser

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

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


      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-function-p1-p2-pn-body
      5 description: Default [[Prototype]] value derived from realm of the newTarget
      6 info: |
      7    [...]
      8    5. Return ? CreateDynamicFunction(C, NewTarget, "normal", args).
      9 
     10    19.2.1.1.1 Runtime Semantics: CreateDynamicFunction
     11 
     12    [...]
     13    2. If kind is "normal", then
     14       [...]
     15       c. Let fallbackProto be "%FunctionPrototype%".
     16    [...]
     17    22. Let proto be ? GetPrototypeFromConstructor(newTarget, fallbackProto).
     18    [...]
     19 
     20    9.1.14 GetPrototypeFromConstructor
     21 
     22    [...]
     23    3. Let proto be ? Get(constructor, "prototype").
     24    4. If Type(proto) is not Object, then
     25       a. Let realm be ? GetFunctionRealm(constructor).
     26       b. Let proto be realm's intrinsic object named intrinsicDefaultProto.
     27    [...]
     28 features: [cross-realm, Reflect]
     29 ---*/
     30 
     31 var other = $262.createRealm().global;
     32 var C = new other.Function();
     33 C.prototype = null;
     34 
     35 var o = Reflect.construct(Function, [], C);
     36 
     37 assert.sameValue(Object.getPrototypeOf(o), other.Function.prototype);
     38 
     39 reportCompare(0, 0);