| 1 |
// |reftest| skip module async -- import-defer is not supported |
| 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 |
/*--- |
| 6 |
esid: sec-ContinueDynamicImport |
| 7 |
description: > |
| 8 |
`import.defer` of a sync module graph does not cause evaluation |
| 9 |
info: | |
| 10 |
13.3.10.1.1 ContinueDynamicImport ( |
| 11 |
_payload_: a DynamicImportState Record, |
| 12 |
_moduleCompletion_: either a normal completion containing a Module Record or a throw completion, |
| 13 |
): ~UNUSED~ |
| 14 |
1. Let _promiseCapability_ be _payload_.[[PromiseCapability]]. |
| 15 |
1. Let _phase_ be _payload_.[[Phase]]. |
| 16 |
1. ... |
| 17 |
1. Let _module_ be _moduleCompletion_.[[Value]]. |
| 18 |
1. Let _loadPromise_ be _module_.LoadRequestedModules(). |
| 19 |
1. ... |
| 20 |
1. Let _linkAndEvaluateClosure_ be a new Abstract Closure with no parameters that captures _module_, _promiseCapability_, _phase_ and _onRejected_ and performs the following steps when called: |
| 21 |
1. ... |
| 22 |
1. Let _fulfilledClosure_ be a new Abstract Closure with no parameters that captures _module_, _phase_, and _promiseCapability_ and performs the following steps when called: |
| 23 |
1. Let _namespace_ be GetModuleNamespace(_module_, _phase_). |
| 24 |
1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _namespace_ »). |
| 25 |
1. Return ~UNUSED~. |
| 26 |
1. If _phase_ is ~defer~, then |
| 27 |
1. Let _evaluationList_ be GatherAsynchronousTransitiveDependencies(_module_). |
| 28 |
1. If _evaluationList_ is empty, then |
| 29 |
1. Perform _fulfilledClosure_(). |
| 30 |
1. Return ~UNUSED~. |
| 31 |
1. ... |
| 32 |
1. Let _linkAndEvaluate_ be CreateBuiltinFunction(_linkAndEvaluateClosure_, *""*, 0, « »). |
| 33 |
1. Perform PerformPromiseThen(_loadPromise_, _linkAndEvaluate_, _onRejected_). |
| 34 |
1. Return ~UNUSED~. |
| 35 |
|
| 36 |
flags: [module, async] |
| 37 |
features: [import-defer] |
| 38 |
includes: [compareArray.js] |
| 39 |
---*/ |
| 40 |
|
| 41 |
import "./setup_FIXTURE.js"; |
| 42 |
|
| 43 |
import.defer("./sync_FIXTURE.js").then(ns => { |
| 44 |
assert.compareArray(globalThis.evaluations, []); |
| 45 |
ns.x; |
| 46 |
assert.compareArray(globalThis.evaluations, ["dep", "sync"]); |
| 47 |
}).then($DONE, $DONE); |