trap-is-null.js (1211B)
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 the apply trap value is null, 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 apply: null 38 }); 39 40 var context = {}; 41 var res = p.call(context, 1, 2); 42 43 assert.sameValue(calls, 1, "apply is null: [[Call]] is invoked once"); 44 assert.sameValue(_context, context, "apply is null: context is passed to [[Call]]"); 45 assert.sameValue(res, 3, "apply is null: result of [[Call]] is returned"); 46 47 reportCompare(0, 0);