Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Proxy/get/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.8
5 description: >
6 [[Get]] (P, Receiver)
7
8 9. Let trapResult be Call(trap, handler, «target, P, Receiver»).
9 info: |
10 6.1.7.2 Object Internal Methods and Internal Slots
11
12 (...) Receiver is used as the this value when evaluating the code
13 ---*/
14
15 var _target, _handler, _prop, _receiver;
16 var target = {
17 attr: 1
18 };
19 var handler = {
20 get: function(t, prop, receiver) {
21 _handler = this;
22 _target = t;
23 _prop = prop;
24 _receiver = receiver;
25 }
26 };
27 var p = new Proxy(target, handler);
28
29 p.attr;
30
31 assert.sameValue(_handler, handler);
32 assert.sameValue(_target, target);
33 assert.sameValue(_prop, "attr");
34 assert.sameValue(_receiver, p, "receiver is the Proxy object");
35
36 _prop = null;
37 p["attr"];
38 assert.sameValue(
39 _prop, "attr",
40 "trap is triggered both by p.attr and p['attr']"
41 );