Re-adjust access failure log messages for %GetOwnProperty.

R=mstarzinger@chromium.org
BUG=

Review URL: https://codereview.chromium.org/11418062

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13006 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
rossberg@chromium.org 2012-11-19 17:59:11 +00:00
parent 1f71c3c34e
commit 75cb024609

View File

@ -1002,22 +1002,29 @@ static bool CheckGenericAccess(
} }
static bool CheckElementAccess( enum AccessCheckResult {
ACCESS_FORBIDDEN,
ACCESS_ALLOWED,
ACCESS_ABSENT
};
static AccessCheckResult CheckElementAccess(
JSObject* obj, JSObject* obj,
uint32_t index, uint32_t index,
v8::AccessType access_type) { v8::AccessType access_type) {
// TODO(1095): we should traverse hidden prototype hierachy as well. // TODO(1095): we should traverse hidden prototype hierachy as well.
if (CheckGenericAccess( if (CheckGenericAccess(
obj, obj, index, access_type, &Isolate::MayIndexedAccess)) { obj, obj, index, access_type, &Isolate::MayIndexedAccess)) {
return true; return ACCESS_ALLOWED;
} }
obj->GetIsolate()->ReportFailedAccessCheck(obj, access_type); obj->GetIsolate()->ReportFailedAccessCheck(obj, access_type);
return false; return ACCESS_FORBIDDEN;
} }
static bool CheckPropertyAccess( static AccessCheckResult CheckPropertyAccess(
JSObject* obj, JSObject* obj,
String* name, String* name,
v8::AccessType access_type) { v8::AccessType access_type) {
@ -1029,9 +1036,10 @@ static bool CheckPropertyAccess(
LookupResult lookup(obj->GetIsolate()); LookupResult lookup(obj->GetIsolate());
obj->LocalLookup(name, &lookup); obj->LocalLookup(name, &lookup);
if (!lookup.IsProperty()) return ACCESS_ABSENT;
if (CheckGenericAccess<Object*>( if (CheckGenericAccess<Object*>(
obj, lookup.holder(), name, access_type, &Isolate::MayNamedAccess)) { obj, lookup.holder(), name, access_type, &Isolate::MayNamedAccess)) {
return true; return ACCESS_ALLOWED;
} }
// Access check callback denied the access, but some properties // Access check callback denied the access, but some properties
@ -1041,7 +1049,7 @@ static bool CheckPropertyAccess(
switch (lookup.type()) { switch (lookup.type()) {
case CALLBACKS: case CALLBACKS:
if (CheckAccessException(lookup.GetCallbackObject(), access_type)) { if (CheckAccessException(lookup.GetCallbackObject(), access_type)) {
return true; return ACCESS_ALLOWED;
} }
break; break;
case INTERCEPTOR: case INTERCEPTOR:
@ -1050,7 +1058,7 @@ static bool CheckPropertyAccess(
lookup.holder()->LookupRealNamedProperty(name, &lookup); lookup.holder()->LookupRealNamedProperty(name, &lookup);
if (lookup.IsProperty() && lookup.IsPropertyCallbacks()) { if (lookup.IsProperty() && lookup.IsPropertyCallbacks()) {
if (CheckAccessException(lookup.GetCallbackObject(), access_type)) { if (CheckAccessException(lookup.GetCallbackObject(), access_type)) {
return true; return ACCESS_ALLOWED;
} }
} }
break; break;
@ -1059,7 +1067,7 @@ static bool CheckPropertyAccess(
} }
obj->GetIsolate()->ReportFailedAccessCheck(obj, access_type); obj->GetIsolate()->ReportFailedAccessCheck(obj, access_type);
return false; return ACCESS_FORBIDDEN;
} }
@ -1080,6 +1088,14 @@ static MaybeObject* GetOwnProperty(Isolate* isolate,
Handle<JSObject> obj, Handle<JSObject> obj,
Handle<String> name) { Handle<String> name) {
Heap* heap = isolate->heap(); Heap* heap = isolate->heap();
// Due to some WebKit tests, we want to make sure that we do not log
// more than one access failure here.
switch (CheckPropertyAccess(*obj, *name, v8::ACCESS_HAS)) {
case ACCESS_FORBIDDEN: return heap->false_value();
case ACCESS_ALLOWED: break;
case ACCESS_ABSENT: return heap->undefined_value();
}
PropertyAttributes attrs = obj->GetLocalPropertyAttribute(*name); PropertyAttributes attrs = obj->GetLocalPropertyAttribute(*name);
if (attrs == ABSENT) return heap->undefined_value(); if (attrs == ABSENT) return heap->undefined_value();
AccessorPair* accessors = obj->GetLocalPropertyAccessorPair(*name); AccessorPair* accessors = obj->GetLocalPropertyAccessorPair(*name);