tor-browser

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

async-gen-meth-eval-var-scope-syntax-err.js (1536B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/function-forms/eval-var-scope-syntax-err.case
      3 // - src/function-forms/error-no-strict/async-gen-meth.template
      4 /*---
      5 description: sloppy direct eval in params introduces var (async generator method in sloppy code)
      6 esid: sec-asyncgenerator-definitions-propertydefinitionevaluation
      7 features: [default-parameters, async-iteration]
      8 flags: [generated, noStrict]
      9 info: |
     10    AsyncGeneratorMethod :
     11        async [no LineTerminator here] * PropertyName ( UniqueFormalParameters )
     12            { AsyncGeneratorBody }
     13 
     14    1. Let propKey be the result of evaluating PropertyName.
     15    2. ReturnIfAbrupt(propKey).
     16    3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true.
     17       Otherwise let strict be false.
     18    4. Let scope be the running execution context's LexicalEnvironment.
     19    5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters,
     20       AsyncGeneratorBody, scope, strict).
     21    [...]
     22 
     23 
     24    
     25    Runtime Semantics: IteratorBindingInitialization
     26    FormalParameter : BindingElement
     27 
     28    1. Return the result of performing IteratorBindingInitialization for BindingElement with arguments iteratorRecord and environment.
     29 
     30 ---*/
     31 
     32 var callCount = 0;
     33 var obj = {
     34  async *method(a = eval("var a = 42")) {
     35    
     36    callCount = callCount + 1;
     37  }
     38 };
     39 
     40 assert.throws(SyntaxError, function() {
     41  obj.method();
     42 });
     43 assert.sameValue(callCount, 0, 'generator method body not evaluated');
     44 
     45 reportCompare(0, 0);