| 1 |
// |reftest| module async |
| 2 |
// Copyright (C) 2019 Leo Balter. All rights reserved. |
| 3 |
// This code is governed by the BSD license found in the LICENSE file. |
| 4 |
|
| 5 |
/*--- |
| 6 |
esid: sec-moduleevaluation |
| 7 |
description: > |
| 8 |
Dynamic imported module with async exports |
| 9 |
info: | |
| 10 |
InnerModuleEvaluation( module, stack, index ) |
| 11 |
|
| 12 |
... |
| 13 |
14. If module.[[PendingAsyncDependencies]] is > 0, set module.[[AsyncEvaluating]] to true. |
| 14 |
15. Otherwise, if module.[[Async]] is true, perform ! ExecuteAsyncModule(module). |
| 15 |
16. Otherwise, perform ? module.ExecuteModule(). |
| 16 |
|
| 17 |
ExecuteAsyncModule ( module ) |
| 18 |
|
| 19 |
1. Assert: module.[[Status]] is "evaluating" or "evaluated". |
| 20 |
2. Assert: module.[[Async]] is true. |
| 21 |
3. Set module.[[AsyncEvaluating]] to true. |
| 22 |
4. Let capability be ! NewPromiseCapability(%Promise%). |
| 23 |
5. Let stepsFulfilled be the steps of a CallAsyncModuleFulfilled function as specified below. |
| 24 |
... |
| 25 |
8. Let stepsRejected be the steps of a CallAsyncModuleRejected function as specified below. |
| 26 |
... |
| 27 |
11. Perform ! PerformPromiseThen(capability.[[Promise]], onFulfilled, onRejected). |
| 28 |
12. Perform ! module.ExecuteModule(capability). |
| 29 |
13. Return. |
| 30 |
|
| 31 |
ExecuteModule ( [ capability ] ) |
| 32 |
|
| 33 |
... |
| 34 |
11. If module.[[Async]] is false, then |
| 35 |
a. Assert: capability was not provided. |
| 36 |
b. Push moduleCxt on to the execution context stack; moduleCxt is now the running execution context. |
| 37 |
c. Let result be the result of evaluating module.[[ECMAScriptCode]]. |
| 38 |
d. Suspend moduleCxt and remove it from the execution context stack. |
| 39 |
e. Resume the context that is now on the top of the execution context stack as the running execution context. |
| 40 |
f. Return Completion(result). |
| 41 |
12. Otherwise, |
| 42 |
a. Assert: capability is a PromiseCapability Record. |
| 43 |
b. Perform ! AsyncBlockStart(capability, module.[[ECMAScriptCode]], moduleCxt). |
| 44 |
c. Return. |
| 45 |
flags: [module, async] |
| 46 |
features: [top-level-await, dynamic-import] |
| 47 |
---*/ |
| 48 |
|
| 49 |
import('./module-import-rejection_FIXTURE.js').then(() => { |
| 50 |
throw new Test262Error('Should not be fulfilled'); |
| 51 |
}, (err) => { |
| 52 |
assert(err instanceof TypeError); |
| 53 |
assert.sameValue(err.constructor, TypeError); |
| 54 |
assert.sameValue(err.message, 'error in the default export line'); |
| 55 |
}).then($DONE, $DONE); |