tor-browser

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

unscopables-with.js (2115B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/function-forms/unscopables-with.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  count++;
     54  with (globalThis) {
     55    count++;
     56    assert.sameValue(v, undefined, 'The value of `v` is expected to equal `undefined`');
     57  }
     58  count++;
     59  var v = x;
     60  with (globalThis) {
     61    count++;
     62    assert.sameValue(v, 10, 'The value of `v` is 10');
     63    v = 20;
     64  }
     65  assert.sameValue(v, 20, 'The value of `v` is 20');
     66  assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1');
     67  callCount = callCount + 1;
     68 }
     69 
     70 ref(10).next().then(() => {
     71    assert.sameValue(callCount, 1, 'generator function invoked exactly once');
     72 }).then($DONE, $DONE);
     73 
     74  count++;
     75 }
     76 assert.sameValue(count, 6, 'The value of `count` is 6');