tor-browser

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

proxy-invariant-duplicate-string-entry.js (924B)


      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.getownpropertysymbols
      6 description: >
      7  Proxy [[OwnPropertyKeys]] trap does not skip string keys when validating invariant:
      8  * The returned List contains no duplicate entries.
      9 info: |
     10  Object.getOwnPropertySymbols ( O )
     11 
     12  1. Return ? GetOwnPropertyKeys(O, Symbol).
     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]
     25 ---*/
     26 
     27 var proxy = new Proxy({}, {
     28  ownKeys: function() {
     29    return ['a', 'a'];
     30  },
     31 });
     32 
     33 assert.throws(TypeError, function() {
     34  Object.getOwnPropertySymbols(proxy);
     35 });
     36 
     37 reportCompare(0, 0);