trap-is-undefined-no-property.js (1191B)
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 /*--- 5 esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist 6 description: > 7 If trap is not set, propagate the call to the target object. 8 info: | 9 [[Call]] (thisArgument, argumentsList) 10 11 ... 12 5. Let trap be ? GetMethod(handler, "apply"). 13 6. If trap is undefined, then 14 a. Return ? Call(target, thisArgument, argumentsList). 15 ... 16 17 GetMethod ( V, P ) 18 19 ... 20 3. If func is either undefined or null, return undefined. 21 ... 22 features: [Proxy] 23 ---*/ 24 25 var calls = 0; 26 var _context; 27 28 var target = new Proxy(function() {}, { 29 apply: function(_target, context, args) { 30 calls++; 31 _context = context; 32 return args[0] + args[1]; 33 } 34 }) 35 36 var p = new Proxy(target, {}); 37 var context = {}; 38 var res = p.call(context, 1, 2); 39 40 assert.sameValue(calls, 1, "apply is missing: [[Call]] is invoked once"); 41 assert.sameValue(_context, context, "apply is missing: context is passed to [[Call]]"); 42 assert.sameValue(res, 3, "apply is missing: result of [[Call]] is returned"); 43 44 reportCompare(0, 0);