Debian Codegraph @

js/src/tests/test262/built-ins/Proxy/ownKeys/trap-is-undefined-target-is-proxy.js

raw
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 /*---
5 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
6 description: >
7 If "ownKeys" trap is null or undefined, [[OwnPropertyKeys]] call is
8 properly forwarded to [[ProxyTarget]] (which is also a Proxy object).
9 info: |
10 [[OwnPropertyKeys]] ( )
11
12 [...]
13 4. Let target be O.[[ProxyTarget]].
14 5. Let trap be ? GetMethod(handler, "ownKeys").
15 6. If trap is undefined, then
16 a. Return ? target.[[OwnPropertyKeys]]().
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 includes: [compareArray.js]
26 features: [Symbol, Proxy, Reflect]
27 ---*/
28
29 var trapResult = [Symbol(), "length", "foo", "0"];
30 var target = new Proxy([], {
31 ownKeys: function(_target) {
32 return trapResult;
33 },
34 });
35
36 var proxy = new Proxy(target, {
37 ownKeys: undefined,
38 });
39
40 assert.compareArray(Reflect.ownKeys(proxy), trapResult);
41
42 reportCompare(0, 0);