nested-async-function-await-import-defer-specifier-tostring-abrupt-rejects.js (2134B)
1 // |reftest| skip async -- import-defer is not supported 2 // This file was procedurally generated from the following sources: 3 // - src/dynamic-import/import-defer-specifier-tostring-abrupt-rejects.case 4 // - src/dynamic-import/catch/nested-async-function-await.template 5 /*--- 6 description: Abrupt from ToString(specifier) rejects the promise (nested in async function, awaited) 7 esid: sec-import-call-runtime-semantics-evaluation 8 features: [import-defer, 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 . defer ( |AssignmentExpression| ) 30 1. Return ? EvaluateImportCall(|AssignmentExpression|, ~defer~) 31 32 EvaluateImportCall ( specifierExpression, phase ) 33 1. Let _referrer_ be GetActiveScriptOrModule(). 34 1. If _referrer_ is *null*, set _referrer_ to the current Realm Record. 35 1. Let _specifierRef_ be ? Evaluation of _specifierExpression_. 36 1. Let _specifier_ be ? GetValue(_specifierRef_). 37 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 38 1. Let _specifierString_ be Completion(ToString(_specifier_)). 39 1. IfAbruptRejectPromise(_specifierString_, _promiseCapability_). 40 ... 41 42 ---*/ 43 const obj = { 44 toString() { 45 throw 'custom error'; 46 } 47 }; 48 49 50 async function f() { 51 await import.defer(obj).catch(error => { 52 53 assert.sameValue(error, 'custom error'); 54 55 }).then($DONE, $DONE); 56 } 57 58 f();