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

Side by Side Diff: third_party/WebKit/Source/core/dom/ModuleScript.cpp

Issue 2842923002: Support Inline module script (Closed)
Patch Set: Rebase Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/ModuleScript.h" 5 #include "core/dom/ModuleScript.h"
6 6
7 #include "bindings/core/v8/ScriptState.h" 7 #include "bindings/core/v8/ScriptState.h"
8 #include "bindings/core/v8/ScriptValue.h" 8 #include "bindings/core/v8/ScriptValue.h"
9 #include "bindings/core/v8/V8BindingForCore.h" 9 #include "bindings/core/v8/V8BindingForCore.h"
10 #include "v8/include/v8.h" 10 #include "v8/include/v8.h"
(...skipping 20 matching lines...) Expand all
31 // Step 6: "...return null, and abort these steps." 31 // Step 6: "...return null, and abort these steps."
32 if (result.IsNull()) 32 if (result.IsNull())
33 return nullptr; 33 return nullptr;
34 // Step 7. Set script's module record to result. 34 // Step 7. Set script's module record to result.
35 // Step 8. Set script's base URL to the script base URL provided. 35 // Step 8. Set script's base URL to the script base URL provided.
36 // Step 9. Set script's cryptographic nonce to the cryptographic nonce 36 // Step 9. Set script's cryptographic nonce to the cryptographic nonce
37 // provided. 37 // provided.
38 // Step 10. Set script's parser state to the parser state. 38 // Step 10. Set script's parser state to the parser state.
39 // Step 11. Set script's credentials mode to the credentials mode provided. 39 // Step 11. Set script's credentials mode to the credentials mode provided.
40 // Step 12. Return script. 40 // Step 12. Return script.
41 // [not specced] |source_text| is saved for CSP checks.
41 return new ModuleScript(modulator, result, base_url, nonce, parser_state, 42 return new ModuleScript(modulator, result, base_url, nonce, parser_state,
42 credentials_mode); 43 credentials_mode, source_text);
43 } 44 }
44 45
45 void ModuleScript::SetInstantiationErrorAndClearRecord(ScriptValue error) { 46 void ModuleScript::SetInstantiationErrorAndClearRecord(ScriptValue error) {
46 // Implements Step 7.1 of: 47 // Implements Step 7.1 of:
47 // https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-scri pt-graph-fetching-procedure 48 // https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-scri pt-graph-fetching-procedure
48 49
49 // "set script's instantiation state to "errored", ..." 50 // "set script's instantiation state to "errored", ..."
50 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated); 51 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated);
51 instantiation_state_ = ModuleInstantiationState::kErrored; 52 instantiation_state_ = ModuleInstantiationState::kErrored;
52 53
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // We don't check MIME type here because we check the MIME type in 91 // We don't check MIME type here because we check the MIME type in
91 // ModuleScriptLoader::WasModuleLoadSuccessful(). 92 // ModuleScriptLoader::WasModuleLoadSuccessful().
92 return true; 93 return true;
93 } 94 }
94 95
95 void ModuleScript::RunScript(LocalFrame* frame, const SecurityOrigin*) const { 96 void ModuleScript::RunScript(LocalFrame* frame, const SecurityOrigin*) const {
96 settings_object_->ExecuteModule(this); 97 settings_object_->ExecuteModule(this);
97 } 98 }
98 99
99 String ModuleScript::InlineSourceTextForCSP() const { 100 String ModuleScript::InlineSourceTextForCSP() const {
100 // Currently we don't support inline module scripts. 101 return source_text_;
101 // TODO(hiroshige): Implement this.
102 NOTREACHED();
103 return String();
104 } 102 }
105 103
106 } // namespace blink 104 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698