proxy-invariant-not-extensible-extra-symbol-key.js (1410B)
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 22. If uncheckedResultKeys is not empty, throw a TypeError exception. 34 features: [Proxy, Symbol] 35 ---*/ 36 37 var target = {}; 38 var symbol = Symbol(); 39 var proxy = new Proxy(target, { 40 ownKeys: function() { 41 return [symbol]; 42 }, 43 }); 44 45 Object.preventExtensions(target); 46 47 assert.throws(TypeError, function() { 48 Object.getOwnPropertyNames(proxy); 49 }); 50 51 reportCompare(0, 0);