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 (1518B)


      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-ownpropertykeys
      6 description: >
      7  If "ownKeys" trap is null or undefined, [[OwnPropertyKeys]] call is
      8  properly forwarded to [[ProxyTarget]] (which is also a Proxy object).
      9 info: |
     10  [[OwnPropertyKeys]] ( )
     11 
     12  [...]
     13  4. Let target be O.[[ProxyTarget]].
     14  5. Let trap be ? GetMethod(handler, "ownKeys").
     15  6. If trap is undefined, then
     16    a. Return ? target.[[OwnPropertyKeys]]().
     17 
     18  [[OwnPropertyKeys]] ( )
     19 
     20  1. Let keys be a new empty List.
     21  [...]
     22  5. For each integer i starting with 0 such that i < len, in ascending order, do
     23    a. Add ! ToString(i) as the last element of keys.
     24  [...]
     25  7. For each own property key P of O such that Type(P) is String and P is not an
     26  array index, in ascending chronological order of property creation, do
     27    a. Add P as the last element of keys.
     28  8. For each own property key P of O such that Type(P) is Symbol, in ascending
     29  chronological order of property creation, do
     30    a. Add P as the last element of keys.
     31  9. Return keys.
     32 includes: [compareArray.js]
     33 features: [Symbol, Proxy, Reflect]
     34 ---*/
     35 
     36 var sym = Symbol();
     37 var string = new String("str");
     38 string[sym] = 1;
     39 
     40 var stringTarget = new Proxy(string, {});
     41 var stringProxy = new Proxy(stringTarget, {});
     42 
     43 assert.compareArray(
     44  Reflect.ownKeys(stringProxy),
     45  ["0", "1", "2", "length", sym]
     46 );
     47 
     48 reportCompare(0, 0);