rejection-order.js (1558B)
1 // |reftest| module async 2 // Copyright (C) 2025 Igalia, S.L. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 /*--- 5 esid: sec-async-module-execution-rejected 6 description: > 7 When an async module rejects, the promises relative to itself and its ancestors are resolved in leaf-to-root order 8 info: | 9 AsyncModuleExecutionRejected ( module, error ) 10 ... 11 9. If module.[[TopLevelCapability]] is not empty, then 12 a. Assert: module.[[CycleRoot]] and module are the same Module Record. 13 b. Perform ! Call(module.[[TopLevelCapability]].[[Reject]], undefined, « error »). 14 10. For each Cyclic Module Record m of module.[[AsyncParentModules]], do 15 a. Perform AsyncModuleExecutionRejected(m, error). 16 flags: [module, async] 17 features: [top-level-await, promise-with-resolvers] 18 includes: [compareArray.js] 19 ---*/ 20 21 import { p1, pA_start, pB_start } from "./rejection-order_setup_FIXTURE.js"; 22 23 let logs = []; 24 25 const importsP = Promise.all([ 26 // Ensure that a.Evaluate() is called after b.Evaluate() 27 pB_start.promise.then(() => import("./rejection-order_a_FIXTURE.js").finally(() => logs.push("A"))).catch(() => {}), 28 import("./rejection-order_b_FIXTURE.js").finally(() => logs.push("B")).catch(() => {}), 29 ]); 30 31 // Wait for evaluation of both graphs with entry points in A and B to start before 32 // rejecting the promise that B is blocked on. 33 Promise.all([pA_start.promise, pB_start.promise]).then(p1.reject); 34 35 importsP.then(() => { 36 assert.compareArray(logs, ["B", "A"]); 37 38 $DONE(); 39 });