diff --git a/atom/common/native_mate_converters/v8_value_converter.cc b/atom/common/native_mate_converters/v8_value_converter.cc index 2596fb4ed18..fbc410bdcb7 100644 --- a/atom/common/native_mate_converters/v8_value_converter.cc +++ b/atom/common/native_mate_converters/v8_value_converter.cc @@ -273,7 +273,9 @@ v8::Local V8ValueConverter::ToArrayBuffer( return v8::Uint8Array::New(array_buffer, 0, length); } - mate::Dictionary buffer_class(isolate, buffer_value->ToObject()); + mate::Dictionary buffer_class( + isolate, + buffer_value->ToObject(isolate->GetCurrentContext()).ToLocalChecked()); v8::Local from_value; if (!buffer_class.Get("from", &from_value) || !from_value->IsFunction()) { return v8::Uint8Array::New(array_buffer, 0, length); @@ -302,21 +304,23 @@ base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state, if (val->IsNull()) return std::make_unique().release(); + auto context = isolate->GetCurrentContext(); + if (val->IsBoolean()) - return new base::Value(val->ToBoolean()->Value()); + return new base::Value(val->ToBoolean(context).ToLocalChecked()->Value()); if (val->IsInt32()) - return new base::Value(val->ToInt32()->Value()); + return new base::Value(val->ToInt32(context).ToLocalChecked()->Value()); if (val->IsNumber()) { - double val_as_double = val->ToNumber()->Value(); + double val_as_double = val->ToNumber(context).ToLocalChecked()->Value(); if (!std::isfinite(val_as_double)) return nullptr; return new base::Value(val_as_double); } if (val->IsString()) { - v8::String::Utf8Value utf8(val->ToString()); + v8::String::Utf8Value utf8(val->ToString(context).ToLocalChecked()); return new base::Value(std::string(*utf8, utf8.length())); } @@ -332,7 +336,7 @@ base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state, v8::Local result = toISOString.As()->Call(val, 0, nullptr); if (!result.IsEmpty()) { - v8::String::Utf8Value utf8(result->ToString()); + v8::String::Utf8Value utf8(result->ToString(context).ToLocalChecked()); return new base::Value(std::string(*utf8, utf8.length())); } } @@ -341,8 +345,10 @@ base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state, if (val->IsRegExp()) { if (!reg_exp_allowed_) // JSON.stringify converts to an object. - return FromV8Object(val->ToObject(), state, isolate); - return new base::Value(*v8::String::Utf8Value(val->ToString())); + return FromV8Object(val->ToObject(context).ToLocalChecked(), + state, isolate); + return new base::Value( + *v8::String::Utf8Value(val->ToString(context).ToLocalChecked())); } // v8::Value doesn't have a ToArray() method for some reason. @@ -353,7 +359,8 @@ base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state, if (!function_allowed_) // JSON.stringify refuses to convert function(){}. return nullptr; - return FromV8Object(val->ToObject(), state, isolate); + return FromV8Object(val->ToObject(context).ToLocalChecked(), + state, isolate); } if (node::Buffer::HasInstance(val)) { @@ -361,7 +368,8 @@ base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state, } if (val->IsObject()) { - return FromV8Object(val->ToObject(), state, isolate); + return FromV8Object(val->ToObject(context).ToLocalChecked(), + state, isolate); } LOG(ERROR) << "Unexpected v8 value type encountered."; @@ -443,7 +451,8 @@ base::Value* V8ValueConverter::FromV8Object(v8::Local val, continue; } - v8::String::Utf8Value name_utf8(key->ToString()); + v8::String::Utf8Value name_utf8( + key->ToString(isolate->GetCurrentContext()).ToLocalChecked()); v8::TryCatch try_catch(isolate); v8::Local child_v8 = val->Get(key);