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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptModule.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 "bindings/core/v8/ScriptModule.h" 5 #include "bindings/core/v8/ScriptModule.h"
6 6
7 #include "bindings/core/v8/V8Binding.h" 7 #include "bindings/core/v8/V8Binding.h"
8 #include "core/dom/Modulator.h" 8 #include "core/dom/Modulator.h"
9 #include "core/dom/ScriptModuleResolver.h" 9 #include "core/dom/ScriptModuleResolver.h"
10 10
(...skipping 24 matching lines...) Expand all
35 DCHECK(try_catch.HasCaught()); 35 DCHECK(try_catch.HasCaught());
36 return ScriptModule(); 36 return ScriptModule();
37 } 37 }
38 DCHECK(!try_catch.HasCaught()); 38 DCHECK(!try_catch.HasCaught());
39 return ScriptModule(isolate, module); 39 return ScriptModule(isolate, module);
40 } 40 }
41 41
42 ScriptValue ScriptModule::Instantiate(ScriptState* script_state) { 42 ScriptValue ScriptModule::Instantiate(ScriptState* script_state) {
43 v8::Isolate* isolate = script_state->GetIsolate(); 43 v8::Isolate* isolate = script_state->GetIsolate();
44 v8::TryCatch try_catch(isolate); 44 v8::TryCatch try_catch(isolate);
45 try_catch.SetVerbose(true);
45 46
46 DCHECK(!IsNull()); 47 DCHECK(!IsNull());
47 v8::Local<v8::Context> context = script_state->GetContext(); 48 v8::Local<v8::Context> context = script_state->GetContext();
48 bool success = module_->NewLocal(script_state->GetIsolate()) 49 bool success = module_->NewLocal(script_state->GetIsolate())
49 ->Instantiate(context, &ResolveModuleCallback); 50 ->Instantiate(context, &ResolveModuleCallback);
50 if (!success) { 51 if (!success) {
51 DCHECK(try_catch.HasCaught()); 52 DCHECK(try_catch.HasCaught());
52 return ScriptValue(script_state, try_catch.Exception()); 53 return ScriptValue(script_state, try_catch.Exception());
53 } 54 }
54 DCHECK(!try_catch.HasCaught()); 55 DCHECK(!try_catch.HasCaught());
55 return ScriptValue(); 56 return ScriptValue();
56 } 57 }
57 58
58 void ScriptModule::Evaluate(ScriptState* script_state) { 59 void ScriptModule::Evaluate(ScriptState* script_state) const {
59 v8::Isolate* isolate = script_state->GetIsolate(); 60 v8::Isolate* isolate = script_state->GetIsolate();
60 v8::TryCatch try_catch(isolate); 61 v8::TryCatch try_catch(isolate);
61 try_catch.SetVerbose(true); 62 try_catch.SetVerbose(true);
62 v8::Local<v8::Value> result; 63 v8::Local<v8::Value> result;
63 if (!V8Call( 64 if (!V8Call(
64 V8ScriptRunner::EvaluateModule(module_->NewLocal(isolate), 65 V8ScriptRunner::EvaluateModule(module_->NewLocal(isolate),
65 script_state->GetContext(), isolate), 66 script_state->GetContext(), isolate),
66 result, try_catch)) { 67 result, try_catch)) {
67 // TODO(adamk): report error 68 // TODO(adamk): report error
68 } 69 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if (resolved.IsNull()) { 102 if (resolved.IsNull()) {
102 DCHECK(exception_state.HadException()); 103 DCHECK(exception_state.HadException());
103 return v8::MaybeLocal<v8::Module>(); 104 return v8::MaybeLocal<v8::Module>();
104 } 105 }
105 106
106 DCHECK(!exception_state.HadException()); 107 DCHECK(!exception_state.HadException());
107 return v8::MaybeLocal<v8::Module>(resolved.module_->NewLocal(isolate)); 108 return v8::MaybeLocal<v8::Module>(resolved.module_->NewLocal(isolate));
108 } 109 }
109 110
110 } // namespace blink 111 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698