tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

scope-lex-open.js (1304B)


      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: >
      6    Creation of new variable environment for the function parameters and body
      7    (as distinct from that for the function's BindingIdentifier)
      8 info: |
      9    [...]
     10    3. Let callerContext be the running execution context.
     11    4. Let calleeContext be PrepareForOrdinaryCall(F, undefined).
     12    [...]
     13 
     14    9.2.1.1 PrepareForOrdinaryCall
     15 
     16    [...]
     17    8. Let localEnv be NewFunctionEnvironment(F, newTarget).
     18    9. Set the LexicalEnvironment of calleeContext to localEnv.
     19    10. Set the VariableEnvironment of calleeContext to localEnv.
     20    [...]
     21 features: [let]
     22 ---*/
     23 
     24 var n = 'outside';
     25 var probeBefore = function() { return n; };
     26 var probeInside;
     27 
     28 // This test intentionally elides parameter expressions because their presence
     29 // triggers the creation of an additional LexicalEnvironment dedicated to the
     30 // function body (see sec-functiondeclarationinstantiation)
     31 var func = function n() {
     32  let n = 'inside';
     33  probeInside = function() { return n; };
     34 };
     35 
     36 func();
     37 
     38 assert.sameValue(probeBefore(), 'outside');
     39 assert.sameValue(probeInside(), 'inside');
     40 
     41 reportCompare(0, 0);