Debian Codegraph @

js/src/tests/test262/built-ins/Proxy/set/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-set-p-v-receiver
5 description: >
6 Proxy "set" trap is called with correct arguments.
7 info: |
8 [[Set]] ( P, V, Receiver )
9
10 ...
11 8. Let booleanTrapResult be ! ToBoolean(? Call(trap, handler, « target, P, V, Receiver »)).
12 ...
13 12. Return true.
14 features: [Proxy]
15 ---*/
16
17 var _target, _handler, _prop, _value, _receiver;
18 var target = {};
19 var handler = {
20 set: function(t, prop, value, receiver) {
21 _handler = this;
22 _target = t;
23 _prop = prop;
24 _value = value;
25 _receiver = receiver;
26 return true;
27 }
28 };
29 var p = new Proxy(target, handler);
30
31 p.attr = "foo";
32
33 assert.sameValue(_handler, handler, "handler object as the trap context");
34 assert.sameValue(_target, target, "first argument is the target object");
35 assert.sameValue(_prop, "attr", "second argument is the property name");
36 assert.sameValue(_value, "foo", "third argument is the new value");
37 assert.sameValue(_receiver, p, "forth argument is the proxy object");
38
39 reportCompare(0, 0);