| 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 |
es6id: 9.5.13 |
| 5 |
description: > |
| 6 |
trap is called with handler object as its context, and parameters are: |
| 7 |
target, the call context and and an array list with the called arguments |
| 8 |
info: | |
| 9 |
[[Call]] (thisArgument, argumentsList) |
| 10 |
|
| 11 |
9. Return Call(trap, handler, «target, thisArgument, argArray»). |
| 12 |
---*/ |
| 13 |
|
| 14 |
var _target, _args, _handler, _context; |
| 15 |
var target = function(a, b) { |
| 16 |
return a + b; |
| 17 |
}; |
| 18 |
var handler = { |
| 19 |
apply: function(t, c, args) { |
| 20 |
_handler = this; |
| 21 |
_target = t; |
| 22 |
_context = c; |
| 23 |
_args = args; |
| 24 |
} |
| 25 |
}; |
| 26 |
var p = new Proxy(target, handler); |
| 27 |
|
| 28 |
var context = {}; |
| 29 |
|
| 30 |
p.call(context, 1, 2); |
| 31 |
|
| 32 |
assert.sameValue(_handler, handler, "trap context is the handler object"); |
| 33 |
assert.sameValue(_target, target, "first parameter is the target object"); |
| 34 |
assert.sameValue(_context, context, "second parameter is the call context"); |
| 35 |
assert.sameValue(_args.length, 2, "arguments list contains all call arguments"); |
| 36 |
assert.sameValue(_args[0], 1, "arguments list has first call argument"); |
| 37 |
assert.sameValue(_args[1], 2, "arguments list has second call argument"); |