Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Proxy/apply/trap-is-undefined.js

raw
1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 es6id: 9.5.13
6 esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist
7 description: >
8 If the apply trap value is undefined, propagate the call to the target object.
9 info: |
10 [[Call]] (thisArgument, argumentsList)
11
12 ...
13 5. Let trap be ? GetMethod(handler, "apply").
14 6. If trap is undefined, then
15 a. Return ? Call(target, thisArgument, argumentsList).
16 ...
17
18 GetMethod ( V, P )
19
20 ...
21 3. If func is either undefined or null, return undefined.
22 ...
23 ---*/
24
25 var calls = 0;
26
27 function target(a, b) {
28 assert.sameValue(this, ctx);
29 calls += 1;
30 return a + b;
31 }
32
33 var ctx = {};
34 var p = new Proxy(target, {
35 apply: undefined
36 });
37 var res = p.call(ctx, 1, 2);
38 assert.sameValue(res, 3, "`apply` trap is `null`");
39 assert.sameValue(calls, 1, "target is called once");