tor-browser

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

trap-is-null-target-is-proxy.js (933B)


      1 // Copyright (C) 2020 Alexey Shvayka. 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 "apply" trap is null or undefined, [[Call]] is properly
      8  forwarded to [[ProxyTarget]] (which is also a Proxy object).
      9 info: |
     10  [[Call]] ( thisArgument, argumentsList )
     11 
     12  [...]
     13  4. Let target be O.[[ProxyTarget]].
     14  5. Let trap be ? GetMethod(handler, "apply").
     15  6. If trap is undefined, then
     16    a. Return ? Call(target, thisArgument, argumentsList).
     17 features: [Proxy]
     18 ---*/
     19 
     20 var sum = function(a, b) {
     21  return this.foo + a + b;
     22 };
     23 
     24 var sumBound = sum.bind({foo: 10}, 1);
     25 var sumTarget = new Proxy(sumBound, {});
     26 var sumProxy = new Proxy(sumTarget, {
     27  apply: null,
     28 });
     29 
     30 assert.sameValue(sumProxy(2), 13);
     31 assert.sameValue(sumProxy.call({foo: 20}, 3), 14);
     32 
     33 reportCompare(0, 0);