proxy-non-enumerable-prop-invariant-3.js (1494B)
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.keys 6 description: > 7 Proxy [[OwnPropertyKeys]] trap does not skip non-enumerable 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.keys ( O ) 12 13 ... 14 2. Let nameList be ? EnumerableOwnPropertyNames(obj, "key"). 15 16 EnumerableOwnPropertyNames ( O, kind ) 17 18 ... 19 2. Let ownKeys be ? O.[[OwnPropertyKeys]](). 20 21 [[OwnPropertyKeys]] ( ) 22 23 ... 24 11. Let targetKeys be ? target.[[OwnPropertyKeys]](). 25 16. For each element key of targetKeys, do 26 a. Let desc be ? target.[[GetOwnProperty]](key). 27 b. If desc is not undefined and desc.[[Configurable]] is false, then 28 ... 29 c. Else, 30 i. Append key as an element of targetConfigurableKeys. 31 ... 32 18. Let uncheckedResultKeys be a new List which is a copy of trapResult. 33 ... 34 22. If uncheckedResultKeys is not empty, throw a TypeError exception. 35 features: [Proxy] 36 ---*/ 37 38 var target = {}; 39 Object.defineProperty(target, 'prop', { 40 value: 3, 41 writable: true, 42 enumerable: false, 43 configurable: true, 44 }); 45 46 var proxy = new Proxy(target, { 47 ownKeys: function() { 48 return ['prop']; 49 }, 50 }); 51 52 Object.preventExtensions(target); 53 54 var keys = Object.keys(proxy); 55 assert.sameValue(keys.length, 0); 56 57 reportCompare(0, 0);