Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/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 es6id: 9.5.9
5 description: >
6 [[Set]] ( P, V, Receiver)
7
8 9. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target, P, V,
9 Receiver»)).
10
11 ---*/
12
13 var _target, _handler, _prop, _value, _receiver;
14 var target = {};
15 var handler = {
16 set: function(t, prop, value, receiver) {
17 _handler = this;
18 _target = t;
19 _prop = prop;
20 _value = value;
21 _receiver = receiver;
22 return t[prop] = value;
23 }
24 };
25 var p = new Proxy(target, handler);
26
27 p.attr = "foo";
28
29 assert.sameValue(_handler, handler, "handler object as the trap context");
30 assert.sameValue(_target, target, "first argument is the target object");
31 assert.sameValue(_prop, "attr", "second argument is the property name");
32 assert.sameValue(_value, "foo", "third argument is the new value");
33 assert.sameValue(_receiver, p, "forth argument is the proxy object");