strings-and-symbol-order-proxy.js (1237B)
1 // Copyright (C) 2020 Alexey Shvayka. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-object.assign 5 description: > 6 Proxy keys are iterated in order they were provided by "ownKeys" trap. 7 info: | 8 Object.assign ( target, ...sources ) 9 10 [...] 11 4. For each element nextSource of sources, in ascending index order, do 12 a. If nextSource is neither undefined nor null, then 13 [...] 14 ii. Let keys be ? from.[[OwnPropertyKeys]](). 15 iii. For each element nextKey of keys in List order, do 16 1. Let desc be ? from.[[GetOwnProperty]](nextKey). 17 18 [[OwnPropertyKeys]] ( ) 19 20 [...] 21 7. Let trapResultArray be ? Call(trap, handler, « target »). 22 8. Let trapResult be ? CreateListFromArrayLike(trapResultArray, « String, Symbol »). 23 [...] 24 23. Return trapResult. 25 features: [Proxy, Symbol] 26 includes: [compareArray.js] 27 ---*/ 28 29 var getOwnKeys = []; 30 var ownKeysResult = [Symbol(), "foo", "0"]; 31 var proxy = new Proxy({}, { 32 getOwnPropertyDescriptor: function(_target, key) { 33 getOwnKeys.push(key); 34 }, 35 ownKeys: function() { 36 return ownKeysResult; 37 }, 38 }); 39 40 Object.assign({}, proxy); 41 assert.compareArray(getOwnKeys, ownKeysResult); 42 43 reportCompare(0, 0);