test262/test/built-ins/Proxy/apply/trap-is-undefined-no-proper...

38 lines
943 B
JavaScript
Raw Normal View History

2015-06-03 01:16:34 +02:00
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
2017-09-06 21:52:05 +02:00
2015-06-03 01:16:34 +02:00
/*---
es6id: 9.5.13
2017-06-27 01:33:35 +02:00
esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist
2015-06-03 01:16:34 +02:00
description: >
2017-09-06 21:52:05 +02:00
If trap is not set, propagate the call to the target object.
2015-06-03 01:16:34 +02:00
info: >
[[Call]] (thisArgument, argumentsList)
2017-09-06 21:52:05 +02:00
...
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.
...
2015-06-03 01:16:34 +02:00
---*/
2017-09-06 21:52:05 +02:00
var calls = 0;
2017-06-27 01:33:35 +02:00
function target(a, b) {
assert.sameValue(this, ctx);
2017-09-06 21:52:05 +02:00
calls += 1;
2015-06-03 01:16:34 +02:00
return a + b;
2017-06-27 01:33:35 +02:00
}
2015-06-03 01:16:34 +02:00
2017-06-27 01:33:35 +02:00
var ctx = {};
var p = new Proxy(target, {});
var res = p.call(ctx, 1, 2);
assert.sameValue(res, 3, "`apply` trap is missing");
2017-09-06 21:52:05 +02:00
assert.sameValue(calls, 1, "target is called once");