Commit eeadb48c authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

Supports Object::DefineOwnProperty with ENTER_V8_NO_SCRIPT.

As Blink needs a way to define a property without running a script,
make Object::DefineOwnProperty use ENTER_V8_NO_SCRIPT if the
receiver object is not a JSProxy.  Quite similar to
https://crrev.com/c/v8/v8/+/608348

Bug: chromium:728583, chromedriver:1978, chromium:762385
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: If358bf0d156139c456de369ac04da2be6e626143
Reviewed-on: https://chromium-review.googlesource.com/651949
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47862}
parent ccb5f5a3
......@@ -4500,8 +4500,6 @@ Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context,
v8::Local<Value> value,
v8::PropertyAttribute attributes) {
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, DefineOwnProperty, Nothing<bool>(),
i::HandleScope);
i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
......@@ -4511,11 +4509,25 @@ Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context,
desc.set_enumerable(!(attributes & v8::DontEnum));
desc.set_configurable(!(attributes & v8::DontDelete));
desc.set_value(value_obj);
if (self->IsJSProxy()) {
ENTER_V8(isolate, context, Object, DefineOwnProperty, Nothing<bool>(),
i::HandleScope);
Maybe<bool> success = i::JSReceiver::DefineOwnProperty(
isolate, self, key_obj, &desc, i::Object::DONT_THROW);
// Even though we said DONT_THROW, there might be accessors that do throw.
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return success;
} else {
// If it's not a JSProxy, i::JSReceiver::DefineOwnProperty should never run
// a script.
ENTER_V8_NO_SCRIPT(isolate, context, Object, DefineOwnProperty,
Nothing<bool>(), i::HandleScope);
Maybe<bool> success = i::JSReceiver::DefineOwnProperty(
isolate, self, key_obj, &desc, i::Object::DONT_THROW);
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return success;
}
}
Maybe<bool> v8::Object::DefineProperty(v8::Local<v8::Context> context,
......
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