From: dcarney Date: Tue, 24 Mar 2015 16:09:59 +0000 (-0700) Subject: fix attribute lookup for all can read indexed interceptors X-Git-Tag: upstream/4.7.83~3620 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a3b7c8320ef169188efcd0a7c4c3ad5f4c380681;p=platform%2Fupstream%2Fv8.git fix attribute lookup for all can read indexed interceptors R=verwaest@chromium.org BUG= Review URL: https://codereview.chromium.org/1034513002 Cr-Commit-Position: refs/heads/master@{#27420} --- diff --git a/src/objects.cc b/src/objects.cc index 14217aac7..23f2eb39d 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -617,7 +617,7 @@ Maybe JSObject::GetElementAttributesWithFailedAccessCheck( FindIndexedAllCanReadHolder(isolate, holder, where_to_start); if (!all_can_read_holder.ToHandle(&holder)) break; auto result = - JSObject::GetElementAttributeFromInterceptor(object, receiver, index); + JSObject::GetElementAttributeFromInterceptor(holder, receiver, index); if (isolate->has_scheduled_exception()) break; if (result.IsJust() && result.FromJust() != ABSENT) return result; where_to_start = PrototypeIterator::START_AT_PROTOTYPE; diff --git a/test/cctest/test-api-interceptors.cc b/test/cctest/test-api-interceptors.cc index 13e511a21..0b060d1e6 100644 --- a/test/cctest/test-api-interceptors.cc +++ b/test/cctest/test-api-interceptors.cc @@ -3024,15 +3024,27 @@ THREADED_TEST(NamedAllCanReadInterceptor) { access_check_data.result = true; ExpectInt32("checked.whatever", 17); - CHECK_EQ(1, access_check_data.count); + CHECK(!CompileRun("Object.getOwnPropertyDescriptor(checked, 'whatever')") + ->IsUndefined()); + CHECK_EQ(2, access_check_data.count); access_check_data.result = false; ExpectInt32("checked.whatever", intercept_data_0.value); - CHECK_EQ(2, access_check_data.count); + { + v8::TryCatch try_catch(isolate); + CompileRun("Object.getOwnPropertyDescriptor(checked, 'whatever')"); + CHECK(try_catch.HasCaught()); + } + CHECK_EQ(4, access_check_data.count); intercept_data_1.should_intercept = true; ExpectInt32("checked.whatever", intercept_data_1.value); - CHECK_EQ(3, access_check_data.count); + { + v8::TryCatch try_catch(isolate); + CompileRun("Object.getOwnPropertyDescriptor(checked, 'whatever')"); + CHECK(try_catch.HasCaught()); + } + CHECK_EQ(6, access_check_data.count); } @@ -3090,15 +3102,23 @@ THREADED_TEST(IndexedAllCanReadInterceptor) { access_check_data.result = true; ExpectInt32("checked[15]", 17); - CHECK_EQ(1, access_check_data.count); + CHECK(!CompileRun("Object.getOwnPropertyDescriptor(checked, '15')") + ->IsUndefined()); + CHECK_EQ(3, access_check_data.count); access_check_data.result = false; ExpectInt32("checked[15]", intercept_data_0.value); - CHECK_EQ(2, access_check_data.count); + // Note: this should throw but without a LookupIterator it's complicated. + CHECK(!CompileRun("Object.getOwnPropertyDescriptor(checked, '15')") + ->IsUndefined()); + CHECK_EQ(6, access_check_data.count); intercept_data_1.should_intercept = true; ExpectInt32("checked[15]", intercept_data_1.value); - CHECK_EQ(3, access_check_data.count); + // Note: this should throw but without a LookupIterator it's complicated. + CHECK(!CompileRun("Object.getOwnPropertyDescriptor(checked, '15')") + ->IsUndefined()); + CHECK_EQ(9, access_check_data.count); }