| OLD | NEW |
| 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 <stdlib.h> | 5 #include <stdlib.h> |
| 6 | 6 |
| 7 #include "test/cctest/test-api.h" | 7 #include "test/cctest/test-api.h" |
| 8 | 8 |
| 9 #include "include/v8-util.h" | 9 #include "include/v8-util.h" |
| 10 #include "src/api.h" | 10 #include "src/api.h" |
| (...skipping 3006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3017 context->Global()->Set(v8_str("checked"), checked_instance); | 3017 context->Global()->Set(v8_str("checked"), checked_instance); |
| 3018 CompileRun( | 3018 CompileRun( |
| 3019 "checked.__proto__ = intercepted_1;" | 3019 "checked.__proto__ = intercepted_1;" |
| 3020 "intercepted_1.__proto__ = intercepted_0;"); | 3020 "intercepted_1.__proto__ = intercepted_0;"); |
| 3021 | 3021 |
| 3022 checked_instance->TurnOnAccessCheck(); | 3022 checked_instance->TurnOnAccessCheck(); |
| 3023 CHECK_EQ(0, access_check_data.count); | 3023 CHECK_EQ(0, access_check_data.count); |
| 3024 | 3024 |
| 3025 access_check_data.result = true; | 3025 access_check_data.result = true; |
| 3026 ExpectInt32("checked.whatever", 17); | 3026 ExpectInt32("checked.whatever", 17); |
| 3027 CHECK_EQ(1, access_check_data.count); | 3027 CHECK(!CompileRun("Object.getOwnPropertyDescriptor(checked, 'whatever')") |
| 3028 ->IsUndefined()); |
| 3029 CHECK_EQ(2, access_check_data.count); |
| 3028 | 3030 |
| 3029 access_check_data.result = false; | 3031 access_check_data.result = false; |
| 3030 ExpectInt32("checked.whatever", intercept_data_0.value); | 3032 ExpectInt32("checked.whatever", intercept_data_0.value); |
| 3031 CHECK_EQ(2, access_check_data.count); | 3033 { |
| 3034 v8::TryCatch try_catch(isolate); |
| 3035 CompileRun("Object.getOwnPropertyDescriptor(checked, 'whatever')"); |
| 3036 CHECK(try_catch.HasCaught()); |
| 3037 } |
| 3038 CHECK_EQ(4, access_check_data.count); |
| 3032 | 3039 |
| 3033 intercept_data_1.should_intercept = true; | 3040 intercept_data_1.should_intercept = true; |
| 3034 ExpectInt32("checked.whatever", intercept_data_1.value); | 3041 ExpectInt32("checked.whatever", intercept_data_1.value); |
| 3035 CHECK_EQ(3, access_check_data.count); | 3042 { |
| 3043 v8::TryCatch try_catch(isolate); |
| 3044 CompileRun("Object.getOwnPropertyDescriptor(checked, 'whatever')"); |
| 3045 CHECK(try_catch.HasCaught()); |
| 3046 } |
| 3047 CHECK_EQ(6, access_check_data.count); |
| 3036 } | 3048 } |
| 3037 | 3049 |
| 3038 | 3050 |
| 3039 THREADED_TEST(IndexedAllCanReadInterceptor) { | 3051 THREADED_TEST(IndexedAllCanReadInterceptor) { |
| 3040 auto isolate = CcTest::isolate(); | 3052 auto isolate = CcTest::isolate(); |
| 3041 v8::HandleScope handle_scope(isolate); | 3053 v8::HandleScope handle_scope(isolate); |
| 3042 LocalContext context; | 3054 LocalContext context; |
| 3043 | 3055 |
| 3044 AccessCheckData access_check_data; | 3056 AccessCheckData access_check_data; |
| 3045 access_check_data.result = false; | 3057 access_check_data.result = false; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3083 checked_instance->Set(15, v8_num(17)); | 3095 checked_instance->Set(15, v8_num(17)); |
| 3084 CompileRun( | 3096 CompileRun( |
| 3085 "checked.__proto__ = intercepted_1;" | 3097 "checked.__proto__ = intercepted_1;" |
| 3086 "intercepted_1.__proto__ = intercepted_0;"); | 3098 "intercepted_1.__proto__ = intercepted_0;"); |
| 3087 | 3099 |
| 3088 checked_instance->TurnOnAccessCheck(); | 3100 checked_instance->TurnOnAccessCheck(); |
| 3089 CHECK_EQ(0, access_check_data.count); | 3101 CHECK_EQ(0, access_check_data.count); |
| 3090 | 3102 |
| 3091 access_check_data.result = true; | 3103 access_check_data.result = true; |
| 3092 ExpectInt32("checked[15]", 17); | 3104 ExpectInt32("checked[15]", 17); |
| 3093 CHECK_EQ(1, access_check_data.count); | 3105 CHECK(!CompileRun("Object.getOwnPropertyDescriptor(checked, '15')") |
| 3106 ->IsUndefined()); |
| 3107 CHECK_EQ(3, access_check_data.count); |
| 3094 | 3108 |
| 3095 access_check_data.result = false; | 3109 access_check_data.result = false; |
| 3096 ExpectInt32("checked[15]", intercept_data_0.value); | 3110 ExpectInt32("checked[15]", intercept_data_0.value); |
| 3097 CHECK_EQ(2, access_check_data.count); | 3111 // Note: this should throw but without a LookupIterator it's complicated. |
| 3112 CHECK(!CompileRun("Object.getOwnPropertyDescriptor(checked, '15')") |
| 3113 ->IsUndefined()); |
| 3114 CHECK_EQ(6, access_check_data.count); |
| 3098 | 3115 |
| 3099 intercept_data_1.should_intercept = true; | 3116 intercept_data_1.should_intercept = true; |
| 3100 ExpectInt32("checked[15]", intercept_data_1.value); | 3117 ExpectInt32("checked[15]", intercept_data_1.value); |
| 3101 CHECK_EQ(3, access_check_data.count); | 3118 // Note: this should throw but without a LookupIterator it's complicated. |
| 3119 CHECK(!CompileRun("Object.getOwnPropertyDescriptor(checked, '15')") |
| 3120 ->IsUndefined()); |
| 3121 CHECK_EQ(9, access_check_data.count); |
| 3102 } | 3122 } |
| 3103 | 3123 |
| 3104 | 3124 |
| 3105 THREADED_TEST(NonMaskingInterceptorOwnProperty) { | 3125 THREADED_TEST(NonMaskingInterceptorOwnProperty) { |
| 3106 auto isolate = CcTest::isolate(); | 3126 auto isolate = CcTest::isolate(); |
| 3107 v8::HandleScope handle_scope(isolate); | 3127 v8::HandleScope handle_scope(isolate); |
| 3108 LocalContext context; | 3128 LocalContext context; |
| 3109 | 3129 |
| 3110 ShouldInterceptData intercept_data; | 3130 ShouldInterceptData intercept_data; |
| 3111 intercept_data.value = 239; | 3131 intercept_data.value = 239; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3220 | 3240 |
| 3221 // Reset. | 3241 // Reset. |
| 3222 CompileRun("delete obj.whatever;"); | 3242 CompileRun("delete obj.whatever;"); |
| 3223 ExpectInt32("f(obj)", 239); | 3243 ExpectInt32("f(obj)", 239); |
| 3224 ExpectInt32("f(outer)", 239); | 3244 ExpectInt32("f(outer)", 239); |
| 3225 | 3245 |
| 3226 CompileRun("outer.whatever = 4;"); | 3246 CompileRun("outer.whatever = 4;"); |
| 3227 ExpectInt32("f(obj)", 239); | 3247 ExpectInt32("f(obj)", 239); |
| 3228 ExpectInt32("f(outer)", 4); | 3248 ExpectInt32("f(outer)", 4); |
| 3229 } | 3249 } |
| OLD | NEW |