| 1 |
// |reftest| skip async -- source-phase-imports is not supported |
| 2 |
// This file was procedurally generated from the following sources: |
| 3 |
// - src/dynamic-import/import-source-specifier-tostring-abrupt-rejects.case |
| 4 |
// - src/dynamic-import/catch/nested-while.template |
| 5 |
/*--- |
| 6 |
description: Abrupt from ToString(specifier) rejects the promise (nested while) |
| 7 |
esid: sec-import-call-runtime-semantics-evaluation |
| 8 |
features: [source-phase-imports, dynamic-import] |
| 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 |
Import Calls |
| 26 |
|
| 27 |
Runtime Semantics: Evaluation |
| 28 |
|
| 29 |
ImportCall : import . source ( AssignmentExpression ) |
| 30 |
1. Return ? EvaluateImportCall(AssignmentExpression, source). |
| 31 |
|
| 32 |
13.3.10.1.1 EvaluateImportCall ( specifierExpression, phase ) |
| 33 |
1. Let referrer be GetActiveScriptOrModule(). |
| 34 |
2. If referrer is null, set referrer to the current Realm Record. |
| 35 |
3. Let specifierRef be ? Evaluation of specifierExpression. |
| 36 |
4. Let specifier be ? GetValue(specifierRef). |
| 37 |
5. Let promiseCapability be ! NewPromiseCapability(%Promise%). |
| 38 |
6. Let specifierString be Completion(ToString(specifier)). |
| 39 |
7. IfAbruptRejectPromise(specifierString, promiseCapability). |
| 40 |
8. Let moduleRequest be a new ModuleRequest Record { [[Specifier]]: specifierString, [[Phase]]: phase }. |
| 41 |
9. Perform HostLoadImportedModule(referrer, moduleRequest, empty, promiseCapability). |
| 42 |
10. Return promiseCapability.[[Promise]]. |
| 43 |
|
| 44 |
---*/ |
| 45 |
const obj = { |
| 46 |
toString() { |
| 47 |
throw 'custom error'; |
| 48 |
} |
| 49 |
}; |
| 50 |
|
| 51 |
|
| 52 |
let x = 0; |
| 53 |
while (!x) { |
| 54 |
x++; |
| 55 |
import.source(obj).catch(error => { |
| 56 |
|
| 57 |
assert.sameValue(error, 'custom error'); |
| 58 |
|
| 59 |
}).then($DONE, $DONE); |
| 60 |
}; |