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

Side by Side Diff: test/cctest/test-object-observe.cc

Issue 1410883006: Plumb accessing context through to access control callbacks (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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 | « test/cctest/test-api-interceptors.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 LocalContext env; 981 LocalContext env;
982 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {}; 982 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
983 global_use_counts = use_counts; 983 global_use_counts = use_counts;
984 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback); 984 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
985 CompileRun("var obj = {}"); 985 CompileRun("var obj = {}");
986 CompileRun("Object.getNotifier(obj)"); 986 CompileRun("Object.getNotifier(obj)");
987 CHECK_EQ(1, use_counts[v8::Isolate::kObjectObserve]); 987 CHECK_EQ(1, use_counts[v8::Isolate::kObjectObserve]);
988 } 988 }
989 989
990 990
991 static bool NamedAccessCheckAlwaysAllow(Local<v8::Object> global, 991 static bool NamedAccessCheckAlwaysAllow(Local<v8::Context> accessing_context,
992 Local<v8::Value> name, 992 Local<v8::Object> accessed_object) {
993 v8::AccessType type,
994 Local<Value> data) {
995 return true; 993 return true;
996 } 994 }
997 995
998 996
999 TEST(DisallowObserveAccessCheckedObject) { 997 TEST(DisallowObserveAccessCheckedObject) {
1000 v8::Isolate* isolate = CcTest::isolate(); 998 v8::Isolate* isolate = CcTest::isolate();
1001 v8::HandleScope scope(isolate); 999 v8::HandleScope scope(isolate);
1002 LocalContext env; 1000 LocalContext env;
1003 v8::Local<v8::ObjectTemplate> object_template = 1001 v8::Local<v8::ObjectTemplate> object_template =
1004 v8::ObjectTemplate::New(isolate); 1002 v8::ObjectTemplate::New(isolate);
1005 object_template->SetAccessCheckCallbacks(NamedAccessCheckAlwaysAllow, NULL); 1003 object_template->SetAccessCheckCallback(NamedAccessCheckAlwaysAllow);
1006 Local<Object> new_instance = 1004 Local<Object> new_instance =
1007 object_template->NewInstance( 1005 object_template->NewInstance(
1008 v8::Isolate::GetCurrent()->GetCurrentContext()) 1006 v8::Isolate::GetCurrent()->GetCurrentContext())
1009 .ToLocalChecked(); 1007 .ToLocalChecked();
1010 env->Global() 1008 env->Global()
1011 ->Set(v8::Isolate::GetCurrent()->GetCurrentContext(), v8_str("obj"), 1009 ->Set(v8::Isolate::GetCurrent()->GetCurrentContext(), v8_str("obj"),
1012 new_instance) 1010 new_instance)
1013 .FromJust(); 1011 .FromJust();
1014 v8::TryCatch try_catch(isolate); 1012 v8::TryCatch try_catch(isolate);
1015 CompileRun("Object.observe(obj, function(){})"); 1013 CompileRun("Object.observe(obj, function(){})");
1016 CHECK(try_catch.HasCaught()); 1014 CHECK(try_catch.HasCaught());
1017 } 1015 }
1018 1016
1019 1017
1020 TEST(DisallowGetNotifierAccessCheckedObject) { 1018 TEST(DisallowGetNotifierAccessCheckedObject) {
1021 v8::Isolate* isolate = CcTest::isolate(); 1019 v8::Isolate* isolate = CcTest::isolate();
1022 v8::HandleScope scope(isolate); 1020 v8::HandleScope scope(isolate);
1023 LocalContext env; 1021 LocalContext env;
1024 v8::Local<v8::ObjectTemplate> object_template = 1022 v8::Local<v8::ObjectTemplate> object_template =
1025 v8::ObjectTemplate::New(isolate); 1023 v8::ObjectTemplate::New(isolate);
1026 object_template->SetAccessCheckCallbacks(NamedAccessCheckAlwaysAllow, NULL); 1024 object_template->SetAccessCheckCallback(NamedAccessCheckAlwaysAllow);
1027 Local<Object> new_instance = 1025 Local<Object> new_instance =
1028 object_template->NewInstance( 1026 object_template->NewInstance(
1029 v8::Isolate::GetCurrent()->GetCurrentContext()) 1027 v8::Isolate::GetCurrent()->GetCurrentContext())
1030 .ToLocalChecked(); 1028 .ToLocalChecked();
1031 env->Global() 1029 env->Global()
1032 ->Set(v8::Isolate::GetCurrent()->GetCurrentContext(), v8_str("obj"), 1030 ->Set(v8::Isolate::GetCurrent()->GetCurrentContext(), v8_str("obj"),
1033 new_instance) 1031 new_instance)
1034 .FromJust(); 1032 .FromJust();
1035 v8::TryCatch try_catch(isolate); 1033 v8::TryCatch try_catch(isolate);
1036 CompileRun("Object.getNotifier(obj)"); 1034 CompileRun("Object.getNotifier(obj)");
1037 CHECK(try_catch.HasCaught()); 1035 CHECK(try_catch.HasCaught());
1038 } 1036 }
OLDNEW
« no previous file with comments | « test/cctest/test-api-interceptors.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698