Debian Codegraph @

js/src/tests/test262/built-ins/Proxy/apply/call-parameters.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 esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist
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 features: [Proxy]
13 ---*/
14
15 var _target, _args, _handler, _context;
16 var target = function() {
17 throw new Test262Error('target should not be called');
18 };
19 var handler = {
20 apply: function(t, c, args) {
21 _handler = this;
22 _target = t;
23 _context = c;
24 _args = args;
25 }
26 };
27 var p = new Proxy(target, handler);
28
29 var context = {};
30
31 p.call(context, 1, 2);
32
33 assert.sameValue(_handler, handler, "trap context is the handler object");
34 assert.sameValue(_target, target, "first parameter is the target object");
35 assert.sameValue(_context, context, "second parameter is the call context");
36 assert.sameValue(_args.length, 2, "arguments list contains all call arguments");
37 assert.sameValue(_args[0], 1, "arguments list has first call argument");
38 assert.sameValue(_args[1], 2, "arguments list has second call argument");
39
40 reportCompare(0, 0);