tor-browser

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

for-await-resolution-and-error.js (1508B)


      1 // |reftest| async
      2 // Copyright (C) 2018 Leo Balter. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 /*---
      5 description: >
      6    Resolve multiple imports through a for await loop
      7 esid: sec-finishdynamicimport
      8 info: |
      9    Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion )
     10    
     11    2. Otherwise,
     12        a. Assert: completion is a normal completion and completion.[[Value]] is undefined.
     13        b. Let moduleRecord be ! HostResolveImportedModule(referencingScriptOrModule, specifier).
     14        c. Assert: Evaluate has already been invoked on moduleRecord and successfully completed.
     15        d. Let namespace be GetModuleNamespace(moduleRecord).
     16        ...
     17        f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »).
     18 flags: [async]
     19 features: [dynamic-import]
     20 includes: [compareArray.js]
     21 ---*/
     22 
     23 let r = [];
     24 async function aiter() {
     25  for await (let imported of [
     26      import('./for-await-resolution-and-error-a_FIXTURE.js'),
     27      import('./for-await-resolution-and-error-b_FIXTURE.js'),
     28      import('./for-await-resolution-and-error-poisoned_FIXTURE.js'),
     29      import('./for-await-resolution-and-error-a_FIXTURE.js'), // this should be ignored
     30    ]) {
     31    r.push(imported.x);
     32  }
     33 }
     34 
     35 aiter().then(() => { throw 'The async function should not resolve' }, error => {
     36  assert.compareArray(r, [42, 39]);
     37  assert.sameValue(error, 'foo');
     38 }).then($DONE, $DONE);