tor-browser

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

trap-is-undefined.js (1236B)


      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 /*---
      5 esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist
      6 description: >
      7    If the apply trap value is undefined, propagate the call to the target object.
      8 info: |
      9    [[Call]] (thisArgument, argumentsList)
     10 
     11    ...
     12    5. Let trap be ? GetMethod(handler, "apply").
     13    6. If trap is undefined, then
     14      a. Return ? Call(target, thisArgument, argumentsList).
     15    ...
     16 
     17    GetMethod ( V, P )
     18 
     19    ...
     20    3. If func is either undefined or null, return undefined.
     21    ...
     22 features: [Proxy]
     23 ---*/
     24 
     25 var calls = 0;
     26 var _context;
     27 
     28 var target = new Proxy(function() {}, {
     29  apply: function(_target, context, args) {
     30    calls++;
     31    _context = context;
     32    return args[0] + args[1];
     33  }
     34 })
     35 
     36 var p = new Proxy(target, {
     37  apply: undefined
     38 });
     39 
     40 var context = {};
     41 var res = p.call(context, 1, 2);
     42 
     43 assert.sameValue(calls, 1, "apply is undefined: [[Call]] is invoked once");
     44 assert.sameValue(_context, context, "apply is undefined: context is passed to [[Call]]");
     45 assert.sameValue(res, 3, "apply is undefined: result of [[Call]] is returned");
     46 
     47 reportCompare(0, 0);