realm.js (1158B)
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-performeval 5 es6id: 18.2.1.1 6 description: > 7 Uses the global variable envrionment of the running execution context 8 info: | 9 [...] 10 12. Let ctx be the running execution context. If direct is true, ctx will be 11 the execution context that performed the direct eval. If direct is false, 12 ctx will be the execution context for the invocation of the eval 13 function. 14 13. If direct is true, then 15 [...] 16 14. Else, 17 a. Let lexEnv be NewDeclarativeEnvironment(evalRealm.[[GlobalEnv]]). 18 b. Let varEnv be evalRealm.[[GlobalEnv]]. 19 [...] 20 17. Let evalCxt be a new ECMAScript code execution context. 21 [...] 22 21. Set the evalCxt's VariableEnvironment to varEnv. 23 [...] 24 24. Let result be EvalDeclarationInstantiation(body, varEnv, lexEnv, 25 strictEval). 26 features: [cross-realm] 27 ---*/ 28 29 var other = $262.createRealm().global; 30 var otherEval = other.eval; 31 32 otherEval('var x = 23;'); 33 assert.sameValue(typeof x, 'undefined'); 34 assert.sameValue(other.x, 23); 35 36 reportCompare(0, 0);