OLD | NEW |
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 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 i::Isolate* isolate = CcTest::i_isolate(); | 878 i::Isolate* isolate = CcTest::i_isolate(); |
879 i::HandleScope scope(isolate); | 879 i::HandleScope scope(isolate); |
880 LocalContext env; | 880 LocalContext env; |
881 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {}; | 881 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {}; |
882 global_use_counts = use_counts; | 882 global_use_counts = use_counts; |
883 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback); | 883 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback); |
884 CompileRun("var obj = {}"); | 884 CompileRun("var obj = {}"); |
885 CompileRun("Object.getNotifier(obj)"); | 885 CompileRun("Object.getNotifier(obj)"); |
886 CHECK_EQ(1, use_counts[v8::Isolate::kObjectObserve]); | 886 CHECK_EQ(1, use_counts[v8::Isolate::kObjectObserve]); |
887 } | 887 } |
| 888 |
| 889 |
| 890 static bool NamedAccessCheckAlwaysAllow(Local<v8::Object> global, |
| 891 Local<v8::Value> name, |
| 892 v8::AccessType type, |
| 893 Local<Value> data) { |
| 894 return true; |
| 895 } |
| 896 |
| 897 |
| 898 TEST(DisallowObserveAccessCheckedObject) { |
| 899 v8::Isolate* isolate = CcTest::isolate(); |
| 900 v8::HandleScope scope(isolate); |
| 901 LocalContext env; |
| 902 v8::Local<v8::ObjectTemplate> object_template = |
| 903 v8::ObjectTemplate::New(isolate); |
| 904 object_template->SetAccessCheckCallbacks(NamedAccessCheckAlwaysAllow, NULL); |
| 905 env->Global()->Set(v8_str("obj"), object_template->NewInstance()); |
| 906 v8::TryCatch try_catch(isolate); |
| 907 CompileRun("Object.observe(obj, function(){})"); |
| 908 CHECK(try_catch.HasCaught()); |
| 909 } |
| 910 |
| 911 |
| 912 TEST(DisallowGetNotifierAccessCheckedObject) { |
| 913 v8::Isolate* isolate = CcTest::isolate(); |
| 914 v8::HandleScope scope(isolate); |
| 915 LocalContext env; |
| 916 v8::Local<v8::ObjectTemplate> object_template = |
| 917 v8::ObjectTemplate::New(isolate); |
| 918 object_template->SetAccessCheckCallbacks(NamedAccessCheckAlwaysAllow, NULL); |
| 919 env->Global()->Set(v8_str("obj"), object_template->NewInstance()); |
| 920 v8::TryCatch try_catch(isolate); |
| 921 CompileRun("Object.getNotifier(obj)"); |
| 922 CHECK(try_catch.HasCaught()); |
| 923 } |
OLD | NEW |