tor-browser

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

proxy-invariant-absent-not-configurable-string-key.js (1531B)


      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 result List must contain the keys of all non-configurable own properties of
      9    the target object.
     10 info: |
     11  Object.getOwnPropertySymbols ( O )
     12 
     13  1. Return ? GetOwnPropertyKeys(O, Symbol).
     14 
     15  GetOwnPropertyKeys ( O, type )
     16 
     17  ...
     18  2. Let keys be ? obj.[[OwnPropertyKeys]]().
     19 
     20  [[OwnPropertyKeys]] ( )
     21 
     22  ...
     23  11. Let targetKeys be ? target.[[OwnPropertyKeys]]().
     24  ...
     25  15. Let targetNonconfigurableKeys be a new empty List.
     26  16. For each element key of targetKeys, do
     27    a. Let desc be ? target.[[GetOwnProperty]](key).
     28    b. If desc is not undefined and desc.[[Configurable]] is false, then
     29      i. Append key as an element of targetNonconfigurableKeys.
     30  ...
     31  18. Let uncheckedResultKeys be a new List which is a copy of trapResult.
     32  19. For each key that is an element of targetNonconfigurableKeys, do
     33    a. If key is not an element of uncheckedResultKeys, throw a TypeError exception.
     34 features: [Proxy]
     35 ---*/
     36 
     37 var target = {};
     38 Object.defineProperty(target, 'prop', {
     39  value: 1,
     40  writable: true,
     41  enumerable: true,
     42  configurable: false,
     43 });
     44 
     45 var proxy = new Proxy(target, {
     46  ownKeys: function() {
     47    return [];
     48  },
     49 });
     50 
     51 assert.throws(TypeError, function() {
     52  Object.getOwnPropertySymbols(proxy);
     53 });
     54 
     55 reportCompare(0, 0);