tor-browser

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

proxy-invariant-not-extensible-absent-string-key.js (1467B)


      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  * If the target object is not extensible, then the result List must contain all the keys of
      9    the own properties of the target object and no other values.
     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  16. For each element key of targetKeys, do
     25    a. Let desc be ? target.[[GetOwnProperty]](key).
     26    b. If desc is not undefined and desc.[[Configurable]] is false, then
     27      ...
     28    c. Else,
     29      i. Append key as an element of targetConfigurableKeys.
     30  ...
     31  18. Let uncheckedResultKeys be a new List which is a copy of trapResult.
     32  ...
     33  21. For each key that is an element of targetConfigurableKeys, do
     34    a. If key is not an element of uncheckedResultKeys, throw a TypeError exception.
     35 features: [Proxy]
     36 ---*/
     37 
     38 var target = {prop: 2};
     39 var proxy = new Proxy(target, {
     40  ownKeys: function() {
     41    return [];
     42  },
     43 });
     44 
     45 Object.preventExtensions(target);
     46 
     47 assert.throws(TypeError, function() {
     48  Object.getOwnPropertySymbols(proxy);
     49 });
     50 
     51 reportCompare(0, 0);