Chromium Code Reviews| 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 7f9213e213e24be7730548294b06b323f6672a0b..10b769a623644ef9a838e22f5b869da2c48a6842 100644 |
| --- a/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.cpp |
| +++ b/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.cpp |
| @@ -112,7 +112,7 @@ void ModuleTreeLinker::AdvanceState(State new_state) { |
| registry_->ReleaseFinishedFetcher(this); |
| // https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-script-graph-fetching-procedure |
| - // Step 8. Asynchronously complete this algorithm with descendants result. |
| + // Step 9. Asynchronously complete this algorithm with descendants result. |
| client_->NotifyModuleTreeLoadFinished(descendants_module_script_); |
| } |
| } |
| @@ -230,7 +230,7 @@ void ModuleTreeLinker::FetchDescendants() { |
| // Abort this algorithm, and asynchronously complete it with null. |
| // Note: The return variable for "internal module script graph fetching |
| - // procedure" is descendants_module_script_ per Step 8. |
| + // procedure" is descendants_module_script_ per Step 9. |
| DCHECK(!descendants_module_script_); |
| // Note: while we complete "fetch the descendants of a module script" |
| // algorithm here, we still need to continue to the rest of the |
| @@ -336,33 +336,50 @@ void ModuleTreeLinker::Instantiate() { |
| // https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-script-graph-fetching-procedure |
| - // Step 5. Let record be result's module record. |
| - ScriptModule record = module_script_->Record(); |
| - |
| - // Step 6. Let instantiationStatus be record.ModuleDeclarationInstantiation(). |
| + // Step 5. Let instantiationStatus be null. |
| // Note: The |error| variable corresponds to spec variable |
| // "instantiationStatus". If |error| is empty, it indicates successful |
| // completion. |
| - ScriptValue error = modulator_->InstantiateModule(record); |
| + ScriptValue error; |
| + |
| + // Step 6. If result's instantiation state is "errored",... |
| + if (module_script_->InstantiationState() == |
| + ModuleInstantiationState::kErrored) { |
| + // ... Set instantiationStatus to record.ModuleDeclarationInstantiation(). |
| + error = modulator_->GetInstantiationError(module_script_); |
|
hiroshige
2017/04/27 22:56:40
DCHECK(!error.IsEmpty());
kouhei (in TOK)
2017/04/28 00:55:09
Done.
|
| + } else { |
| + // Step 7. Otherwise: |
| + // Step 7.1. Let record be result's module record. |
| + ScriptModule record = module_script_->Record(); |
| + // Step 7.2. Set instantiationStatus to |
| + // record.ModuleDeclarationInstantiation(). |
| + error = modulator_->InstantiateModule(record); |
| + } |
| - // Step 7. For each module script script in result's uninstantiated inclusive |
| + // Step 8. For each module script script in result's uninstantiated inclusive |
| // descendant module scripts, perform the following steps: |
| HeapHashSet<Member<ModuleScript>> uninstantiated_set = |
| UninstantiatedInclusiveDescendants(); |
| for (const auto& descendant : uninstantiated_set) { |
| if (!error.IsEmpty()) { |
| - // Step 7.1. If instantiationStatus is an abrupt completion, then set |
| - // script's instantiation state to "errored", its instantiation error to |
| - // instantiationStatus.[[Value]], and its module record to null. |
| + // Step 8.1. If instantiationStatus is an abrupt completion, then |
| + // Step 8.1.1. Set script module record's [[HostDefined]] field to |
| + // undefined. |
| + // TODO(kouhei): Implement this. |
| + |
| + // Step 8.1.2. Set script's module record to null. |
| + // Step 8.1.3. Set script's instantiation state to "errored". |
| + // Step 8.1.4. Set script's instantiation error to |
| + // instantiationStatus.[[Value]]. |
| descendant->SetInstantiationErrorAndClearRecord(error); |
| } else { |
| - // Step 7.2. Otherwise, set script's instantiation state to |
| + // Step 8.2. Otherwise, set script's instantiation state to |
| // "instantiated". |
| descendant->SetInstantiationSuccess(); |
| } |
| } |
| - // Step 8. Asynchronously complete this algorithm with descendants result. |
| + // Step 9. Asynchronously complete this algorithm with descendants result. |
| AdvanceState(State::kFinished); |
| } |