tor-browser

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

value-via-reflect-construct.js (766B)


      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-reflect.construct
      5 es6id: 26.1.2
      6 description: Value when invoked via `Reflect.construct`
      7 info: |
      8  [...]
      9  2. If newTarget is not present, let newTarget be target.
     10  [...]
     11  5. Return ? Construct(target, args, newTarget).
     12 features: [new.target, Reflect, Reflect.construct]
     13 ---*/
     14 
     15 var customNewTarget = function() {};
     16 var newTarget = null;
     17 
     18 function f() {
     19  newTarget = new.target;
     20 }
     21 
     22 Reflect.construct(f, []);
     23 
     24 assert.sameValue(newTarget, f, 'NewTarget unspecified');
     25 
     26 Reflect.construct(f, [], customNewTarget);
     27 
     28 assert.sameValue(newTarget, customNewTarget, 'NewTarget explicitly defined');
     29 
     30 reportCompare(0, 0);