Debian Codegraph @

js/src/tests/test262/built-ins/Proxy/apply/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-call-thisargument-argumentslist
6 description: >
7 If "apply" trap is null or undefined, [[Call]] is properly
8 forwarded to [[ProxyTarget]] (which is also a Proxy object).
9 info: |
10 [[Call]] ( thisArgument, argumentsList )
11
12 [...]
13 4. Let target be O.[[ProxyTarget]].
14 5. Let trap be ? GetMethod(handler, "apply").
15 6. If trap is undefined, then
16 a. Return ? Call(target, thisArgument, argumentsList).
17 features: [generators, Proxy, Reflect]
18 includes: [compareArray.js]
19 ---*/
20
21 var sum = function* (arg) {
22 yield this.foo;
23 yield arg;
24 };
25
26 var sumTarget = new Proxy(sum, {});
27 var sumProxy = new Proxy(sumTarget, {
28 apply: undefined,
29 });
30
31 var gen = Reflect.apply(sumProxy, {foo: 10}, [1]);
32
33 assert.compareArray(Array.from(gen), [10, 1]);
34
35 reportCompare(0, 0);