diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 2bcdd281cacd..749bcf0736f5 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -1401,7 +1401,9 @@ void Initialize(v8::Local exports, void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); - dict.Set("App", atom::api::App::GetConstructor(isolate)->GetFunction()); + dict.Set("App", atom::api::App::GetConstructor(isolate) + ->GetFunction(context) + .ToLocalChecked()); dict.Set("app", atom::api::App::Create(isolate)); #if defined(OS_MACOSX) auto browser = base::Unretained(Browser::Get()); diff --git a/atom/browser/api/atom_api_auto_updater.cc b/atom/browser/api/atom_api_auto_updater.cc index 3bee34247e92..694f9beb54a8 100644 --- a/atom/browser/api/atom_api_auto_updater.cc +++ b/atom/browser/api/atom_api_auto_updater.cc @@ -147,7 +147,9 @@ void Initialize(v8::Local exports, v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.Set("autoUpdater", AutoUpdater::Create(isolate)); - dict.Set("AutoUpdater", AutoUpdater::GetConstructor(isolate)->GetFunction()); + dict.Set("AutoUpdater", AutoUpdater::GetConstructor(isolate) + ->GetFunction(context) + .ToLocalChecked()); } } // namespace diff --git a/atom/browser/api/atom_api_browser_view.cc b/atom/browser/api/atom_api_browser_view.cc index 6c9578c61eaf..27e012a8e7fa 100644 --- a/atom/browser/api/atom_api_browser_view.cc +++ b/atom/browser/api/atom_api_browser_view.cc @@ -159,8 +159,9 @@ void Initialize(v8::Local exports, v8::Isolate* isolate = context->GetIsolate(); BrowserView::SetConstructor(isolate, base::Bind(&BrowserView::New)); - mate::Dictionary browser_view( - isolate, BrowserView::GetConstructor(isolate)->GetFunction()); + mate::Dictionary browser_view(isolate, BrowserView::GetConstructor(isolate) + ->GetFunction(context) + .ToLocalChecked()); browser_view.SetMethod("fromId", &mate::TrackableObject::FromWeakMapID); browser_view.SetMethod("getAllViews", diff --git a/atom/browser/api/atom_api_debugger.cc b/atom/browser/api/atom_api_debugger.cc index 536f8af682c3..616cc827a231 100644 --- a/atom/browser/api/atom_api_debugger.cc +++ b/atom/browser/api/atom_api_debugger.cc @@ -194,7 +194,9 @@ void Initialize(v8::Local exports, void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary(isolate, exports) - .Set("Debugger", Debugger::GetConstructor(isolate)->GetFunction()); + .Set("Debugger", Debugger::GetConstructor(isolate) + ->GetFunction(context) + .ToLocalChecked()); } } // namespace diff --git a/atom/browser/api/atom_api_download_item.cc b/atom/browser/api/atom_api_download_item.cc index 67b2ae05ce1a..0db325237c9f 100644 --- a/atom/browser/api/atom_api_download_item.cc +++ b/atom/browser/api/atom_api_download_item.cc @@ -244,8 +244,9 @@ void Initialize(v8::Local exports, void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary(isolate, exports) - .Set("DownloadItem", - atom::api::DownloadItem::GetConstructor(isolate)->GetFunction()); + .Set("DownloadItem", atom::api::DownloadItem::GetConstructor(isolate) + ->GetFunction(context) + .ToLocalChecked()); } } // namespace diff --git a/atom/browser/api/atom_api_in_app_purchase.cc b/atom/browser/api/atom_api_in_app_purchase.cc index af25f73181a8..1f6718ba53ed 100644 --- a/atom/browser/api/atom_api_in_app_purchase.cc +++ b/atom/browser/api/atom_api_in_app_purchase.cc @@ -132,8 +132,9 @@ void Initialize(v8::Local exports, v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.Set("inAppPurchase", InAppPurchase::Create(isolate)); - dict.Set("InAppPurchase", - InAppPurchase::GetConstructor(isolate)->GetFunction()); + dict.Set("InAppPurchase", InAppPurchase::GetConstructor(isolate) + ->GetFunction(context) + .ToLocalChecked()); #endif } diff --git a/atom/browser/api/atom_api_menu.cc b/atom/browser/api/atom_api_menu.cc index f6000dbb5c50..78c84310da31 100644 --- a/atom/browser/api/atom_api_menu.cc +++ b/atom/browser/api/atom_api_menu.cc @@ -233,7 +233,9 @@ void Initialize(v8::Local exports, Menu::SetConstructor(isolate, base::Bind(&Menu::New)); mate::Dictionary dict(isolate, exports); - dict.Set("Menu", Menu::GetConstructor(isolate)->GetFunction()); + dict.Set( + "Menu", + Menu::GetConstructor(isolate)->GetFunction(context).ToLocalChecked()); #if defined(OS_MACOSX) dict.SetMethod("setApplicationMenu", &Menu::SetApplicationMenu); dict.SetMethod("sendActionToFirstResponder", diff --git a/atom/browser/api/atom_api_net.cc b/atom/browser/api/atom_api_net.cc index 77393c92565b..fc037fb9d8db 100644 --- a/atom/browser/api/atom_api_net.cc +++ b/atom/browser/api/atom_api_net.cc @@ -31,7 +31,9 @@ void Net::BuildPrototype(v8::Isolate* isolate, } v8::Local Net::URLRequest(v8::Isolate* isolate) { - return URLRequest::GetConstructor(isolate)->GetFunction(); + return URLRequest::GetConstructor(isolate) + ->GetFunction(isolate->GetCurrentContext()) + .ToLocalChecked(); } } // namespace api @@ -53,7 +55,8 @@ void Initialize(v8::Local exports, mate::Dictionary dict(isolate, exports); dict.Set("net", Net::Create(isolate)); - dict.Set("Net", Net::GetConstructor(isolate)->GetFunction()); + dict.Set("Net", + Net::GetConstructor(isolate)->GetFunction(context).ToLocalChecked()); } } // namespace diff --git a/atom/browser/api/atom_api_notification.cc b/atom/browser/api/atom_api_notification.cc index 81272fc180bd..0ce0d065bd58 100644 --- a/atom/browser/api/atom_api_notification.cc +++ b/atom/browser/api/atom_api_notification.cc @@ -263,8 +263,9 @@ void Initialize(v8::Local exports, Notification::SetConstructor(isolate, base::Bind(&Notification::New)); mate::Dictionary dict(isolate, exports); - dict.Set("Notification", - Notification::GetConstructor(isolate)->GetFunction()); + dict.Set("Notification", Notification::GetConstructor(isolate) + ->GetFunction(context) + .ToLocalChecked()); dict.SetMethod("isSupported", &Notification::IsSupported); } diff --git a/atom/browser/api/atom_api_power_monitor.cc b/atom/browser/api/atom_api_power_monitor.cc index 8145a09501fc..bf199270781f 100644 --- a/atom/browser/api/atom_api_power_monitor.cc +++ b/atom/browser/api/atom_api_power_monitor.cc @@ -141,8 +141,9 @@ void Initialize(v8::Local exports, v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.Set("powerMonitor", PowerMonitor::Create(isolate)); - dict.Set("PowerMonitor", - PowerMonitor::GetConstructor(isolate)->GetFunction()); + dict.Set("PowerMonitor", PowerMonitor::GetConstructor(isolate) + ->GetFunction(context) + .ToLocalChecked()); } } // namespace diff --git a/atom/browser/api/atom_api_screen.cc b/atom/browser/api/atom_api_screen.cc index 65a11eed0cce..65b9e3e11f1d 100644 --- a/atom/browser/api/atom_api_screen.cc +++ b/atom/browser/api/atom_api_screen.cc @@ -164,7 +164,9 @@ void Initialize(v8::Local exports, v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.Set("screen", Screen::Create(isolate)); - dict.Set("Screen", Screen::GetConstructor(isolate)->GetFunction()); + dict.Set( + "Screen", + Screen::GetConstructor(isolate)->GetFunction(context).ToLocalChecked()); } } // namespace diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index 65069d4904e8..e73b1e52c839 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -805,8 +805,12 @@ void Initialize(v8::Local exports, void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); - dict.Set("Session", Session::GetConstructor(isolate)->GetFunction()); - dict.Set("Cookies", Cookies::GetConstructor(isolate)->GetFunction()); + dict.Set( + "Session", + Session::GetConstructor(isolate)->GetFunction(context).ToLocalChecked()); + dict.Set( + "Cookies", + Cookies::GetConstructor(isolate)->GetFunction(context).ToLocalChecked()); dict.SetMethod("fromPartition", &FromPartition); } diff --git a/atom/browser/api/atom_api_system_preferences.cc b/atom/browser/api/atom_api_system_preferences.cc index abc3dd4f38ee..4943fd52d57a 100644 --- a/atom/browser/api/atom_api_system_preferences.cc +++ b/atom/browser/api/atom_api_system_preferences.cc @@ -121,8 +121,9 @@ void Initialize(v8::Local exports, v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.Set("systemPreferences", SystemPreferences::Create(isolate)); - dict.Set("SystemPreferences", - SystemPreferences::GetConstructor(isolate)->GetFunction()); + dict.Set("SystemPreferences", SystemPreferences::GetConstructor(isolate) + ->GetFunction(context) + .ToLocalChecked()); } } // namespace diff --git a/atom/browser/api/atom_api_top_level_window.cc b/atom/browser/api/atom_api_top_level_window.cc index cd6ef374218b..b42b0b996f84 100644 --- a/atom/browser/api/atom_api_top_level_window.cc +++ b/atom/browser/api/atom_api_top_level_window.cc @@ -1179,8 +1179,9 @@ void Initialize(v8::Local exports, v8::Isolate* isolate = context->GetIsolate(); TopLevelWindow::SetConstructor(isolate, base::Bind(&TopLevelWindow::New)); - mate::Dictionary constructor( - isolate, TopLevelWindow::GetConstructor(isolate)->GetFunction()); + mate::Dictionary constructor(isolate, TopLevelWindow::GetConstructor(isolate) + ->GetFunction(context) + .ToLocalChecked()); constructor.SetMethod("fromId", &mate::TrackableObject::FromWeakMapID); constructor.SetMethod("getAllWindows", diff --git a/atom/browser/api/atom_api_tray.cc b/atom/browser/api/atom_api_tray.cc index a750a575316e..625a828a5ed5 100644 --- a/atom/browser/api/atom_api_tray.cc +++ b/atom/browser/api/atom_api_tray.cc @@ -254,7 +254,9 @@ void Initialize(v8::Local exports, Tray::SetConstructor(isolate, base::Bind(&Tray::New)); mate::Dictionary dict(isolate, exports); - dict.Set("Tray", Tray::GetConstructor(isolate)->GetFunction()); + dict.Set( + "Tray", + Tray::GetConstructor(isolate)->GetFunction(context).ToLocalChecked()); } } // namespace diff --git a/atom/browser/api/atom_api_view.cc b/atom/browser/api/atom_api_view.cc index af907d5abccb..4ef46cf3e712 100644 --- a/atom/browser/api/atom_api_view.cc +++ b/atom/browser/api/atom_api_view.cc @@ -76,8 +76,9 @@ void Initialize(v8::Local exports, v8::Isolate* isolate = context->GetIsolate(); View::SetConstructor(isolate, base::Bind(&View::New)); - mate::Dictionary constructor(isolate, - View::GetConstructor(isolate)->GetFunction()); + mate::Dictionary constructor( + isolate, + View::GetConstructor(isolate)->GetFunction(context).ToLocalChecked()); mate::Dictionary dict(isolate, exports); dict.Set("View", constructor); diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 93b2ccb361b3..00f74f97a8f0 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -2284,7 +2284,9 @@ void Initialize(v8::Local exports, void* priv) { v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); - dict.Set("WebContents", WebContents::GetConstructor(isolate)->GetFunction()); + dict.Set("WebContents", WebContents::GetConstructor(isolate) + ->GetFunction(context) + .ToLocalChecked()); dict.SetMethod("create", &WebContents::Create); dict.SetMethod("fromId", &mate::TrackableObject::FromWeakMapID); dict.SetMethod("getAllWebContents", diff --git a/atom/browser/api/event_emitter.cc b/atom/browser/api/event_emitter.cc index 4b4c0caa7261..4558514d9fe5 100644 --- a/atom/browser/api/event_emitter.cc +++ b/atom/browser/api/event_emitter.cc @@ -35,7 +35,8 @@ v8::Local CreateEventObject(v8::Isolate* isolate) { } return v8::Local::New(isolate, event_template) - ->NewInstance(); + ->NewInstance(isolate->GetCurrentContext()) + .ToLocalChecked(); } } // namespace diff --git a/atom/common/api/constructor.h b/atom/common/api/constructor.h index a4e4332f0a55..d14d760337ee 100644 --- a/atom/common/api/constructor.h +++ b/atom/common/api/constructor.h @@ -25,7 +25,7 @@ v8::Local CreateConstructor(v8::Isolate* isolate, isolate, base::Bind(&mate::internal::InvokeNew, func)); templ->InstanceTemplate()->SetInternalFieldCount(1); T::BuildPrototype(isolate, templ); - return templ->GetFunction(); + return templ->GetFunction(isolate->GetCurrentContext()).ToLocalChecked(); } } // namespace mate diff --git a/atom/common/native_mate_converters/callback.cc b/atom/common/native_mate_converters/callback.cc index 7a1a855f6a7b..dc3300e43985 100644 --- a/atom/common/native_mate_converters/callback.cc +++ b/atom/common/native_mate_converters/callback.cc @@ -43,16 +43,19 @@ void CallTranslater(v8::Local external, mate::Arguments* args) { // Whether the callback should only be called for once. v8::Isolate* isolate = args->isolate(); - bool one_time = state->Has(mate::StringToSymbol(isolate, "oneTime")); + auto context = isolate->GetCurrentContext(); + bool one_time = + state->Has(context, mate::StringToSymbol(isolate, "oneTime")).ToChecked(); // Check if the callback has already been called. if (one_time) { auto called_symbol = mate::StringToSymbol(isolate, "called"); - if (state->Has(called_symbol)) { + if (state->Has(context, called_symbol).ToChecked()) { args->ThrowError("callback can only be called for once"); return; } else { - state->Set(called_symbol, v8::Boolean::New(isolate, true)); + state->Set(context, called_symbol, v8::Boolean::New(isolate, true)) + .ToChecked(); } } @@ -130,9 +133,10 @@ v8::Local CreateFunctionFromTranslater(v8::Isolate* isolate, Dictionary state = mate::Dictionary::CreateEmpty(isolate); if (one_time) state.Set("oneTime", true); - return BindFunctionWith(isolate, isolate->GetCurrentContext(), - call_translater->GetFunction(), - holder->handle.Get(isolate), state.GetHandle()); + auto context = isolate->GetCurrentContext(); + return BindFunctionWith( + isolate, context, call_translater->GetFunction(context).ToLocalChecked(), + holder->handle.Get(isolate), state.GetHandle()); } // func.bind(func, arg1). diff --git a/atom/common/native_mate_converters/callback.h b/atom/common/native_mate_converters/callback.h index 3fea5b9f3106..50008990c2fd 100644 --- a/atom/common/native_mate_converters/callback.h +++ b/atom/common/native_mate_converters/callback.h @@ -55,8 +55,10 @@ struct V8FunctionInvoker(ArgTypes...)> { v8::Local context = holder->CreationContext(); v8::Context::Scope context_scope(context); std::vector> args{ConvertToV8(isolate, raw)...}; - v8::Local ret(holder->Call( - holder, args.size(), args.empty() ? nullptr : &args.front())); + v8::Local ret(holder + ->Call(context, holder, args.size(), + args.empty() ? nullptr : &args.front()) + .ToLocalChecked()); return handle_scope.Escape(ret); } }; @@ -76,7 +78,10 @@ struct V8FunctionInvoker { v8::Local context = holder->CreationContext(); v8::Context::Scope context_scope(context); std::vector> args{ConvertToV8(isolate, raw)...}; - holder->Call(holder, args.size(), args.empty() ? nullptr : &args.front()); + holder + ->Call(context, holder, args.size(), + args.empty() ? nullptr : &args.front()) + .ToLocalChecked(); } }; diff --git a/atom/common/native_mate_converters/v8_value_converter.cc b/atom/common/native_mate_converters/v8_value_converter.cc index c8d85b0583d0..73bfe5a96a8c 100644 --- a/atom/common/native_mate_converters/v8_value_converter.cc +++ b/atom/common/native_mate_converters/v8_value_converter.cc @@ -331,8 +331,9 @@ base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state, v8::Local toISOString = date->Get(v8::String::NewFromUtf8(isolate, "toISOString")); if (toISOString->IsFunction()) { - v8::Local result = - toISOString.As()->Call(val, 0, nullptr); + v8::Local result = toISOString.As() + ->Call(context, val, 0, nullptr) + .ToLocalChecked(); if (!result.IsEmpty()) { v8::String::Utf8Value utf8(isolate, result->ToString(context).ToLocalChecked()); diff --git a/atom/renderer/api/atom_api_spell_check_client.cc b/atom/renderer/api/atom_api_spell_check_client.cc index 329884bbfebc..cf3da3629d6c 100644 --- a/atom/renderer/api/atom_api_spell_check_client.cc +++ b/atom/renderer/api/atom_api_spell_check_client.cc @@ -211,10 +211,11 @@ void SpellCheckClient::SpellCheckWords( v8::Local templ = mate::CreateFunctionTemplate( isolate_, base::Bind(&SpellCheckClient::OnSpellCheckDone, AsWeakPtr())); + auto context = isolate_->GetCurrentContext(); v8::Local args[] = {mate::ConvertToV8(isolate_, words), - templ->GetFunction()}; + templ->GetFunction(context).ToLocalChecked()}; // Call javascript with the words and the callback function - scope.spell_check_->Call(scope.provider_, 2, args); + scope.spell_check_->Call(context, scope.provider_, 2, args).ToLocalChecked(); } // Returns whether or not the given string is a contraction. diff --git a/atom/renderer/api/atom_api_web_frame.cc b/atom/renderer/api/atom_api_web_frame.cc index 3f1a89d1fc0b..5daea0da6391 100644 --- a/atom/renderer/api/atom_api_web_frame.cc +++ b/atom/renderer/api/atom_api_web_frame.cc @@ -222,7 +222,9 @@ int WebFrame::GetWebFrameId(v8::Local content_window) { void WebFrame::SetSpellCheckProvider(mate::Arguments* args, const std::string& language, v8::Local provider) { - if (!provider->Has(mate::StringToV8(args->isolate(), "spellCheck"))) { + auto context = args->isolate()->GetCurrentContext(); + if (!provider->Has(context, mate::StringToV8(args->isolate(), "spellCheck")) + .ToChecked()) { args->ThrowError("\"spellCheck\" has to be defined"); return; } @@ -541,7 +543,9 @@ void Initialize(v8::Local exports, v8::Isolate* isolate = context->GetIsolate(); mate::Dictionary dict(isolate, exports); dict.Set("webFrame", WebFrame::Create(isolate)); - dict.Set("WebFrame", WebFrame::GetConstructor(isolate)->GetFunction()); + dict.Set( + "WebFrame", + WebFrame::GetConstructor(isolate)->GetFunction(context).ToLocalChecked()); } } // namespace diff --git a/native_mate/native_mate/dictionary.h b/native_mate/native_mate/dictionary.h index 63a135059760..1eece77c5a2a 100644 --- a/native_mate/native_mate/dictionary.h +++ b/native_mate/native_mate/dictionary.h @@ -106,7 +106,9 @@ class Dictionary { bool SetMethod(const base::StringPiece& key, const T& callback) { return GetHandle()->Set( StringToV8(isolate_, key), - CallbackTraits::CreateTemplate(isolate_, callback)->GetFunction()); + CallbackTraits::CreateTemplate(isolate_, callback) + ->GetFunction(isolate_->GetCurrentContext()) + .ToLocalChecked()); } bool Delete(const base::StringPiece& key) { diff --git a/native_mate/native_mate/wrappable.cc b/native_mate/native_mate/wrappable.cc index 3d5ce44ac0a8..8b1f73d6baec 100644 --- a/native_mate/native_mate/wrappable.cc +++ b/native_mate/native_mate/wrappable.cc @@ -39,7 +39,8 @@ void WrappableBase::InitWith(v8::Isolate* isolate, // Call object._init if we have one. v8::Local init; if (Dictionary(isolate, wrapper).Get("_init", &init)) - init->Call(wrapper, 0, nullptr); + init->Call(isolate->GetCurrentContext(), wrapper, 0, nullptr) + .ToLocalChecked(); AfterInit(isolate); }