| 1 |
// |reftest| async |
| 2 |
// This file was procedurally generated from the following sources: |
| 3 |
// - src/dynamic-import/eval-script-code-host-resolves-module-code.case |
| 4 |
// - src/dynamic-import/default/nested-async-generator-await.template |
| 5 |
/*--- |
| 6 |
description: import() from a script code can load a file with module code (nested in async generator, awaited) |
| 7 |
esid: sec-import-call-runtime-semantics-evaluation |
| 8 |
features: [dynamic-import, async-iteration] |
| 9 |
flags: [generated, async] |
| 10 |
info: | |
| 11 |
ImportCall : |
| 12 |
import( AssignmentExpression ) |
| 13 |
|
| 14 |
1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). |
| 15 |
2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). |
| 16 |
3. Let argRef be the result of evaluating AssignmentExpression. |
| 17 |
4. Let specifier be ? GetValue(argRef). |
| 18 |
5. Let promiseCapability be ! NewPromiseCapability(%Promise%). |
| 19 |
6. Let specifierString be ToString(specifier). |
| 20 |
7. IfAbruptRejectPromise(specifierString, promiseCapability). |
| 21 |
8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). |
| 22 |
9. Return promiseCapability.[[Promise]]. |
| 23 |
|
| 24 |
---*/ |
| 25 |
// This is still valid in script code, and should not be valid for module code |
| 26 |
// https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames |
| 27 |
var smoosh; function smoosh() {} |
| 28 |
|
| 29 |
|
| 30 |
let callCount = 0; |
| 31 |
|
| 32 |
async function * f() { |
| 33 |
await import('./module-code_FIXTURE.js').then(imported => { |
| 34 |
|
| 35 |
assert.sameValue(imported.default, 42); |
| 36 |
assert.sameValue(imported.x, 'Test262'); |
| 37 |
assert.sameValue(imported.z, 42); |
| 38 |
|
| 39 |
callCount++; |
| 40 |
}); |
| 41 |
} |
| 42 |
|
| 43 |
f().next().then(() => { |
| 44 |
assert.sameValue(callCount, 1); |
| 45 |
}).then($DONE, $DONE).catch($DONE); |