tor-browser

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

trap-is-missing-target-is-proxy.js (905B)


      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, Reflect]
     18 ---*/
     19 
     20 var hasOwn = Object.prototype.hasOwnProperty;
     21 var hasOwnTarget = new Proxy(hasOwn, {});
     22 var hasOwnProxy = new Proxy(hasOwnTarget, {});
     23 
     24 var obj = {foo: 1};
     25 assert(hasOwnProxy.call(obj, "foo"));
     26 assert(!Reflect.apply(hasOwnProxy, obj, ["bar"]));
     27 
     28 reportCompare(0, 0);