tor-browser

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

call-parameters.js (1350B)


      1 // Copyright (C) 2015 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    trap is called with handler object as its context, and parameters are:
      7    target, an array list with the called arguments and the new target, and the
      8    constructor new.target.
      9 info: |
     10    [[Construct]] ( argumentsList, newTarget)
     11 
     12    9. Let newObj be Call(trap, handler, «target, argArray, newTarget »).
     13 features: [Proxy]
     14 ---*/
     15 
     16 var _target, _handler, _args, _P;
     17 
     18 function Target() {}
     19 
     20 var handler = {
     21  construct: function(t, args, newTarget) {
     22    _handler = this;
     23    _target = t;
     24    _args = args;
     25    _P = newTarget;
     26 
     27    return new t(args[0], args[1]);
     28  }
     29 };
     30 var P = new Proxy(Target, handler);
     31 
     32 new P(1, 2);
     33 
     34 assert.sameValue(_handler, handler, "trap context is the handler object");
     35 assert.sameValue(_target, Target, "first parameter is the target object");
     36 assert.sameValue(_args.length, 2, "arguments list contains all call arguments");
     37 assert.sameValue(_args[0], 1, "arguments list has first call argument");
     38 assert.sameValue(_args[1], 2, "arguments list has second call argument");
     39 assert.sameValue(_P, P, "constructor is sent as the third parameter");
     40 
     41 reportCompare(0, 0);