module-import-rejection-body.js (2794B)
1 // |reftest| error:TypeError module 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 Evaluate imported rejected module 9 info: | 10 Table 3: Additional Fields of Cyclic Module Records 11 12 [[Async]] 13 14 ... 15 Having an asynchronous dependency does not make the module asynchronous. This field must not change after the module is parsed. 16 17 Evaluate ( ) Concrete Method 18 19 ... 20 6. Let capability be ! NewPromiseCapability(%Promise%). 21 7. Set module.[[TopLevelCapability]] to capability. 22 8. Let result be InnerModuleEvaluation(module, stack, 0). 23 9. If result is an abrupt completion, then 24 ... 25 d. Perform ! Call(capability.[[Reject]], undefined, «result.[[Value]]»). 26 10. Otherwise, 27 ... 28 b. If module.[[AsyncEvaluating]] is false, then 29 i. Perform ! Call(capability.[[Resolve]], undefined, «undefined»). 30 ... 31 11. Return undefinedcapability.[[Promise]]. 32 33 InnerModuleEvaluation( module, stack, index ) 34 35 ... 36 14. If module.[[PendingAsyncDependencies]] is > 0, set module.[[AsyncEvaluating]] to true. 37 15. Otherwise, if module.[[Async]] is true, perform ! ExecuteAsyncModule(module). 38 16. Otherwise, perform ? module.ExecuteModule(). 39 40 ExecuteAsyncModule ( module ) 41 42 1. Assert: module.[[Status]] is "evaluating" or "evaluated". 43 2. Assert: module.[[Async]] is true. 44 3. Set module.[[AsyncEvaluating]] to true. 45 4. Let capability be ! NewPromiseCapability(%Promise%). 46 5. Let stepsFulfilled be the steps of a CallAsyncModuleFulfilled function as specified below. 47 ... 48 8. Let stepsRejected be the steps of a CallAsyncModuleRejected function as specified below. 49 ... 50 11. Perform ! PerformPromiseThen(capability.[[Promise]], onFulfilled, onRejected). 51 12. Perform ! module.ExecuteModule(capability). 52 13. Return. 53 54 ExecuteModule ( [ capability ] ) 55 56 ... 57 11. If module.[[Async]] is false, then 58 a. Assert: capability was not provided. 59 b. Push moduleCxt on to the execution context stack; moduleCxt is now the running execution context. 60 c. Let result be the result of evaluating module.[[ECMAScriptCode]]. 61 d. Suspend moduleCxt and remove it from the execution context stack. 62 e. Resume the context that is now on the top of the execution context stack as the running execution context. 63 f. Return Completion(result). 64 12. Otherwise, 65 a. Assert: capability is a PromiseCapability Record. 66 b. Perform ! AsyncBlockStart(capability, module.[[ECMAScriptCode]], moduleCxt). 67 c. Return. 68 flags: [module] 69 features: [top-level-await] 70 negative: 71 phase: runtime 72 type: TypeError 73 ---*/ 74 75 import foo from './module-import-rejection-body_FIXTURE.js'; 76 77 throw new Test262Error('this should be unreachable');