tor-browser

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

unscopables-with-in-nested-fn.js (2290B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/function-forms/unscopables-with-in-nested-fn.case
      4 // - src/function-forms/default/async-gen-func-decl.template
      5 /*---
      6 description: Symbol.unscopables behavior across scope boundaries (async generator function declaration)
      7 esid: sec-asyncgenerator-definitions-instantiatefunctionobject
      8 features: [globalThis, Symbol.unscopables, async-iteration]
      9 flags: [generated, noStrict, async]
     10 info: |
     11    AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier
     12        ( FormalParameters ) { AsyncGeneratorBody }
     13 
     14        [...]
     15        3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody,
     16            scope, strict).
     17        [...]
     18 
     19 
     20    ...
     21    Let envRec be lex's EnvironmentRecord.
     22    Let exists be ? envRec.HasBinding(name).
     23 
     24    HasBinding
     25 
     26    ...
     27    If the withEnvironment flag of envRec is false, return true.
     28    Let unscopables be ? Get(bindings, @@unscopables).
     29    If Type(unscopables) is Object, then
     30       Let blocked be ToBoolean(? Get(unscopables, N)).
     31       If blocked is true, return false.
     32 
     33    (The `with` Statement) Runtime Semantics: Evaluation
     34 
     35    ...
     36    Set the withEnvironment flag of newEnv’s EnvironmentRecord to true.
     37    ...
     38 
     39 ---*/
     40 let count = 0;
     41 var v = 1;
     42 globalThis[Symbol.unscopables] = {
     43  v: true,
     44 };
     45 
     46 {
     47  count++;
     48 
     49 
     50 var callCount = 0;
     51 // Stores a reference `ref` for case evaluation
     52 async function* ref(x) {
     53  (function() {
     54    count++;
     55    with (globalThis) {
     56      count++;
     57      assert.sameValue(v, 1, 'The value of `v` is 1');
     58    }
     59  })();
     60  (function() {
     61    count++;
     62    var v = x;
     63    with (globalThis) {
     64      count++;
     65      assert.sameValue(v, 10, 'The value of `v` is 10');
     66      v = 20;
     67    }
     68    assert.sameValue(v, 20, 'The value of `v` is 20');
     69    assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1');
     70  })();
     71  assert.sameValue(v, 1, 'The value of `v` is 1');
     72  assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1');
     73  callCount = callCount + 1;
     74 }
     75 
     76 ref(10).next().then(() => {
     77    assert.sameValue(callCount, 1, 'generator function invoked exactly once');
     78 }).then($DONE, $DONE);
     79 
     80  count++;
     81 }
     82 assert.sameValue(count, 6, 'The value of `count` is 6');