| Index: gin/shell_runner.cc
|
| diff --git a/gin/shell_runner.cc b/gin/shell_runner.cc
|
| index eccee9f69ca355f47255e1f25d2c3973f496a0af..0e534e4af027ca1cacb0e950ee0d6167dae5253e 100644
|
| --- a/gin/shell_runner.cc
|
| +++ b/gin/shell_runner.cc
|
| @@ -65,11 +65,13 @@ ShellRunner::~ShellRunner() {
|
|
|
| void ShellRunner::Run(const std::string& source,
|
| const std::string& resource_name) {
|
| - TryCatch try_catch;
|
| v8::Isolate* isolate = GetContextHolder()->isolate();
|
| - v8::Local<Script> script = Script::Compile(
|
| - StringToV8(isolate, source), StringToV8(isolate, resource_name));
|
| - if (try_catch.HasCaught()) {
|
| + TryCatch try_catch(isolate);
|
| + v8::ScriptOrigin origin(StringToV8(isolate, resource_name));
|
| + auto maybe_script = Script::Compile(GetContextHolder()->context(),
|
| + StringToV8(isolate, source), &origin);
|
| + v8::Local<Script> script;
|
| + if (!maybe_script.ToLocal(&script)) {
|
| delegate_->UnhandledException(this, try_catch);
|
| return;
|
| }
|
| @@ -81,13 +83,15 @@ v8::Local<v8::Value> ShellRunner::Call(v8::Local<v8::Function> function,
|
| v8::Local<v8::Value> receiver,
|
| int argc,
|
| v8::Local<v8::Value> argv[]) {
|
| - TryCatch try_catch;
|
| + TryCatch try_catch(GetContextHolder()->isolate());
|
| delegate_->WillRunScript(this);
|
|
|
| - v8::Local<v8::Value> result = function->Call(receiver, argc, argv);
|
| + auto maybe_result =
|
| + function->Call(GetContextHolder()->context(), receiver, argc, argv);
|
|
|
| delegate_->DidRunScript(this);
|
| - if (try_catch.HasCaught())
|
| + v8::Local<v8::Value> result;
|
| + if (!maybe_result.ToLocal(&result))
|
| delegate_->UnhandledException(this, try_catch);
|
|
|
| return result;
|
| @@ -98,13 +102,14 @@ ContextHolder* ShellRunner::GetContextHolder() {
|
| }
|
|
|
| void ShellRunner::Run(v8::Local<Script> script) {
|
| - TryCatch try_catch;
|
| + TryCatch try_catch(GetContextHolder()->isolate());
|
| delegate_->WillRunScript(this);
|
|
|
| - script->Run();
|
| + auto maybe = script->Run(GetContextHolder()->context());
|
|
|
| delegate_->DidRunScript(this);
|
| - if (try_catch.HasCaught()) {
|
| + v8::Local<v8::Value> result;
|
| + if (!maybe.ToLocal(&result)) {
|
| delegate_->UnhandledException(this, try_catch);
|
| }
|
| }
|
|
|