Commit 0981e91a authored by Igor Sheludko's avatar Igor Sheludko Committed by V8 LUCI CQ

[runtime] Fix handling of interceptors

Bug: chromium:1309225
Change-Id: Ifd62639a2aa18b633e7cf36632677ee16c977afd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3548458Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79613}
parent d7966ecd
...@@ -2511,6 +2511,12 @@ Maybe<bool> Object::SetPropertyInternal(LookupIterator* it, ...@@ -2511,6 +2511,12 @@ Maybe<bool> Object::SetPropertyInternal(LookupIterator* it,
Maybe<bool> result = Maybe<bool> result =
JSObject::SetPropertyWithInterceptor(it, should_throw, value); JSObject::SetPropertyWithInterceptor(it, should_throw, value);
if (result.IsNothing() || result.FromJust()) return result; if (result.IsNothing() || result.FromJust()) return result;
// Assuming that the callback have side effects, we use
// Object::SetSuperProperty() which works properly regardless on
// whether the property was present on the receiver or not when
// storing to the receiver.
// Proceed lookup from the next state.
it->Next();
} else { } else {
Maybe<PropertyAttributes> maybe_attributes = Maybe<PropertyAttributes> maybe_attributes =
JSObject::GetPropertyAttributesWithInterceptor(it); JSObject::GetPropertyAttributesWithInterceptor(it);
...@@ -2531,10 +2537,8 @@ Maybe<bool> Object::SetPropertyInternal(LookupIterator* it, ...@@ -2531,10 +2537,8 @@ Maybe<bool> Object::SetPropertyInternal(LookupIterator* it,
// property to the receiver. // property to the receiver.
it->NotFound(); it->NotFound();
} }
return Object::SetSuperProperty(it, value, store_origin,
should_throw);
} }
break; return Object::SetSuperProperty(it, value, store_origin, should_throw);
} }
case LookupIterator::ACCESSOR: { case LookupIterator::ACCESSOR: {
......
...@@ -5833,10 +5833,10 @@ void DatabaseGetter(Local<Name> name, ...@@ -5833,10 +5833,10 @@ void DatabaseGetter(Local<Name> name,
const v8::PropertyCallbackInfo<Value>& info) { const v8::PropertyCallbackInfo<Value>& info) {
ApiTestFuzzer::Fuzz(); ApiTestFuzzer::Fuzz();
auto context = info.GetIsolate()->GetCurrentContext(); auto context = info.GetIsolate()->GetCurrentContext();
Local<v8::Object> db = info.Holder() v8::MaybeLocal<Value> maybe_db =
->GetRealNamedProperty(context, v8_str("db")) info.Holder()->GetRealNamedProperty(context, v8_str("db"));
.ToLocalChecked() if (maybe_db.IsEmpty()) return;
.As<v8::Object>(); Local<v8::Object> db = maybe_db.ToLocalChecked().As<v8::Object>();
if (!db->Has(context, name).FromJust()) return; if (!db->Has(context, name).FromJust()) return;
info.GetReturnValue().Set(db->Get(context, name).ToLocalChecked()); info.GetReturnValue().Set(db->Get(context, name).ToLocalChecked());
} }
......
...@@ -174,8 +174,8 @@ TEST_F(InterceptorLoggingTest, DispatchTest) { ...@@ -174,8 +174,8 @@ TEST_F(InterceptorLoggingTest, DispatchTest) {
EXPECT_EQ(Run("obj.foo"), "named getter"); EXPECT_EQ(Run("obj.foo"), "named getter");
EXPECT_EQ(Run("obj[42]"), "indexed getter"); EXPECT_EQ(Run("obj[42]"), "indexed getter");
EXPECT_EQ(Run("obj.foo = null"), "named setter"); EXPECT_EQ(Run("obj.foo = null"), "named setter, named descriptor");
EXPECT_EQ(Run("obj[42] = null"), "indexed setter"); EXPECT_EQ(Run("obj[42] = null"), "indexed setter, indexed descriptor");
EXPECT_EQ(Run("Object.getOwnPropertyDescriptor(obj, 'foo')"), EXPECT_EQ(Run("Object.getOwnPropertyDescriptor(obj, 'foo')"),
"named descriptor"); "named descriptor");
......
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