summaryrefslogtreecommitdiff
path: root/test/built-ins/Proxy/apply/trap-is-undefined-no-property.js
blob: 9cb26e3652d7c0659bbc770043c69b792bf42157 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
es6id: 9.5.13
esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist
description: >
    If trap is not set, propagate the call to the target object.
info: |
    [[Call]] (thisArgument, argumentsList)

    ...
    5. Let trap be ? GetMethod(handler, "apply").
    6. If trap is undefined, then
      a. Return ? Call(target, thisArgument, argumentsList).
    ...

    GetMethod ( V, P )

    ...
    3. If func is either undefined or null, return undefined.
    ...
---*/

var calls = 0;

function target(a, b) {
    assert.sameValue(this, ctx);
    calls += 1;
    return a + b;
}

var ctx = {};
var p = new Proxy(target, {});
var res = p.call(ctx, 1, 2);
assert.sameValue(res, 3, "`apply` trap is missing");
assert.sameValue(calls, 1, "target is called once");