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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptModule.cpp

Issue 2798533002: [ES6 modules] ScriptModule::compile() exceptions are handled via isolate's MessageListener (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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ScriptModule.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 namespace blink { 11 namespace blink {
12 12
13 ScriptModule::ScriptModule(v8::Isolate* isolate, v8::Local<v8::Module> module) 13 ScriptModule::ScriptModule(v8::Isolate* isolate, v8::Local<v8::Module> module)
14 : m_module(SharedPersistent<v8::Module>::create(module, isolate)) {} 14 : m_module(SharedPersistent<v8::Module>::create(module, isolate)) {}
15 15
16 ScriptModule::~ScriptModule() {} 16 ScriptModule::~ScriptModule() {}
17 17
18 ScriptModule ScriptModule::compile(v8::Isolate* isolate, 18 ScriptModule ScriptModule::compile(v8::Isolate* isolate,
19 const String& source, 19 const String& source,
20 const String& fileName) { 20 const String& fileName) {
21 v8::TryCatch tryCatch(isolate); 21 v8::TryCatch tryCatch(isolate);
22 tryCatch.SetVerbose(true); 22 tryCatch.SetVerbose(true);
23 v8::Local<v8::Module> module; 23 v8::Local<v8::Module> module;
24 if (!v8Call(V8ScriptRunner::compileModule(isolate, source, fileName), module, 24 if (!v8Call(V8ScriptRunner::compileModule(isolate, source, fileName), module,
25 tryCatch)) { 25 tryCatch)) {
26 // TODO(adamk): Signal failure somehow. 26 // Compilation error is not used in Blink implementaion logic.
27 return ScriptModule(isolate, module); 27 // Note: Error message is delivered to user (e.g. console) by message
28 // listeners set on v8::Isolate. See V8Initializer::initalizeMainThread().
29 // TODO(nhiroki): Revisit this when supporting modules on worker threads.
30 DCHECK(tryCatch.HasCaught());
31 return ScriptModule();
28 } 32 }
33 DCHECK(!tryCatch.HasCaught());
29 return ScriptModule(isolate, module); 34 return ScriptModule(isolate, module);
30 } 35 }
31 36
32 ScriptValue ScriptModule::instantiate(ScriptState* scriptState) { 37 ScriptValue ScriptModule::instantiate(ScriptState* scriptState) {
33 v8::Isolate* isolate = scriptState->isolate(); 38 v8::Isolate* isolate = scriptState->isolate();
34 v8::TryCatch tryCatch(isolate); 39 v8::TryCatch tryCatch(isolate);
35 40
36 DCHECK(!isNull()); 41 DCHECK(!isNull());
37 v8::Local<v8::Context> context = scriptState->context(); 42 v8::Local<v8::Context> context = scriptState->context();
38 bool success = m_module->newLocal(scriptState->isolate()) 43 bool success = m_module->newLocal(scriptState->isolate())
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 if (resolved.isNull()) { 78 if (resolved.isNull()) {
74 DCHECK(exceptionState.hadException()); 79 DCHECK(exceptionState.hadException());
75 return v8::MaybeLocal<v8::Module>(); 80 return v8::MaybeLocal<v8::Module>();
76 } 81 }
77 82
78 DCHECK(!exceptionState.hadException()); 83 DCHECK(!exceptionState.hadException());
79 return v8::MaybeLocal<v8::Module>(resolved.m_module->newLocal(isolate)); 84 return v8::MaybeLocal<v8::Module>(resolved.m_module->newLocal(isolate));
80 } 85 }
81 86
82 } // namespace blink 87 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ScriptModule.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698