proxy-invariant-absent-not-configurable-symbol-key.js (1556B)
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 * The result List must contain the keys of all non-configurable own properties of 9 the target object. 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 ... 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, Symbol] 35 ---*/ 36 37 var target = {}; 38 var symbol = Symbol(); 39 Object.defineProperty(target, symbol, { 40 value: 1, 41 writable: true, 42 enumerable: true, 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.getOwnPropertyNames(proxy); 54 }); 55 56 reportCompare(0, 0);