Skip to content

Commit bde6181

Browse files
Test a module depending on a non-root node of an asyn cycle
1 parent 84f8202 commit bde6181

5 files changed

+92
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-innermoduleevaluation
6+
description: >
7+
A module depending on an async module of a separate cycle should wait for the cycle root to complete
8+
info: |
9+
Module graph:
10+
11+
┌──────────────────┐
12+
│ entrypoint │
13+
└──────────────────┘
14+
│ │
15+
▼ ▼
16+
┌──────────────────┐ ┌────────────────────────┐
17+
│ cycle root (TLA) │ │ importer of cycle leaf │
18+
└──────────────────┘ └────────────────────────┘
19+
│ ▲ │
20+
▼ │ │
21+
┌──────────────────┐ │
22+
│ cycle leaf (TLA) │ ◄──────┘
23+
└──────────────────┘
24+
25+
This test exercises step 11.c.iv.1 of the following algorithm when _module_ is
26+
"importer of cycle leaf", _requiredModule_ is "cycle leaf (TLA)", and
27+
_requiredModule_.[[CycleRoot]] is "cycle root (TLA)".
28+
29+
InnerModuleEvaluation ( module, stack, index )
30+
...
31+
11. For each ModuleRequest Record request of module.[[RequestedModules]], do
32+
a. Let requiredModule be GetImportedModule(module, request).
33+
b. Set index to ? InnerModuleEvaluation(requiredModule, stack, index).
34+
c. If requiredModule is a Cyclic Module Record, then
35+
i. Assert: requiredModule.[[Status]] is one of evaluating, evaluating-async, or evaluated.
36+
ii. Assert: requiredModule.[[Status]] is evaluating if and only if stack contains requiredModule.
37+
iii. If requiredModule.[[Status]] is evaluating, then
38+
1. Set module.[[DFSAncestorIndex]] to min(module.[[DFSAncestorIndex]], requiredModule.[[DFSAncestorIndex]]).
39+
iv. Else,
40+
1. Set requiredModule to requiredModule.[[CycleRoot]].
41+
2. Assert: requiredModule.[[Status]] is either evaluating-async or evaluated.
42+
3. If requiredModule.[[EvaluationError]] is not empty, return ? requiredModule.[[EvaluationError]].
43+
v. If requiredModule.[[AsyncEvaluationOrder]] is an integer, then
44+
1. Set module.[[PendingAsyncDependencies]] to module.[[PendingAsyncDependencies]] + 1.
45+
2. Append module to requiredModule.[[AsyncParentModules]].
46+
47+
flags: [module, async]
48+
features: [top-level-await]
49+
includes: [compareArray.js]
50+
---*/
51+
52+
import "./pending-async-dep-from-cycle_setup_FIXTURE.js";
53+
import "./pending-async-dep-from-cycle_cycle-root_FIXTURE.js";
54+
import "./pending-async-dep-from-cycle_import-cycle-leaf_FIXTURE.js";
55+
56+
assert.compareArray(globalThis.logs, [
57+
"cycle leaf start",
58+
"cycle leaf end",
59+
"cycle root start",
60+
// Without the step covered by this test,
61+
// these last two entries would be swapped.
62+
"cycle root end",
63+
"importer of cycle leaf"
64+
]);
65+
66+
$DONE();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
import "./pending-async-dep-from-cycle_cycle-root_FIXTURE.js";
5+
6+
globalThis.logs.push("cycle leaf start");
7+
await 1;
8+
globalThis.logs.push("cycle leaf end");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
import "./pending-async-dep-from-cycle_cycle-leaf_FIXTURE.js";
5+
6+
globalThis.logs.push("cycle root start");
7+
await 1;
8+
globalThis.logs.push("cycle root end");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
import "./pending-async-dep-from-cycle_cycle-leaf_FIXTURE.js";
5+
6+
globalThis.logs.push("importer of cycle leaf");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
globalThis.logs = [];

0 commit comments

Comments
 (0)