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

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

Issue 2555653002: [WIP Prototype] ES6 https://html.spec.whatwg.org/#fetch-a-single-module-script implementation (Closed)
Patch Set: ModuleTreeLinkerTest.fetchTreeInstantiationFailure 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 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/V8Binding.h"
8 #include "bindings/core/v8/V8ThrowException.h"
9 #include "core/dom/Modulator.h"
10 #include "core/dom/ScriptModuleResolver.h"
11
7 namespace blink { 12 namespace blink {
8 13
9 void ModuleScript::SetInstantiationError(v8::Isolate* isolate, 14 void ModuleScript::SetInstantiationErrorAndClearRecord(ScriptValue error) {
10 v8::Local<v8::Value> error) {
11 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated); 15 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated);
12 instantiation_state_ = ModuleInstantiationState::kErrored; 16 instantiation_state_ = ModuleInstantiationState::kErrored;
13 17
14 DCHECK(!error.IsEmpty()); 18 DCHECK(!error.IsEmpty());
15 instantiation_error_.Set(isolate, error); 19 {
20 ScriptState::Scope scope(error.GetScriptState());
21 instantiation_error_.Set(error.GetIsolate(), error.V8Value());
22 }
23
24 record_ = ScriptModule();
16 } 25 }
17 26
18 void ModuleScript::SetInstantiationSuccess() { 27 void ModuleScript::SetInstantiationSuccess() {
19 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated); 28 DCHECK_EQ(instantiation_state_, ModuleInstantiationState::kUninstantiated);
20 instantiation_state_ = ModuleInstantiationState::kInstantiated; 29 instantiation_state_ = ModuleInstantiationState::kInstantiated;
21 } 30 }
22 31
23 DEFINE_TRACE(ModuleScript) { 32 DEFINE_TRACE(ModuleScript) {
24 visitor->Trace(settings_object_); 33 visitor->Trace(settings_object_);
25 Script::Trace(visitor); 34 Script::Trace(visitor);
26 } 35 }
27 DEFINE_TRACE_WRAPPERS(ModuleScript) { 36 DEFINE_TRACE_WRAPPERS(ModuleScript) {
28 visitor->TraceWrappers(instantiation_error_); 37 visitor->TraceWrappers(instantiation_error_);
29 } 38 }
30 39
31 bool ModuleScript::IsEmpty() const { 40 bool ModuleScript::IsEmpty() const {
32 return false; 41 return false;
33 } 42 }
34 43
35 bool ModuleScript::CheckMIMETypeBeforeRunScript(Document* context_document, 44 bool ModuleScript::CheckMIMETypeBeforeRunScript(Document* context_document,
36 const SecurityOrigin*) const { 45 const SecurityOrigin*) const {
37 // We don't check MIME type here because we check the MIME type in 46 // We don't check MIME type here because we check the MIME type in
38 // ModuleScriptLoader::WasModuleLoadSuccessful(). 47 // ModuleScriptLoader::WasModuleLoadSuccessful().
39 return true; 48 return true;
40 } 49 }
41 50
42 void ModuleScript::RunScript(LocalFrame* frame, const SecurityOrigin*) const { 51 void ModuleScript::RunScript(LocalFrame* frame, const SecurityOrigin*) const {
43 // TODO(hiroshige): Implement this once Modulator::ExecuteModule() is landed. 52 fprintf(stderr, "ModuleScript: isNull=%d state=%d\n", record_.IsNull(),
44 NOTREACHED(); 53 InstantiationState());
54
55 settings_object_->ExecuteModule(this);
45 } 56 }
46 57
47 String ModuleScript::InlineSourceTextForCSP() const { 58 String ModuleScript::InlineSourceTextForCSP() const {
48 // Currently we don't support inline module scripts. 59 // Currently we don't support inline module scripts.
49 // TODO(hiroshige): Implement this. 60 // TODO(hiroshige): Implement this.
50 NOTREACHED(); 61 NOTREACHED();
51 return String(); 62 return String();
52 } 63 }
53 64
54 } // namespace blink 65 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698