Skip to content

Commit adc0215

Browse files
verwaestCommit bot
authored andcommitted
Propagate not-found on proxy target to GetRealNamedProperty
BUG=v8:4932 LOG=n Review-Url: https://codereview.chromium.org/1929853002 Cr-Commit-Position: refs/heads/master@{#35846}
1 parent 47ffcac commit adc0215

3 files changed

Lines changed: 28 additions & 6 deletions

File tree

src/objects.cc

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,14 @@ MaybeHandle<Object> Object::GetProperty(LookupIterator* it) {
720720
case LookupIterator::NOT_FOUND:
721721
case LookupIterator::TRANSITION:
722722
UNREACHABLE();
723-
case LookupIterator::JSPROXY:
724-
return JSProxy::GetProperty(it->isolate(), it->GetHolder<JSProxy>(),
725-
it->GetName(), it->GetReceiver());
723+
case LookupIterator::JSPROXY: {
724+
bool was_found;
725+
MaybeHandle<Object> result =
726+
JSProxy::GetProperty(it->isolate(), it->GetHolder<JSProxy>(),
727+
it->GetName(), it->GetReceiver(), &was_found);
728+
if (!was_found) it->NotFound();
729+
return result;
730+
}
726731
case LookupIterator::INTERCEPTOR: {
727732
bool done;
728733
Handle<Object> result;
@@ -762,7 +767,9 @@ MaybeHandle<Object> Object::GetProperty(LookupIterator* it) {
762767
MaybeHandle<Object> JSProxy::GetProperty(Isolate* isolate,
763768
Handle<JSProxy> proxy,
764769
Handle<Name> name,
765-
Handle<Object> receiver) {
770+
Handle<Object> receiver,
771+
bool* was_found) {
772+
*was_found = true;
766773
if (receiver->IsJSGlobalObject()) {
767774
THROW_NEW_ERROR(
768775
isolate,
@@ -795,7 +802,9 @@ MaybeHandle<Object> JSProxy::GetProperty(Isolate* isolate,
795802
// 7.a Return target.[[Get]](P, Receiver).
796803
LookupIterator it =
797804
LookupIterator::PropertyOrElement(isolate, receiver, name, target);
798-
return Object::GetProperty(&it);
805+
MaybeHandle<Object> result = Object::GetProperty(&it);
806+
*was_found = it.IsFound();
807+
return result;
799808
}
800809
// 8. Let trapResult be ? Call(trap, handler, «target, P, Receiver»).
801810
Handle<Object> trap_result;

src/objects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9682,7 +9682,7 @@ class JSProxy: public JSReceiver {
96829682
// ES6 9.5.8
96839683
MUST_USE_RESULT static MaybeHandle<Object> GetProperty(
96849684
Isolate* isolate, Handle<JSProxy> proxy, Handle<Name> name,
9685-
Handle<Object> receiver);
9685+
Handle<Object> receiver, bool* was_found);
96869686

96879687
// ES6 9.5.9
96889688
MUST_USE_RESULT static Maybe<bool> SetProperty(Handle<JSProxy> proxy,

test/cctest/test-api.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12870,6 +12870,19 @@ THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) {
1287012870
CHECK(try_catch.HasCaught());
1287112871
try_catch.Reset();
1287212872
CHECK(result.IsEmpty());
12873+
12874+
Local<Object> target = CompileRun("({})").As<Object>();
12875+
Local<Object> handler = CompileRun("({})").As<Object>();
12876+
Local<v8::Proxy> proxy =
12877+
v8::Proxy::New(context.local(), target, handler).ToLocalChecked();
12878+
12879+
result = target->GetRealNamedProperty(context.local(), v8_str("f"));
12880+
CHECK(!try_catch.HasCaught());
12881+
CHECK(result.IsEmpty());
12882+
12883+
result = proxy->GetRealNamedProperty(context.local(), v8_str("f"));
12884+
CHECK(!try_catch.HasCaught());
12885+
CHECK(result.IsEmpty());
1287312886
}
1287412887

1287512888

0 commit comments

Comments
 (0)