tor-browser

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

proxy-invariant-duplicate-symbol-entry.js (955B)


      1 // Copyright (C) 2019 Alexey Shvayka. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-object.getownpropertynames
      6 description: >
      7  Proxy [[OwnPropertyKeys]] trap does not skip symbol keys when validating invariant:
      8  * The returned List contains no duplicate entries.
      9 info: |
     10  Object.getOwnPropertyNames ( O )
     11 
     12  1. Return ? GetOwnPropertyKeys(O, String).
     13 
     14  GetOwnPropertyKeys ( O, type )
     15 
     16  ...
     17  2. Let keys be ? obj.[[OwnPropertyKeys]]().
     18 
     19  [[OwnPropertyKeys]] ( )
     20 
     21  ...
     22  8. Let trapResult be ? CreateListFromArrayLike(trapResultArray, « String, Symbol »).
     23  9. If trapResult contains any duplicate entries, throw a TypeError exception.
     24 features: [Proxy, Symbol]
     25 ---*/
     26 
     27 var symbol = Symbol();
     28 var proxy = new Proxy({}, {
     29  ownKeys: function() {
     30    return [symbol, symbol];
     31  },
     32 });
     33 
     34 assert.throws(TypeError, function() {
     35  Object.getOwnPropertyNames(proxy);
     36 });
     37 
     38 reportCompare(0, 0);