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