object-spread-proxy-no-excluded-keys.js (1401B)
1 // Copyright (C) 2021 Alexey Shvayka. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-object-initializer-runtime-semantics-propertydefinitionevaluation 5 description: > 6 Proxy's "getOwnPropertyDescriptor" trap is invoked for all keys. 7 info: | 8 PropertyDefinition : ... AssignmentExpression 9 10 [...] 11 3. Let excludedNames be a new empty List. 12 4. Return ? CopyDataProperties(object, fromValue, excludedNames). 13 14 CopyDataProperties ( target, source, excludedItems ) 15 16 [...] 17 5. Let keys be ? from.[[OwnPropertyKeys]](). 18 6. For each element nextKey of keys in List order, do 19 [...] 20 c. If excluded is false, then 21 i. Let desc be ? from.[[GetOwnProperty]](nextKey). 22 23 [[OwnPropertyKeys]] ( ) 24 25 [...] 26 7. Let trapResultArray be ? Call(trap, handler, « target »). 27 8. Let trapResult be ? CreateListFromArrayLike(trapResultArray, « String, Symbol »). 28 [...] 29 23. Return trapResult. 30 features: [object-spread, Proxy, Symbol] 31 includes: [compareArray.js] 32 ---*/ 33 34 var sym = Symbol(); 35 var getOwnKeys = []; 36 var ownKeysResult = [sym, "foo", "0"]; 37 var proxy = new Proxy({}, { 38 getOwnPropertyDescriptor: function(_target, key) { 39 getOwnKeys.push(key); 40 }, 41 ownKeys: function() { 42 return ownKeysResult; 43 }, 44 }); 45 46 ({[sym]: 0, foo: 0, [0]: 0, ...proxy}); 47 assert.compareArray(getOwnKeys, ownKeysResult); 48 49 reportCompare(0, 0);