tor-browser

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

new-target-optional-call.js (797B)


      1 // Copyright 2019 Google, LLC.  All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: prod-OptionalExpression
      5 description: >
      6  optional call invoked on new.target should be equivalent to call
      7 info: |
      8  OptionalExpression
      9    MemberExpression OptionalChain
     10      NewTarget OptionalChain
     11 features: [optional-chaining]
     12 ---*/
     13 
     14 const newTargetContext = (function() { return this; })();
     15 
     16 let called = false;
     17 // should be set to 'undefined' or global context, depending on whether
     18 // mode is strict or sloppy.
     19 let context = null;
     20 function Base() {
     21  called = true;
     22  context = this;
     23 }
     24 function Foo(blerg) {
     25  new.target?.();
     26 }
     27 
     28 Reflect.construct(Foo, [], Base);
     29 assert(context === newTargetContext);
     30 assert.sameValue(called, true);
     31 
     32 reportCompare(0, 0);