Skip to content

Commit

Permalink
[ES6 modules] Update module linking procedures to follow latest spec …
Browse files Browse the repository at this point in the history
…updates

This CL updates Blink's impl of #internal-module-script-graph-fetching-procedure
and #fetch-the-descendants-of-and-instantiate-a-module-script to match
recent spec change: whatwg/html#2595 .

Tests: external/wpt/html/semantics/scripting-1/the-script-element/module/specifier-error.html
Bug: 727299, 594639
Change-Id: I022b3b380b408a6d5c75a59d161aea4fe2868f48
Reviewed-on: https://chromium-review.googlesource.com/528724
Commit-Queue: Yutaka Hirano <[email protected]>
Reviewed-by: Hiroki Nakagawa <[email protected]>
Reviewed-by: Yutaka Hirano <[email protected]>
Reviewed-by: Kinuko Yasuda <[email protected]>
Cr-Commit-Position: refs/heads/master@{#478609}
  • Loading branch information
nyaxt authored and Commit Bot committed Jun 12, 2017
1 parent 937beec commit e123c91
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 127 deletions.
1 change: 0 additions & 1 deletion third_party/WebKit/LayoutTests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,6 @@ crbug.com/594639 external/wpt/html/semantics/scripting-1/the-script-element/modu
crbug.com/594639 external/wpt/html/semantics/scripting-1/the-script-element/module/evaluation-error-2.html [ Failure ]
crbug.com/594639 external/wpt/html/semantics/scripting-1/the-script-element/module/evaluation-error-3.html [ Failure ]
crbug.com/594639 external/wpt/html/semantics/scripting-1/the-script-element/module/evaluation-error-4.html [ Failure ]
crbug.com/594639 external/wpt/html/semantics/scripting-1/the-script-element/module/specifier-error.html [ Failure ]

# This test has a failure console message with specific performance
# numbers so a consistent baseline cannot be added. This test could be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({allow_uncaught_exception: true});

window.log = [];

window.addEventListener("error", ev => log.push(ev.error));
Expand Down
19 changes: 19 additions & 0 deletions third_party/WebKit/Source/core/dom/ModuleScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@

namespace blink {

const char* ModuleInstantiationStateToString(ModuleInstantiationState state) {
switch (state) {
case ModuleInstantiationState::kUninstantiated:
return "uninstantiated";
case ModuleInstantiationState::kInstantiated:
return "instantiated";
case ModuleInstantiationState::kErrored:
return "errored";
}
NOTREACHED();
return "";
}

ModuleScript* ModuleScript::Create(
const String& source_text,
Modulator* modulator,
Expand Down Expand Up @@ -144,7 +157,13 @@ ScriptModule ModuleScript::Record() const {
return ScriptModule(isolate, record_.NewLocal(isolate));
}

bool ModuleScript::HasEmptyRecord() const {
return record_.IsEmpty();
}

void ModuleScript::SetErrorAndClearRecord(ScriptValue error) {
DVLOG(1) << "ModuleScript[" << this << "]::SetErrorAndClearRecord()";

// https://html.spec.whatwg.org/multipage/webappapis.html#error-a-module-script
// Step 1. Assert: script's state is not "errored".
DCHECK_NE(state_, ModuleInstantiationState::kErrored);
Expand Down
3 changes: 3 additions & 0 deletions third_party/WebKit/Source/core/dom/ModuleScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ enum class ModuleInstantiationState {
kInstantiated,
};

const char* ModuleInstantiationStateToString(ModuleInstantiationState);

// ModuleScript is a model object for the "module script" spec concept.
// https://html.spec.whatwg.org/multipage/webappapis.html#module-script
class CORE_EXPORT ModuleScript final : public Script, public TraceWrapperBase {
Expand Down Expand Up @@ -54,6 +56,7 @@ class CORE_EXPORT ModuleScript final : public Script, public TraceWrapperBase {
~ModuleScript() override = default;

ScriptModule Record() const;
bool HasEmptyRecord() const;
const KURL& BaseURL() const { return base_url_; }

ModuleInstantiationState State() const { return state_; }
Expand Down
Loading

0 comments on commit e123c91

Please sign in to comment.