Commit e8e79c7c authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[cleanup] Fix deprecated use of Value::ToObject

Value::ToObject(Isolate*) is deprecated because it doesn't force the
user to check whether a result was actually returned.

This changes MessageChannel::Create to use the Context version and calls
FromMaybe on the result. This will return an empty Local if ToObject
throws which would happen if its input was undefined or null
(https://tc39.github.io/ecma262/#sec-toobject).

Bug: v8:7279, v8:8238
Change-Id: I51c48350d1c50507d2dff6ef5c5a97cf2b03ddb5
Reviewed-on: https://chromium-review.googlesource.com/c/1344100
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610646}
parent d976aac9
...@@ -80,11 +80,13 @@ MessageChannel* MessageChannel::Create(PepperPluginInstanceImpl* instance, ...@@ -80,11 +80,13 @@ MessageChannel* MessageChannel::Create(PepperPluginInstanceImpl* instance,
v8::Persistent<v8::Object>* result) { v8::Persistent<v8::Object>* result) {
MessageChannel* message_channel = new MessageChannel(instance); MessageChannel* message_channel = new MessageChannel(instance);
v8::HandleScope handle_scope(instance->GetIsolate()); v8::HandleScope handle_scope(instance->GetIsolate());
v8::Context::Scope context_scope(instance->GetMainWorldContext()); v8::Local<v8::Context> context = instance->GetMainWorldContext();
v8::Context::Scope context_scope(context);
gin::Handle<MessageChannel> handle = gin::Handle<MessageChannel> handle =
gin::CreateHandle(instance->GetIsolate(), message_channel); gin::CreateHandle(instance->GetIsolate(), message_channel);
v8::MaybeLocal<v8::Object> object = handle.ToV8()->ToObject(context);
result->Reset(instance->GetIsolate(), result->Reset(instance->GetIsolate(),
handle.ToV8()->ToObject(instance->GetIsolate())); object.FromMaybe(v8::Local<v8::Object>()));
return message_channel; return message_channel;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment