proxy-invariant-not-extensible-absent-symbol-key.js (1506B)
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 * 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.getOwnPropertyNames ( O ) 12 13 1. Return ? GetOwnPropertyKeys(O, String). 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, Symbol] 36 ---*/ 37 38 var target = {}; 39 var symbol = Symbol(); 40 target[symbol] = 2; 41 42 var proxy = new Proxy(target, { 43 ownKeys: function() { 44 return []; 45 }, 46 }); 47 48 Object.preventExtensions(target); 49 50 assert.throws(TypeError, function() { 51 Object.getOwnPropertyNames(proxy); 52 }); 53 54 reportCompare(0, 0);