tor-browser

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

call-construct-invocation.js (1054B)


      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-super-keyword
      5 es6id: 12.3.5
      6 description: Invocation of "parent" constructor
      7 info: |
      8  [...]
      9  6. Let result be ? Construct(func, argList, newTarget).
     10  [...]
     11 features: [class, new.target, Reflect, Reflect.construct]
     12 ---*/
     13 
     14 var expectedNewTarget = function() {};
     15 var thisValue, instance, args, actualNewTarget;
     16 function Parent() {
     17  thisValue = this;
     18  args = arguments;
     19  actualNewTarget = new.target;
     20 }
     21 
     22 class Child extends Parent {
     23  constructor() {
     24    super(1, 2, 3);
     25  }
     26 }
     27 
     28 instance = Reflect.construct(Child, [4, 5, 6], expectedNewTarget);
     29 
     30 assert.sameValue(thisValue, instance);
     31 assert.sameValue(args.length, 3, 'length of provided arguments object');
     32 assert.sameValue(args[0], 1, 'first argument');
     33 assert.sameValue(args[1], 2, 'second argument');
     34 assert.sameValue(args[2], 3, 'third argument');
     35 assert.sameValue(actualNewTarget, expectedNewTarget, 'new.target value');
     36 
     37 reportCompare(0, 0);