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

Unified Diff: third_party/WebKit/Source/core/dom/ModuleScript.cpp

Issue 2842923002: Support Inline module script (Closed)
Patch Set: Rebase 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
Index: third_party/WebKit/Source/core/dom/ModuleScript.cpp
diff --git a/third_party/WebKit/Source/core/dom/ModuleScript.cpp b/third_party/WebKit/Source/core/dom/ModuleScript.cpp
index bd911121cc17913fda9ebeac47216eabb09c04be..20cdc1eba221736e3e485153ccc7f38d5a2e2d9f 100644
--- a/third_party/WebKit/Source/core/dom/ModuleScript.cpp
+++ b/third_party/WebKit/Source/core/dom/ModuleScript.cpp
@@ -33,11 +33,12 @@ ModuleScript* ModuleScript::Create(
if (result.IsNull())
return nullptr;
- return CreateInternal(modulator, result, base_url, nonce, parser_state,
- credentials_mode);
+ return CreateInternal(source_text, modulator, result, base_url, nonce,
+ parser_state, credentials_mode);
}
ModuleScript* ModuleScript::CreateInternal(
+ const String& source_text,
Modulator* modulator,
ScriptModule result,
const KURL& base_url,
@@ -52,8 +53,10 @@ ModuleScript* ModuleScript::CreateInternal(
// Step 10. Set script's parser state to the parser state.
// Step 11. Set script's credentials mode to the credentials mode provided.
// Step 12. Return script.
- ModuleScript* module_script = new ModuleScript(
- modulator, result, base_url, nonce, parser_state, credentials_mode);
+ // [not specced] |source_text| is saved for CSP checks.
+ ModuleScript* module_script =
+ new ModuleScript(modulator, result, base_url, nonce, parser_state,
+ credentials_mode, source_text);
// Step 5, a part of ParseModule(): Passing script as the last parameter
// here ensures result.[[HostDefined]] will be script.
@@ -69,8 +72,9 @@ ModuleScript* ModuleScript::CreateForTest(
const String& nonce,
ParserDisposition parser_state,
WebURLRequest::FetchCredentialsMode credentials_mode) {
- return CreateInternal(modulator, record, base_url, nonce, parser_state,
- credentials_mode);
+ String dummy_source_text = "";
+ return CreateInternal(dummy_source_text, modulator, record, base_url, nonce,
+ parser_state, credentials_mode);
}
void ModuleScript::SetInstantiationErrorAndClearRecord(ScriptValue error) {
@@ -125,10 +129,7 @@ void ModuleScript::RunScript(LocalFrame* frame, const SecurityOrigin*) const {
}
String ModuleScript::InlineSourceTextForCSP() const {
- // Currently we don't support inline module scripts.
- // TODO(hiroshige): Implement this.
- NOTREACHED();
- return String();
+ return source_text_;
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/ModuleScript.h ('k') | third_party/WebKit/Source/core/dom/ScriptLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698