Commit 3612350c authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

Supports property deletion with ENTER_V8_NO_SCRIPT.

As Blink needs a way to delete a property without running a script,
make Object::Delete use ENTER_V8_NO_SCRIPT if the receiver object is
not a JSProxy.  Also makes Object::DeletePrivate use
ENTER_V8_NO_SCRIPT, too.

Bug: chromium:728583
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: Ib37959764b99a68d730d1bbc6dba410106d4f452
Reviewed-on: https://chromium-review.googlesource.com/608348Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47779}
parent 1aead19c
......@@ -4827,29 +4827,49 @@ Maybe<bool> v8::Object::SetIntegrityLevel(Local<Context> context,
Maybe<bool> v8::Object::Delete(Local<Context> context, Local<Value> key) {
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, Delete, Nothing<bool>(), i::HandleScope);
auto self = Utils::OpenHandle(this);
auto key_obj = Utils::OpenHandle(*key);
Maybe<bool> result =
i::Runtime::DeleteObjectProperty(isolate, self, key_obj, i::SLOPPY);
has_pending_exception = result.IsNothing();
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return result;
if (self->IsJSProxy()) {
ENTER_V8(isolate, context, Object, Delete, Nothing<bool>(), i::HandleScope);
Maybe<bool> result =
i::Runtime::DeleteObjectProperty(isolate, self, key_obj, i::SLOPPY);
has_pending_exception = result.IsNothing();
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return result;
} else {
// If it's not a JSProxy, i::Runtime::DeleteObjectProperty should never run
// a script.
ENTER_V8_NO_SCRIPT(isolate, context, Object, Delete, Nothing<bool>(),
i::HandleScope);
Maybe<bool> result =
i::Runtime::DeleteObjectProperty(isolate, self, key_obj, i::SLOPPY);
has_pending_exception = result.IsNothing();
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return result;
}
}
bool v8::Object::Delete(v8::Local<Value> key) {
auto context = ContextFromHeapObject(Utils::OpenHandle(this));
return Delete(context, key).FromMaybe(false);
}
Maybe<bool> v8::Object::DeletePrivate(Local<Context> context,
Local<Private> key) {
return Delete(context, Local<Value>(reinterpret_cast<Value*>(*key)));
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
// In case of private symbols, i::Runtime::DeleteObjectProperty does not run
// any author script.
ENTER_V8_NO_SCRIPT(isolate, context, Object, Delete, Nothing<bool>(),
i::HandleScope);
auto self = Utils::OpenHandle(this);
auto key_obj = Utils::OpenHandle(*key);
Maybe<bool> result =
i::Runtime::DeleteObjectProperty(isolate, self, key_obj, i::SLOPPY);
has_pending_exception = result.IsNothing();
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return result;
}
Maybe<bool> v8::Object::Has(Local<Context> context, Local<Value> key) {
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, Has, Nothing<bool>(), i::HandleScope);
......
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