tor-browser

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

eval-self-once-module.js (1297B)


      1 // |reftest| module async
      2 // Copyright (C) 2018 Rick Waldron. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 /*---
      5 description: Module is evaluated exactly once
      6 esid: sec-moduleevaluation
      7 info: |
      8    [...]
      9    4. If module.[[Evaluated]] is true, return undefined.
     10    5. Set module.[[Evaluated]] to true.
     11    6. For each String required that is an element of module.[[RequestedModules]] do,
     12       a. Let requiredModule be ? HostResolveImportedModule(module, required).
     13       b. Perform ? requiredModule.ModuleEvaluation().
     14    [...]
     15 
     16    This test is meant to be flagged as module code, it should not initially
     17    run as script code or the result will not be the same.
     18 includes: [fnGlobalObject.js]
     19 flags: [async, module]
     20 features: [dynamic-import]
     21 ---*/
     22 
     23 var global = fnGlobalObject();
     24 
     25 if (typeof global.evaluated === 'undefined') {
     26  global.evaluated = 0;
     27 }
     28 
     29 global.evaluated++;
     30 
     31 Promise.all([
     32  import('./eval-self-once-module.js'),
     33  import('./eval-self-once-module.js'),
     34 ]).then(async () => {
     35  // Use await to serialize imports
     36  await import('./eval-self-once-module.js');
     37  await import('./eval-self-once-module.js');
     38 
     39  assert.sameValue(global.evaluated, 1, 'global property was defined and incremented only once');
     40 }).then($DONE, $DONE);