Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1543)

Unified Diff: third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.cpp

Issue 2852963002: [ES6 modules] ModuleTreeLinker::FetchDescendants should not assume urls isn't empty. (Closed)
Patch Set: commentfix Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinkerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.cpp
diff --git a/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.cpp b/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.cpp
index e032e1043e7083354420fdd0d8f10eeabe6c255d..baceb7eedd23f10e52a9ea52e7ffd19e0cf300e0 100644
--- a/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.cpp
+++ b/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.cpp
@@ -233,20 +233,15 @@ void ModuleTreeLinker::FetchDescendants() {
// Step 2. If record.[[RequestedModules]] is empty, asynchronously complete
// this algorithm with module script.
- Vector<String> module_requests =
- modulator_->ModuleRequestsFromScriptModule(record);
- if (module_requests.IsEmpty()) {
- // Continue to Instantiate() to process "internal module script graph
- // fetching procedure" Step 5-.
- descendants_module_script_ = module_script_;
- Instantiate();
- return;
- }
+ // Note: We defer this bail-out until Step 5. Step 4 will be no-op anyway if
+ // record.[[RequestedModules]] is empty.
// Step 3. Let urls be a new empty list.
Vector<KURL> urls;
// Step 4. For each string requested of record.[[RequestedModules]],
+ Vector<String> module_requests =
+ modulator_->ModuleRequestsFromScriptModule(record);
for (const auto& module_request : module_requests) {
// Step 4.1. Let url be the result of resolving a module specifier given
// module script and requested.
@@ -288,8 +283,22 @@ void ModuleTreeLinker::FetchDescendants() {
// unset. If the caller of this algorithm specified custom perform the fetch
// steps, pass those along while performing the internal module script graph
// fetching procedure.
- // TODO(kouhei): handle "destination".
- DCHECK(!urls.IsEmpty());
+
+ if (urls.IsEmpty()) {
+ // Step 2. If record.[[RequestedModules]] is empty, asynchronously
+ // complete this algorithm with module script. [spec text]
+ // Also, if record.[[RequestedModules]] is not empty but |urls| is
+ // empty here, we can immediately complete this algorithm, as
+ // we don't have to process or wait for anything in Step 5. [non-spec text]
+
+ // Proceed to Instantiate() to continue
+ // "internal module script graph fetching procedure".
+ descendants_module_script_ = module_script_;
+ Instantiate();
+ return;
+ }
+
+ // Step 5, when "urls" is non-empty.
CHECK_EQ(num_incomplete_descendants_, 0u);
num_incomplete_descendants_ = urls.size();
for (const KURL& url : urls) {
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinkerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698