tor-browser

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

trap-is-undefined-target-is-proxy.js (1300B)


      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-getownproperty-p
      6 description: >
      7  If "getOwnPropertyDescriptor" trap is null or undefined, [[GetOwnProperty]]
      8  call is properly forwarded to [[ProxyTarget]] (which is also a Proxy object).
      9 info: |
     10  [[GetOwnProperty]] ( P )
     11 
     12  [...]
     13  5. Let target be O.[[ProxyTarget]].
     14  6. Let trap be ? GetMethod(handler, "getOwnPropertyDescriptor").
     15  7. If trap is undefined, then
     16    a. Return ? target.[[GetOwnProperty]](P).
     17 includes: [propertyHelper.js]
     18 features: [Proxy]
     19 ---*/
     20 
     21 var arrayTarget = new Proxy([42], {});
     22 var arrayProxy = new Proxy(arrayTarget, {
     23  getOwnPropertyDescriptor: undefined,
     24 });
     25 
     26 verifyProperty(arrayProxy, "0", {
     27  value: 42,
     28  writable: true,
     29  enumerable: true,
     30  configurable: true,
     31 });
     32 
     33 verifyProperty(arrayProxy, "length", {
     34  value: 1,
     35  // writable: true,
     36  enumerable: false,
     37  configurable: false,
     38 });
     39 
     40 
     41 var regExpTarget = new Proxy(/(?:)/, {});
     42 var regExpProxy = new Proxy(regExpTarget, {
     43  getOwnPropertyDescriptor: undefined,
     44 });
     45 
     46 verifyProperty(regExpProxy, "lastIndex", {
     47  value: 0,
     48  writable: true,
     49  enumerable: false,
     50  configurable: false,
     51 });
     52 
     53 reportCompare(0, 0);