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

Side by Side Diff: src/objects.cc

Issue 2707263002: [api] Fix DescriptorInterceptor with access check. (Closed)
Patch Set: Check access if needed. Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | test/cctest/test-api-interceptors.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 6875 matching lines...) Expand 10 before | Expand all | Expand 10 after
6886 LookupIterator it = LookupIterator::PropertyOrElement( 6886 LookupIterator it = LookupIterator::PropertyOrElement(
6887 isolate, object, key, &success, LookupIterator::OWN); 6887 isolate, object, key, &success, LookupIterator::OWN);
6888 DCHECK(success); // ...so creating a LookupIterator can't fail. 6888 DCHECK(success); // ...so creating a LookupIterator can't fail.
6889 return GetOwnPropertyDescriptor(&it, desc); 6889 return GetOwnPropertyDescriptor(&it, desc);
6890 } 6890 }
6891 6891
6892 namespace { 6892 namespace {
6893 6893
6894 Maybe<bool> GetPropertyDescriptorWithInterceptor(LookupIterator* it, 6894 Maybe<bool> GetPropertyDescriptorWithInterceptor(LookupIterator* it,
6895 PropertyDescriptor* desc) { 6895 PropertyDescriptor* desc) {
6896 if (it->state() == LookupIterator::INTERCEPTOR) { 6896 bool has_access = true;
6897 if (it->state() == LookupIterator::ACCESS_CHECK) {
6898 has_access = it->HasAccess() || JSObject::AllCanRead(it);
6899 it->Next();
6900 }
6901
6902 if (has_access && it->state() == LookupIterator::INTERCEPTOR) {
6897 Isolate* isolate = it->isolate(); 6903 Isolate* isolate = it->isolate();
6898 Handle<InterceptorInfo> interceptor = it->GetInterceptor(); 6904 Handle<InterceptorInfo> interceptor = it->GetInterceptor();
6899 if (!interceptor->descriptor()->IsUndefined(isolate)) { 6905 if (!interceptor->descriptor()->IsUndefined(isolate)) {
6900 Handle<Object> result; 6906 Handle<Object> result;
6901 Handle<JSObject> holder = it->GetHolder<JSObject>(); 6907 Handle<JSObject> holder = it->GetHolder<JSObject>();
6902 6908
6903 Handle<Object> receiver = it->GetReceiver(); 6909 Handle<Object> receiver = it->GetReceiver();
6904 if (!receiver->IsJSReceiver()) { 6910 if (!receiver->IsJSReceiver()) {
6905 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 6911 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
6906 isolate, receiver, Object::ConvertReceiver(isolate, receiver), 6912 isolate, receiver, Object::ConvertReceiver(isolate, receiver),
(...skipping 23 matching lines...) Expand all
6930 Utils::ApiCheck( 6936 Utils::ApiCheck(
6931 PropertyDescriptor::ToPropertyDescriptor(isolate, result, desc), 6937 PropertyDescriptor::ToPropertyDescriptor(isolate, result, desc),
6932 it->IsElement() ? "v8::IndexedPropertyDescriptorCallback" 6938 it->IsElement() ? "v8::IndexedPropertyDescriptorCallback"
6933 : "v8::NamedPropertyDescriptorCallback", 6939 : "v8::NamedPropertyDescriptorCallback",
6934 "Invalid property descriptor."); 6940 "Invalid property descriptor.");
6935 6941
6936 return Just(true); 6942 return Just(true);
6937 } 6943 }
6938 } 6944 }
6939 } 6945 }
6946 it->Restart();
6940 return Just(false); 6947 return Just(false);
6941 } 6948 }
6942 } // namespace 6949 } // namespace
6943 6950
6944 // ES6 9.1.5.1 6951 // ES6 9.1.5.1
6945 // Returns true on success, false if the property didn't exist, nothing if 6952 // Returns true on success, false if the property didn't exist, nothing if
6946 // an exception was thrown. 6953 // an exception was thrown.
6947 // static 6954 // static
6948 Maybe<bool> JSReceiver::GetOwnPropertyDescriptor(LookupIterator* it, 6955 Maybe<bool> JSReceiver::GetOwnPropertyDescriptor(LookupIterator* it,
6949 PropertyDescriptor* desc) { 6956 PropertyDescriptor* desc) {
(...skipping 13132 matching lines...) Expand 10 before | Expand all | Expand 10 after
20082 // depend on this. 20089 // depend on this.
20083 return DICTIONARY_ELEMENTS; 20090 return DICTIONARY_ELEMENTS;
20084 } 20091 }
20085 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20092 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20086 return kind; 20093 return kind;
20087 } 20094 }
20088 } 20095 }
20089 20096
20090 } // namespace internal 20097 } // namespace internal
20091 } // namespace v8 20098 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api-interceptors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698