with-base-obj.js (952B)
1 // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-function-calls-runtime-semantics-evaluation 5 es6id: 12.3.4.1 6 description: Correct retrieval of environment's "with" base object 7 info: | 8 4. If Type(ref) is Reference, then 9 a. If IsPropertyReference(ref) is true, then 10 [...] 11 b. Else the base of ref is an Environment Record, 12 i. Let refEnv be GetBase(ref). 13 ii. Let thisValue be refEnv.WithBaseObject(). 14 [...] 15 8. Return ? EvaluateDirectCall(func, thisValue, Arguments, tailCall). 16 flags: [noStrict] 17 ---*/ 18 19 var viaMember, viaCall; 20 var obj = { 21 method: function() { 22 viaCall = this; 23 }, 24 get attribute() { 25 viaMember = this; 26 } 27 }; 28 29 with (obj) { 30 method(); 31 attribute; 32 } 33 34 assert.sameValue(viaCall, obj, 'via CallExpression'); 35 assert.sameValue(viaMember, obj, 'via MemberExpression'); 36 37 reportCompare(0, 0);