call-parameters.js (992B)
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 features: [Proxy] 14 ---*/ 15 16 var _target, _handler, _prop, _receiver; 17 var target = { 18 attr: 1 19 }; 20 var handler = { 21 get: function(t, prop, receiver) { 22 _handler = this; 23 _target = t; 24 _prop = prop; 25 _receiver = receiver; 26 } 27 }; 28 var p = new Proxy(target, handler); 29 30 p.attr; 31 32 assert.sameValue(_handler, handler); 33 assert.sameValue(_target, target); 34 assert.sameValue(_prop, "attr"); 35 assert.sameValue(_receiver, p, "receiver is the Proxy object"); 36 37 _prop = null; 38 p["attr"]; 39 assert.sameValue( 40 _prop, "attr", 41 "trap is triggered both by p.attr and p['attr']" 42 ); 43 44 reportCompare(0, 0);