Skip to content

Commit

Permalink
[ES6 modules] Update spec reference to #run-a-module-script
Browse files Browse the repository at this point in the history
This CL updates spec text references to
https://html.spec.whatwg.org/#run-a-module-script.

This change is to be introduced in whatwg html spec PR:
whatwg/html#2674

The actual implementation behavior change will be introduced in separate CLs.

Bug: 594639, 727299, whatwg/html#2674
Change-Id: Ia658aed3bd2c37814aa1950c7cf4fec8b1c4bb1d
Reviewed-on: https://chromium-review.googlesource.com/541178
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Kouhei Ueno <kouhei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#480761}
  • Loading branch information
nyaxt authored and Commit Bot committed Jun 20, 2017
1 parent 147c403 commit ed8fde7
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions third_party/WebKit/Source/core/dom/ModulatorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,21 @@ void ModulatorImpl::ExecuteModule(const ModuleScript* module_script) {
// https://crbug.com/715376
CHECK(RuntimeEnabledFeatures::ModuleScriptsEnabled());

// 1. "Let settings be the settings object of s."
// Step 1. "Let settings be the settings object of s." [spec text]
// The settings object is |this|.

// 2. "Check if we can run script with settings.
// If this returns "do not run" then abort these steps."
// Step 2. "Check if we can run script with settings.
// If this returns "do not run" then abort these steps." [spec text]
if (!GetExecutionContext()->CanExecuteScripts(kAboutToExecuteScript))
return;

// 6. "Prepare to run script given settings."
// Step 4. "Prepare to run script given settings." [spec text]
// This is placed here to also cover ScriptModule::ReportException().
ScriptState::Scope scope(script_state_.Get());

// 3. "If s's instantiation state is "errored", then report the exception
// given by s's instantiation error for s and abort these steps."
// Step 3. "If s is errored, then report the exception given by s's error for
// s and abort these steps." [spec text]
// TODO(kouhei): Update "is errored".
ModuleInstantiationState instantiationState = module_script->State();
if (instantiationState == ModuleInstantiationState::kErrored) {
v8::Isolate* isolate = script_state_->GetIsolate();
Expand All @@ -194,18 +195,18 @@ void ModulatorImpl::ExecuteModule(const ModuleScript* module_script) {
return;
}

// 4. "Assert: s's instantiation state is "instantiated" (and thus its
// module record is not null)."
CHECK_EQ(instantiationState, ModuleInstantiationState::kInstantiated);

// 5. "Let record be s's module record."
// Step 5. "Let record be s's module record." [spec text]
const ScriptModule& record = module_script->Record();
CHECK(!record.IsNull());

// Steps 7 and 8.
// Step 6. "Let evaluationStatus be record.ModuleEvaluation()." [spec text]
record.Evaluate(script_state_.Get());

// 9. "Clean up after running script with settings."
// Step 7. "If evaluationStatus is an abrupt completion, then report the
// exception given by evaluationStatus.[[Value]] for s." [spec text]
// TODO(kouhei): Implement this.

// Step 8. "Clean up after running script with settings." [spec text]
// Implemented as the ScriptState::Scope destructor.
}

Expand Down

0 comments on commit ed8fde7

Please sign in to comment.