call-bind-this-realm-undef.js (1081B)
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-ecmascript-function-objects-call-thisargument-argumentslist 5 description: The "this" value is set to the global This value 6 info: | 7 [...] 8 6. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument). 9 [...] 10 11 9.2.1.2OrdinaryCallBindThis ( F, calleeContext, thisArgument )# 12 13 [...] 14 5. If thisMode is strict, let thisValue be thisArgument. 15 6. Else, 16 a. If thisArgument is null or undefined, then 17 i. Let globalEnv be calleeRealm.[[GlobalEnv]]. 18 ii. Let globalEnvRec be globalEnv's EnvironmentRecord. 19 iii. Let thisValue be globalEnvRec.[[GlobalThisValue]]. 20 [...] 21 features: [cross-realm] 22 ---*/ 23 24 var other = $262.createRealm().global; 25 var func = new other.Function('return this;'); 26 var subject; 27 28 assert.sameValue(func(), other, 'implicit undefined'); 29 assert.sameValue(func.call(undefined), other, 'explicit undefined'); 30 assert.sameValue(func.call(null), other, 'null'); 31 32 reportCompare(0, 0);