tor-browser

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

scope-body-lex-boundary.js (1576B)


      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-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
      5 description: >
      6    Creation of new lexical environment for each evaluation of the statement
      7    body
      8 info: |
      9    IterationStatement : for ( ForDeclaration of AssignmentExpression ) Statement
     10 
     11    [...]
     12    2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
     13       lexicalBinding, labelSet).
     14 
     15    13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
     16 
     17    [...]
     18    5. Repeat
     19       [...]
     20       i. Let result be the result of evaluating stmt.
     21       j. Set the running execution context's LexicalEnvironment to oldEnv.
     22       k. If LoopContinues(result, labelSet) is false, return ?
     23          IteratorClose(iterator, UpdateEmpty(result, V)).
     24       l. If result.[[Value]] is not empty, let V be result.[[Value]].
     25 features: [let]
     26 ---*/
     27 
     28 let x = 'outside';
     29 var probeFirst, probeSecond;
     30 
     31 for (let x in { a: 0, b: 0 })
     32  if (!probeFirst)
     33    probeFirst = function() { return x; };
     34  else
     35    probeSecond = function() { return x; };
     36 
     37 
     38 // 13.7.5.15 EnumerateObjectProperties
     39 //
     40 // > [...] The mechanics and order of enumerating the properties is not
     41 // > specified [...]
     42 assert.notSameValue(probeFirst(), probeSecond());
     43 assert(
     44  probeFirst() === 'a' || probeFirst() === 'b',
     45  'First binding is either "a" or "b"'
     46 );
     47 assert(
     48  probeSecond() === 'a' || probeSecond() === 'b',
     49  'Second binding is either "a" or "b"'
     50 );
     51 
     52 reportCompare(0, 0);