Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: src/runtime.cc

Issue 260253002: Proposed fix for Object.observe access checks (Closed) Base URL: https://chromium.googlesource.com/external/v8.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index c91c3f908fcb02a713455ca99cd383670d6f5450..923705294e4b04e5ad40df99cbfe678e18e5bf66 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -14913,26 +14913,19 @@ RUNTIME_FUNCTION(Runtime_IsAccessAllowedForObserver) {
CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0);
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1);
RUNTIME_ASSERT(object->map()->is_access_check_needed());
+ // FIXME: Remove key arg
CONVERT_ARG_HANDLE_CHECKED(Object, key, 2);
- SaveContext save(isolate);
- isolate->set_context(observer->context());
- if (!isolate->MayNamedAccess(
- object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) {
- return isolate->heap()->false_value();
- }
- bool access_allowed = false;
- uint32_t index = 0;
- if (key->ToArrayIndex(&index) ||
- (key->IsString() && String::cast(*key)->AsArrayIndex(&index))) {
- access_allowed =
- isolate->MayIndexedAccess(object, index, v8::ACCESS_GET) &&
- isolate->MayIndexedAccess(object, index, v8::ACCESS_HAS);
+ Handle<Context> observer_context(observer->context()->native_context(), isolate);
+ Handle<Context> object_context;
+ Handle<Object> constructor(object->map()->constructor(), isolate);
+ if (!constructor->IsJSFunction()) {
+ object_context = handle(JSFunction::cast(*object)->context()->native_context(), isolate);
} else {
- access_allowed =
- isolate->MayNamedAccess(object, key, v8::ACCESS_GET) &&
- isolate->MayNamedAccess(object, key, v8::ACCESS_HAS);
+ object_context = handle(JSFunction::cast(*constructor)->context()->native_context(), isolate);
}
- return isolate->heap()->ToBoolean(access_allowed);
+ return isolate->heap()->ToBoolean(
+ *object_context == *observer_context ||
+ object_context->security_token() == observer_context->security_token());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698