| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 109 } |
| 110 | 110 |
| 111 | 111 |
| 112 static void ExpectUndefined(const char* code) { | 112 static void ExpectUndefined(const char* code) { |
| 113 Local<Value> result = CompileRun(code); | 113 Local<Value> result = CompileRun(code); |
| 114 CHECK(result->IsUndefined()); | 114 CHECK(result->IsUndefined()); |
| 115 } | 115 } |
| 116 | 116 |
| 117 | 117 |
| 118 static int signature_callback_count; | 118 static int signature_callback_count; |
| 119 static v8::Handle<Value> IncrementingSignatureCallback( | 119 static void IncrementingSignatureCallback( |
| 120 const v8::Arguments& args) { | 120 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 121 ApiTestFuzzer::Fuzz(); | 121 ApiTestFuzzer::Fuzz(); |
| 122 signature_callback_count++; | 122 signature_callback_count++; |
| 123 v8::Handle<v8::Array> result = v8::Array::New(args.Length()); | 123 v8::Handle<v8::Array> result = v8::Array::New(args.Length()); |
| 124 for (int i = 0; i < args.Length(); i++) | 124 for (int i = 0; i < args.Length(); i++) |
| 125 result->Set(v8::Integer::New(i), args[i]); | 125 result->Set(v8::Integer::New(i), args[i]); |
| 126 return result; | 126 args.GetReturnValue().Set(result); |
| 127 } | 127 } |
| 128 | 128 |
| 129 | 129 |
| 130 static v8::Handle<Value> SignatureCallback(const v8::Arguments& args) { | 130 static void SignatureCallback( |
| 131 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 131 ApiTestFuzzer::Fuzz(); | 132 ApiTestFuzzer::Fuzz(); |
| 132 v8::Handle<v8::Array> result = v8::Array::New(args.Length()); | 133 v8::Handle<v8::Array> result = v8::Array::New(args.Length()); |
| 133 for (int i = 0; i < args.Length(); i++) { | 134 for (int i = 0; i < args.Length(); i++) { |
| 134 result->Set(v8::Integer::New(i), args[i]); | 135 result->Set(v8::Integer::New(i), args[i]); |
| 135 } | 136 } |
| 136 return result; | 137 args.GetReturnValue().Set(result); |
| 137 } | 138 } |
| 138 | 139 |
| 139 | 140 |
| 140 THREADED_TEST(Handles) { | 141 THREADED_TEST(Handles) { |
| 141 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 142 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 142 Local<Context> local_env; | 143 Local<Context> local_env; |
| 143 { | 144 { |
| 144 LocalContext env; | 145 LocalContext env; |
| 145 local_env = env.local(); | 146 local_env = env.local(); |
| 146 } | 147 } |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(t.GetIsolate()); | 822 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(t.GetIsolate()); |
| 822 // If CPU profiler is active check that when API callback is invoked | 823 // If CPU profiler is active check that when API callback is invoked |
| 823 // VMState is set to EXTERNAL. | 824 // VMState is set to EXTERNAL. |
| 824 if (isolate->cpu_profiler()->is_profiling()) { | 825 if (isolate->cpu_profiler()->is_profiling()) { |
| 825 CHECK_EQ(i::EXTERNAL, isolate->current_vm_state()); | 826 CHECK_EQ(i::EXTERNAL, isolate->current_vm_state()); |
| 826 CHECK(isolate->external_callback()); | 827 CHECK(isolate->external_callback()); |
| 827 CHECK_EQ(callback, isolate->external_callback()); | 828 CHECK_EQ(callback, isolate->external_callback()); |
| 828 } | 829 } |
| 829 } | 830 } |
| 830 | 831 |
| 831 static v8::Handle<Value> handle_call_impl( | |
| 832 const v8::Arguments& args, | |
| 833 i::Address callback) { | |
| 834 ApiTestFuzzer::Fuzz(); | |
| 835 CheckReturnValue(args, callback); | |
| 836 args.GetReturnValue().Set(v8_str("bad value")); | |
| 837 return v8_num(102); | |
| 838 } | |
| 839 | |
| 840 static v8::Handle<Value> handle_call(const v8::Arguments& args) { | |
| 841 return handle_call_impl(args, FUNCTION_ADDR(handle_call)); | |
| 842 } | |
| 843 | |
| 844 static v8::Handle<Value> handle_call_2(const v8::Arguments& args) { | |
| 845 return handle_call_impl(args, FUNCTION_ADDR(handle_call_2)); | |
| 846 } | |
| 847 | |
| 848 static v8::Handle<Value> handle_call_indirect_impl(const v8::Arguments& args, | |
| 849 i::Address callback) { | |
| 850 ApiTestFuzzer::Fuzz(); | |
| 851 CheckReturnValue(args, callback); | |
| 852 args.GetReturnValue().Set(v8_str("bad value")); | |
| 853 args.GetReturnValue().Set(v8_num(102)); | |
| 854 return v8::Handle<Value>(); | |
| 855 } | |
| 856 | |
| 857 static v8::Handle<Value> handle_call_indirect(const v8::Arguments& args) { | |
| 858 return handle_call_indirect_impl(args, FUNCTION_ADDR(handle_call_indirect)); | |
| 859 } | |
| 860 | |
| 861 static v8::Handle<Value> handle_call_indirect_2(const v8::Arguments& args) { | |
| 862 return handle_call_indirect_impl(args, FUNCTION_ADDR(handle_call_indirect_2)); | |
| 863 } | |
| 864 | 832 |
| 865 static void handle_callback_impl(const v8::FunctionCallbackInfo<Value>& info, | 833 static void handle_callback_impl(const v8::FunctionCallbackInfo<Value>& info, |
| 866 i::Address callback) { | 834 i::Address callback) { |
| 867 ApiTestFuzzer::Fuzz(); | 835 ApiTestFuzzer::Fuzz(); |
| 868 CheckReturnValue(info, callback); | 836 CheckReturnValue(info, callback); |
| 869 info.GetReturnValue().Set(v8_str("bad value")); | 837 info.GetReturnValue().Set(v8_str("bad value")); |
| 870 info.GetReturnValue().Set(v8_num(102)); | 838 info.GetReturnValue().Set(v8_num(102)); |
| 871 } | 839 } |
| 872 | 840 |
| 873 static void handle_callback(const v8::FunctionCallbackInfo<Value>& info) { | 841 static void handle_callback(const v8::FunctionCallbackInfo<Value>& info) { |
| 874 return handle_callback_impl(info, FUNCTION_ADDR(handle_callback)); | 842 return handle_callback_impl(info, FUNCTION_ADDR(handle_callback)); |
| 875 } | 843 } |
| 876 | 844 |
| 877 static void handle_callback_2(const v8::FunctionCallbackInfo<Value>& info) { | 845 static void handle_callback_2(const v8::FunctionCallbackInfo<Value>& info) { |
| 878 return handle_callback_impl(info, FUNCTION_ADDR(handle_callback_2)); | 846 return handle_callback_impl(info, FUNCTION_ADDR(handle_callback_2)); |
| 879 } | 847 } |
| 880 | 848 |
| 881 static v8::Handle<Value> construct_call(const v8::Arguments& args) { | |
| 882 ApiTestFuzzer::Fuzz(); | |
| 883 CheckReturnValue(args, FUNCTION_ADDR(construct_call)); | |
| 884 args.This()->Set(v8_str("x"), v8_num(1)); | |
| 885 args.This()->Set(v8_str("y"), v8_num(2)); | |
| 886 args.GetReturnValue().Set(v8_str("bad value")); | |
| 887 return args.This(); | |
| 888 } | |
| 889 | |
| 890 static v8::Handle<Value> construct_call_indirect(const v8::Arguments& args) { | |
| 891 ApiTestFuzzer::Fuzz(); | |
| 892 CheckReturnValue(args, FUNCTION_ADDR(construct_call_indirect)); | |
| 893 args.This()->Set(v8_str("x"), v8_num(1)); | |
| 894 args.This()->Set(v8_str("y"), v8_num(2)); | |
| 895 args.GetReturnValue().Set(v8_str("bad value")); | |
| 896 args.GetReturnValue().Set(args.This()); | |
| 897 return v8::Handle<Value>(); | |
| 898 } | |
| 899 | |
| 900 static void construct_callback( | 849 static void construct_callback( |
| 901 const v8::FunctionCallbackInfo<Value>& info) { | 850 const v8::FunctionCallbackInfo<Value>& info) { |
| 902 ApiTestFuzzer::Fuzz(); | 851 ApiTestFuzzer::Fuzz(); |
| 903 CheckReturnValue(info, FUNCTION_ADDR(construct_callback)); | 852 CheckReturnValue(info, FUNCTION_ADDR(construct_callback)); |
| 904 info.This()->Set(v8_str("x"), v8_num(1)); | 853 info.This()->Set(v8_str("x"), v8_num(1)); |
| 905 info.This()->Set(v8_str("y"), v8_num(2)); | 854 info.This()->Set(v8_str("y"), v8_num(2)); |
| 906 info.GetReturnValue().Set(v8_str("bad value")); | 855 info.GetReturnValue().Set(v8_str("bad value")); |
| 907 info.GetReturnValue().Set(info.This()); | 856 info.GetReturnValue().Set(info.This()); |
| 908 } | 857 } |
| 909 | 858 |
| 910 | 859 |
| 911 static v8::Handle<Value> Return239( | |
| 912 Local<String> name, const AccessorInfo& info) { | |
| 913 ApiTestFuzzer::Fuzz(); | |
| 914 CheckReturnValue(info, FUNCTION_ADDR(Return239)); | |
| 915 info.GetReturnValue().Set(v8_str("bad value")); | |
| 916 return v8_num(239); | |
| 917 } | |
| 918 | |
| 919 static v8::Handle<Value> Return239Indirect( | |
| 920 Local<String> name, const AccessorInfo& info) { | |
| 921 ApiTestFuzzer::Fuzz(); | |
| 922 CheckReturnValue(info, FUNCTION_ADDR(Return239Indirect)); | |
| 923 Handle<Value> value = v8_num(239); | |
| 924 info.GetReturnValue().Set(v8_str("bad value")); | |
| 925 info.GetReturnValue().Set(value); | |
| 926 return v8::Handle<Value>(); | |
| 927 } | |
| 928 | |
| 929 static void Return239Callback( | 860 static void Return239Callback( |
| 930 Local<String> name, const v8::PropertyCallbackInfo<Value>& info) { | 861 Local<String> name, const v8::PropertyCallbackInfo<Value>& info) { |
| 931 ApiTestFuzzer::Fuzz(); | 862 ApiTestFuzzer::Fuzz(); |
| 932 CheckReturnValue(info, FUNCTION_ADDR(Return239Callback)); | 863 CheckReturnValue(info, FUNCTION_ADDR(Return239Callback)); |
| 933 info.GetReturnValue().Set(v8_str("bad value")); | 864 info.GetReturnValue().Set(v8_str("bad value")); |
| 934 info.GetReturnValue().Set(v8_num(239)); | 865 info.GetReturnValue().Set(v8_num(239)); |
| 935 } | 866 } |
| 936 | 867 |
| 937 | 868 |
| 938 template<typename Handler> | 869 template<typename Handler> |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 } | 958 } |
| 1028 | 959 |
| 1029 if (is_profiling) { | 960 if (is_profiling) { |
| 1030 cpu_profiler->DeleteAllCpuProfiles(); | 961 cpu_profiler->DeleteAllCpuProfiles(); |
| 1031 } | 962 } |
| 1032 } | 963 } |
| 1033 } | 964 } |
| 1034 | 965 |
| 1035 | 966 |
| 1036 THREADED_TEST(FunctionTemplate) { | 967 THREADED_TEST(FunctionTemplate) { |
| 1037 TestFunctionTemplateInitializer(handle_call, handle_call_2); | |
| 1038 TestFunctionTemplateInitializer(handle_call_indirect, handle_call_indirect_2); | |
| 1039 TestFunctionTemplateInitializer(handle_callback, handle_callback_2); | 968 TestFunctionTemplateInitializer(handle_callback, handle_callback_2); |
| 1040 | |
| 1041 TestFunctionTemplateAccessor(construct_call, Return239); | |
| 1042 TestFunctionTemplateAccessor(construct_call_indirect, Return239Indirect); | |
| 1043 TestFunctionTemplateAccessor(construct_callback, Return239Callback); | 969 TestFunctionTemplateAccessor(construct_callback, Return239Callback); |
| 1044 } | 970 } |
| 1045 | 971 |
| 1046 | 972 |
| 1047 static v8::Handle<v8::Value> SimpleDirectCallback(const v8::Arguments& args) { | |
| 1048 ApiTestFuzzer::Fuzz(); | |
| 1049 CheckReturnValue(args, FUNCTION_ADDR(SimpleDirectCallback)); | |
| 1050 args.GetReturnValue().Set(v8_str("bad value")); | |
| 1051 return v8_num(51423 + args.Length()); | |
| 1052 } | |
| 1053 | |
| 1054 static v8::Handle<v8::Value> SimpleIndirectCallback(const v8::Arguments& args) { | |
| 1055 ApiTestFuzzer::Fuzz(); | |
| 1056 CheckReturnValue(args, FUNCTION_ADDR(SimpleIndirectCallback)); | |
| 1057 args.GetReturnValue().Set(v8_num(51423 + args.Length())); | |
| 1058 return v8::Handle<v8::Value>(); | |
| 1059 } | |
| 1060 | |
| 1061 static void SimpleCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 973 static void SimpleCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 1062 ApiTestFuzzer::Fuzz(); | 974 ApiTestFuzzer::Fuzz(); |
| 1063 CheckReturnValue(info, FUNCTION_ADDR(SimpleCallback)); | 975 CheckReturnValue(info, FUNCTION_ADDR(SimpleCallback)); |
| 1064 info.GetReturnValue().Set(v8_num(51423 + info.Length())); | 976 info.GetReturnValue().Set(v8_num(51423 + info.Length())); |
| 1065 } | 977 } |
| 1066 | 978 |
| 1067 | 979 |
| 1068 template<typename Callback> | 980 template<typename Callback> |
| 1069 static void TestSimpleCallback(Callback callback) { | 981 static void TestSimpleCallback(Callback callback) { |
| 1070 for (int i = 0; i < 2; i++) { | 982 for (int i = 0; i < 2; i++) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1093 } | 1005 } |
| 1094 | 1006 |
| 1095 if (is_profiling) { | 1007 if (is_profiling) { |
| 1096 cpu_profiler->DeleteAllCpuProfiles(); | 1008 cpu_profiler->DeleteAllCpuProfiles(); |
| 1097 } | 1009 } |
| 1098 } | 1010 } |
| 1099 } | 1011 } |
| 1100 | 1012 |
| 1101 | 1013 |
| 1102 THREADED_TEST(SimpleCallback) { | 1014 THREADED_TEST(SimpleCallback) { |
| 1103 TestSimpleCallback(SimpleDirectCallback); | |
| 1104 TestSimpleCallback(SimpleIndirectCallback); | |
| 1105 TestSimpleCallback(SimpleCallback); | 1015 TestSimpleCallback(SimpleCallback); |
| 1106 } | 1016 } |
| 1107 | 1017 |
| 1108 | 1018 |
| 1109 template<typename T> | 1019 template<typename T> |
| 1110 void FastReturnValueCallback(const v8::FunctionCallbackInfo<v8::Value>& info); | 1020 void FastReturnValueCallback(const v8::FunctionCallbackInfo<v8::Value>& info); |
| 1111 | 1021 |
| 1112 // constant return values | 1022 // constant return values |
| 1113 static int32_t fast_return_value_int32 = 471; | 1023 static int32_t fast_return_value_int32 = 471; |
| 1114 static uint32_t fast_return_value_uint32 = 571; | 1024 static uint32_t fast_return_value_uint32 = 571; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 value = TestFastReturnValues<Object>(); | 1169 value = TestFastReturnValues<Object>(); |
| 1260 CHECK(value->IsUndefined()); | 1170 CHECK(value->IsUndefined()); |
| 1261 } | 1171 } |
| 1262 | 1172 |
| 1263 | 1173 |
| 1264 THREADED_TEST(FunctionTemplateSetLength) { | 1174 THREADED_TEST(FunctionTemplateSetLength) { |
| 1265 LocalContext env; | 1175 LocalContext env; |
| 1266 v8::HandleScope scope(env->GetIsolate()); | 1176 v8::HandleScope scope(env->GetIsolate()); |
| 1267 { | 1177 { |
| 1268 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New( | 1178 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New( |
| 1269 handle_call, Handle<v8::Value>(), Handle<v8::Signature>(), 23); | 1179 handle_callback, Handle<v8::Value>(), Handle<v8::Signature>(), 23); |
| 1270 Local<Function> fun = fun_templ->GetFunction(); | 1180 Local<Function> fun = fun_templ->GetFunction(); |
| 1271 env->Global()->Set(v8_str("obj"), fun); | 1181 env->Global()->Set(v8_str("obj"), fun); |
| 1272 Local<Script> script = v8_compile("obj.length"); | 1182 Local<Script> script = v8_compile("obj.length"); |
| 1273 CHECK_EQ(23, script->Run()->Int32Value()); | 1183 CHECK_EQ(23, script->Run()->Int32Value()); |
| 1274 } | 1184 } |
| 1275 { | 1185 { |
| 1276 Local<v8::FunctionTemplate> fun_templ = | 1186 Local<v8::FunctionTemplate> fun_templ = |
| 1277 v8::FunctionTemplate::New(handle_call); | 1187 v8::FunctionTemplate::New(handle_callback); |
| 1278 fun_templ->SetLength(22); | 1188 fun_templ->SetLength(22); |
| 1279 Local<Function> fun = fun_templ->GetFunction(); | 1189 Local<Function> fun = fun_templ->GetFunction(); |
| 1280 env->Global()->Set(v8_str("obj"), fun); | 1190 env->Global()->Set(v8_str("obj"), fun); |
| 1281 Local<Script> script = v8_compile("obj.length"); | 1191 Local<Script> script = v8_compile("obj.length"); |
| 1282 CHECK_EQ(22, script->Run()->Int32Value()); | 1192 CHECK_EQ(22, script->Run()->Int32Value()); |
| 1283 } | 1193 } |
| 1284 { | 1194 { |
| 1285 // Without setting length it defaults to 0. | 1195 // Without setting length it defaults to 0. |
| 1286 Local<v8::FunctionTemplate> fun_templ = | 1196 Local<v8::FunctionTemplate> fun_templ = |
| 1287 v8::FunctionTemplate::New(handle_call); | 1197 v8::FunctionTemplate::New(handle_callback); |
| 1288 Local<Function> fun = fun_templ->GetFunction(); | 1198 Local<Function> fun = fun_templ->GetFunction(); |
| 1289 env->Global()->Set(v8_str("obj"), fun); | 1199 env->Global()->Set(v8_str("obj"), fun); |
| 1290 Local<Script> script = v8_compile("obj.length"); | 1200 Local<Script> script = v8_compile("obj.length"); |
| 1291 CHECK_EQ(0, script->Run()->Int32Value()); | 1201 CHECK_EQ(0, script->Run()->Int32Value()); |
| 1292 } | 1202 } |
| 1293 } | 1203 } |
| 1294 | 1204 |
| 1295 | 1205 |
| 1296 static void* expected_ptr; | 1206 static void* expected_ptr; |
| 1297 static v8::Handle<v8::Value> callback(const v8::Arguments& args) { | 1207 static void callback(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 1298 void* ptr = v8::External::Cast(*args.Data())->Value(); | 1208 void* ptr = v8::External::Cast(*args.Data())->Value(); |
| 1299 CHECK_EQ(expected_ptr, ptr); | 1209 CHECK_EQ(expected_ptr, ptr); |
| 1300 return v8::True(); | 1210 args.GetReturnValue().Set(true); |
| 1301 } | 1211 } |
| 1302 | 1212 |
| 1303 | 1213 |
| 1304 static void TestExternalPointerWrapping() { | 1214 static void TestExternalPointerWrapping() { |
| 1305 LocalContext env; | 1215 LocalContext env; |
| 1306 v8::HandleScope scope(env->GetIsolate()); | 1216 v8::HandleScope scope(env->GetIsolate()); |
| 1307 | 1217 |
| 1308 v8::Handle<v8::Value> data = v8::External::New(expected_ptr); | 1218 v8::Handle<v8::Value> data = v8::External::New(expected_ptr); |
| 1309 | 1219 |
| 1310 v8::Handle<v8::Object> obj = v8::Object::New(); | 1220 v8::Handle<v8::Object> obj = v8::Object::New(); |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1668 v8::Handle<String> str2 = v8_str("x"); | 1578 v8::Handle<String> str2 = v8_str("x"); |
| 1669 CHECK(str2->BooleanValue()); | 1579 CHECK(str2->BooleanValue()); |
| 1670 CHECK(!v8::Number::New(0)->BooleanValue()); | 1580 CHECK(!v8::Number::New(0)->BooleanValue()); |
| 1671 CHECK(v8::Number::New(-1)->BooleanValue()); | 1581 CHECK(v8::Number::New(-1)->BooleanValue()); |
| 1672 CHECK(v8::Number::New(1)->BooleanValue()); | 1582 CHECK(v8::Number::New(1)->BooleanValue()); |
| 1673 CHECK(v8::Number::New(42)->BooleanValue()); | 1583 CHECK(v8::Number::New(42)->BooleanValue()); |
| 1674 CHECK(!v8_compile("NaN")->Run()->BooleanValue()); | 1584 CHECK(!v8_compile("NaN")->Run()->BooleanValue()); |
| 1675 } | 1585 } |
| 1676 | 1586 |
| 1677 | 1587 |
| 1678 static v8::Handle<Value> DummyCallHandler(const v8::Arguments& args) { | 1588 static void DummyCallHandler(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 1679 ApiTestFuzzer::Fuzz(); | 1589 ApiTestFuzzer::Fuzz(); |
| 1680 return v8_num(13.4); | 1590 args.GetReturnValue().Set(v8_num(13.4)); |
| 1681 } | 1591 } |
| 1682 | 1592 |
| 1683 | 1593 |
| 1684 static v8::Handle<Value> GetM(Local<String> name, const AccessorInfo&) { | 1594 static void GetM(Local<String> name, |
| 1595 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1685 ApiTestFuzzer::Fuzz(); | 1596 ApiTestFuzzer::Fuzz(); |
| 1686 return v8_num(876); | 1597 info.GetReturnValue().Set(v8_num(876)); |
| 1687 } | 1598 } |
| 1688 | 1599 |
| 1689 | 1600 |
| 1690 THREADED_TEST(GlobalPrototype) { | 1601 THREADED_TEST(GlobalPrototype) { |
| 1691 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 1602 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 1692 v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New(); | 1603 v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New(); |
| 1693 func_templ->PrototypeTemplate()->Set( | 1604 func_templ->PrototypeTemplate()->Set( |
| 1694 "dummy", | 1605 "dummy", |
| 1695 v8::FunctionTemplate::New(DummyCallHandler)); | 1606 v8::FunctionTemplate::New(DummyCallHandler)); |
| 1696 v8::Handle<ObjectTemplate> templ = func_templ->InstanceTemplate(); | 1607 v8::Handle<ObjectTemplate> templ = func_templ->InstanceTemplate(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1722 templ2->Set("b", templ1); | 1633 templ2->Set("b", templ1); |
| 1723 Local<v8::Object> instance2 = templ2->NewInstance(); | 1634 Local<v8::Object> instance2 = templ2->NewInstance(); |
| 1724 env->Global()->Set(v8_str("q"), instance2); | 1635 env->Global()->Set(v8_str("q"), instance2); |
| 1725 CHECK(v8_compile("(q.nirk == 123)")->Run()->BooleanValue()); | 1636 CHECK(v8_compile("(q.nirk == 123)")->Run()->BooleanValue()); |
| 1726 CHECK(v8_compile("(q.a == 12)")->Run()->BooleanValue()); | 1637 CHECK(v8_compile("(q.a == 12)")->Run()->BooleanValue()); |
| 1727 CHECK(v8_compile("(q.b.x == 10)")->Run()->BooleanValue()); | 1638 CHECK(v8_compile("(q.b.x == 10)")->Run()->BooleanValue()); |
| 1728 CHECK(v8_compile("(q.b.y == 13)")->Run()->BooleanValue()); | 1639 CHECK(v8_compile("(q.b.y == 13)")->Run()->BooleanValue()); |
| 1729 } | 1640 } |
| 1730 | 1641 |
| 1731 | 1642 |
| 1732 static v8::Handle<Value> GetFlabby(const v8::Arguments& args) { | 1643 static void GetFlabby(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 1733 ApiTestFuzzer::Fuzz(); | 1644 ApiTestFuzzer::Fuzz(); |
| 1734 return v8_num(17.2); | 1645 args.GetReturnValue().Set(v8_num(17.2)); |
| 1735 } | 1646 } |
| 1736 | 1647 |
| 1737 | 1648 |
| 1738 static v8::Handle<Value> GetKnurd(Local<String> property, const AccessorInfo&) { | 1649 static void GetKnurd(Local<String> property, |
| 1650 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1739 ApiTestFuzzer::Fuzz(); | 1651 ApiTestFuzzer::Fuzz(); |
| 1740 return v8_num(15.2); | 1652 info.GetReturnValue().Set(v8_num(15.2)); |
| 1741 } | 1653 } |
| 1742 | 1654 |
| 1743 | 1655 |
| 1744 THREADED_TEST(DescriptorInheritance) { | 1656 THREADED_TEST(DescriptorInheritance) { |
| 1745 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 1657 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 1746 v8::Handle<v8::FunctionTemplate> super = v8::FunctionTemplate::New(); | 1658 v8::Handle<v8::FunctionTemplate> super = v8::FunctionTemplate::New(); |
| 1747 super->PrototypeTemplate()->Set("flabby", | 1659 super->PrototypeTemplate()->Set("flabby", |
| 1748 v8::FunctionTemplate::New(GetFlabby)); | 1660 v8::FunctionTemplate::New(GetFlabby)); |
| 1749 super->PrototypeTemplate()->Set("PI", v8_num(3.14)); | 1661 super->PrototypeTemplate()->Set("PI", v8_num(3.14)); |
| 1750 | 1662 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1793 | 1705 |
| 1794 // base1 and base2 cannot cross reference to each's prototype | 1706 // base1 and base2 cannot cross reference to each's prototype |
| 1795 CHECK(v8_compile("obj.v2")->Run()->IsUndefined()); | 1707 CHECK(v8_compile("obj.v2")->Run()->IsUndefined()); |
| 1796 CHECK(v8_compile("obj2.v1")->Run()->IsUndefined()); | 1708 CHECK(v8_compile("obj2.v1")->Run()->IsUndefined()); |
| 1797 } | 1709 } |
| 1798 | 1710 |
| 1799 | 1711 |
| 1800 int echo_named_call_count; | 1712 int echo_named_call_count; |
| 1801 | 1713 |
| 1802 | 1714 |
| 1803 static v8::Handle<Value> EchoNamedProperty(Local<String> name, | 1715 static void EchoNamedProperty(Local<String> name, |
| 1804 const AccessorInfo& info) { | 1716 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1805 ApiTestFuzzer::Fuzz(); | 1717 ApiTestFuzzer::Fuzz(); |
| 1806 CHECK_EQ(v8_str("data"), info.Data()); | 1718 CHECK_EQ(v8_str("data"), info.Data()); |
| 1807 echo_named_call_count++; | 1719 echo_named_call_count++; |
| 1808 return name; | 1720 info.GetReturnValue().Set(name); |
| 1809 } | 1721 } |
| 1810 | 1722 |
| 1811 // Helper functions for Interceptor/Accessor interaction tests | 1723 // Helper functions for Interceptor/Accessor interaction tests |
| 1812 | 1724 |
| 1813 Handle<Value> SimpleAccessorGetter(Local<String> name, | 1725 void SimpleAccessorGetter(Local<String> name, |
| 1814 const AccessorInfo& info) { | 1726 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1815 Handle<Object> self = info.This(); | 1727 Handle<Object> self = info.This(); |
| 1816 return self->Get(String::Concat(v8_str("accessor_"), name)); | 1728 info.GetReturnValue().Set( |
| 1729 self->Get(String::Concat(v8_str("accessor_"), name))); |
| 1817 } | 1730 } |
| 1818 | 1731 |
| 1819 void SimpleAccessorSetter(Local<String> name, Local<Value> value, | 1732 void SimpleAccessorSetter(Local<String> name, Local<Value> value, |
| 1820 const AccessorInfo& info) { | 1733 const v8::PropertyCallbackInfo<void>& info) { |
| 1821 Handle<Object> self = info.This(); | 1734 Handle<Object> self = info.This(); |
| 1822 self->Set(String::Concat(v8_str("accessor_"), name), value); | 1735 self->Set(String::Concat(v8_str("accessor_"), name), value); |
| 1823 } | 1736 } |
| 1824 | 1737 |
| 1825 Handle<Value> EmptyInterceptorGetter(Local<String> name, | 1738 void EmptyInterceptorGetter(Local<String> name, |
| 1826 const AccessorInfo& info) { | 1739 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1827 return Handle<Value>(); | |
| 1828 } | 1740 } |
| 1829 | 1741 |
| 1830 Handle<Value> EmptyInterceptorSetter(Local<String> name, | 1742 void EmptyInterceptorSetter(Local<String> name, |
| 1831 Local<Value> value, | 1743 Local<Value> value, |
| 1832 const AccessorInfo& info) { | 1744 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1833 return Handle<Value>(); | |
| 1834 } | 1745 } |
| 1835 | 1746 |
| 1836 Handle<Value> InterceptorGetter(Local<String> name, | 1747 void InterceptorGetter(Local<String> name, |
| 1837 const AccessorInfo& info) { | 1748 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1838 // Intercept names that start with 'interceptor_'. | 1749 // Intercept names that start with 'interceptor_'. |
| 1839 String::Utf8Value utf8(name); | 1750 String::Utf8Value utf8(name); |
| 1840 char* name_str = *utf8; | 1751 char* name_str = *utf8; |
| 1841 char prefix[] = "interceptor_"; | 1752 char prefix[] = "interceptor_"; |
| 1842 int i; | 1753 int i; |
| 1843 for (i = 0; name_str[i] && prefix[i]; ++i) { | 1754 for (i = 0; name_str[i] && prefix[i]; ++i) { |
| 1844 if (name_str[i] != prefix[i]) return Handle<Value>(); | 1755 if (name_str[i] != prefix[i]) return; |
| 1845 } | 1756 } |
| 1846 Handle<Object> self = info.This(); | 1757 Handle<Object> self = info.This(); |
| 1847 return self->GetHiddenValue(v8_str(name_str + i)); | 1758 info.GetReturnValue().Set(self->GetHiddenValue(v8_str(name_str + i))); |
| 1848 } | 1759 } |
| 1849 | 1760 |
| 1850 Handle<Value> InterceptorSetter(Local<String> name, | 1761 void InterceptorSetter(Local<String> name, |
| 1851 Local<Value> value, | 1762 Local<Value> value, |
| 1852 const AccessorInfo& info) { | 1763 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1853 // Intercept accesses that set certain integer values. | 1764 // Intercept accesses that set certain integer values. |
| 1854 if (value->IsInt32() && value->Int32Value() < 10000) { | 1765 if (value->IsInt32() && value->Int32Value() < 10000) { |
| 1855 Handle<Object> self = info.This(); | 1766 Handle<Object> self = info.This(); |
| 1856 self->SetHiddenValue(name, value); | 1767 self->SetHiddenValue(name, value); |
| 1857 return value; | 1768 info.GetReturnValue().Set(value); |
| 1858 } | 1769 } |
| 1859 return Handle<Value>(); | |
| 1860 } | 1770 } |
| 1861 | 1771 |
| 1862 void AddAccessor(Handle<FunctionTemplate> templ, | 1772 void AddAccessor(Handle<FunctionTemplate> templ, |
| 1863 Handle<String> name, | 1773 Handle<String> name, |
| 1864 v8::AccessorGetter getter, | 1774 v8::AccessorGetterCallback getter, |
| 1865 v8::AccessorSetter setter) { | 1775 v8::AccessorSetterCallback setter) { |
| 1866 templ->PrototypeTemplate()->SetAccessor(name, getter, setter); | 1776 templ->PrototypeTemplate()->SetAccessor(name, getter, setter); |
| 1867 } | 1777 } |
| 1868 | 1778 |
| 1869 void AddInterceptor(Handle<FunctionTemplate> templ, | 1779 void AddInterceptor(Handle<FunctionTemplate> templ, |
| 1870 v8::NamedPropertyGetter getter, | 1780 v8::NamedPropertyGetterCallback getter, |
| 1871 v8::NamedPropertySetter setter) { | 1781 v8::NamedPropertySetterCallback setter) { |
| 1872 templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter); | 1782 templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter); |
| 1873 } | 1783 } |
| 1874 | 1784 |
| 1875 THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) { | 1785 THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) { |
| 1876 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 1786 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 1877 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 1787 Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
| 1878 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 1788 Handle<FunctionTemplate> child = FunctionTemplate::New(); |
| 1879 child->Inherit(parent); | 1789 child->Inherit(parent); |
| 1880 AddAccessor(parent, v8_str("age"), | 1790 AddAccessor(parent, v8_str("age"), |
| 1881 SimpleAccessorGetter, SimpleAccessorSetter); | 1791 SimpleAccessorGetter, SimpleAccessorSetter); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2102 // Check default behavior | 2012 // Check default behavior |
| 2103 CHECK_EQ(v8_compile("obj.flob = 10;")->Run()->Int32Value(), 10); | 2013 CHECK_EQ(v8_compile("obj.flob = 10;")->Run()->Int32Value(), 10); |
| 2104 CHECK(v8_compile("'myProperty' in obj")->Run()->BooleanValue()); | 2014 CHECK(v8_compile("'myProperty' in obj")->Run()->BooleanValue()); |
| 2105 CHECK(v8_compile("delete obj.myProperty")->Run()->BooleanValue()); | 2015 CHECK(v8_compile("delete obj.myProperty")->Run()->BooleanValue()); |
| 2106 } | 2016 } |
| 2107 | 2017 |
| 2108 | 2018 |
| 2109 int echo_indexed_call_count = 0; | 2019 int echo_indexed_call_count = 0; |
| 2110 | 2020 |
| 2111 | 2021 |
| 2112 static v8::Handle<Value> EchoIndexedProperty(uint32_t index, | 2022 static void EchoIndexedProperty( |
| 2113 const AccessorInfo& info) { | 2023 uint32_t index, |
| 2024 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 2114 ApiTestFuzzer::Fuzz(); | 2025 ApiTestFuzzer::Fuzz(); |
| 2115 CHECK_EQ(v8_num(637), info.Data()); | 2026 CHECK_EQ(v8_num(637), info.Data()); |
| 2116 echo_indexed_call_count++; | 2027 echo_indexed_call_count++; |
| 2117 return v8_num(index); | 2028 info.GetReturnValue().Set(v8_num(index)); |
| 2118 } | 2029 } |
| 2119 | 2030 |
| 2120 | 2031 |
| 2121 THREADED_TEST(IndexedPropertyHandlerGetter) { | 2032 THREADED_TEST(IndexedPropertyHandlerGetter) { |
| 2122 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2033 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 2123 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 2034 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
| 2124 templ->InstanceTemplate()->SetIndexedPropertyHandler(EchoIndexedProperty, | 2035 templ->InstanceTemplate()->SetIndexedPropertyHandler(EchoIndexedProperty, |
| 2125 0, 0, 0, 0, | 2036 0, 0, 0, 0, |
| 2126 v8_num(637)); | 2037 v8_num(637)); |
| 2127 LocalContext env; | 2038 LocalContext env; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2263 | 2174 |
| 2264 // Indexed and named deleter. | 2175 // Indexed and named deleter. |
| 2265 Script::Compile(v8_str("delete obj[0]"))->Run(); | 2176 Script::Compile(v8_str("delete obj[0]"))->Run(); |
| 2266 Script::Compile(v8_str("delete obj.x"))->Run(); | 2177 Script::Compile(v8_str("delete obj.x"))->Run(); |
| 2267 | 2178 |
| 2268 // Enumerators. | 2179 // Enumerators. |
| 2269 Script::Compile(v8_str("for (var p in obj) ;"))->Run(); | 2180 Script::Compile(v8_str("for (var p in obj) ;"))->Run(); |
| 2270 } | 2181 } |
| 2271 | 2182 |
| 2272 | 2183 |
| 2273 static v8::Handle<Value> PrePropertyHandlerGet(Local<String> key, | 2184 static void PrePropertyHandlerGet( |
| 2274 const AccessorInfo& info) { | 2185 Local<String> key, |
| 2186 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 2275 ApiTestFuzzer::Fuzz(); | 2187 ApiTestFuzzer::Fuzz(); |
| 2276 if (v8_str("pre")->Equals(key)) { | 2188 if (v8_str("pre")->Equals(key)) { |
| 2277 return v8_str("PrePropertyHandler: pre"); | 2189 info.GetReturnValue().Set(v8_str("PrePropertyHandler: pre")); |
| 2278 } | 2190 } |
| 2279 return v8::Handle<String>(); | |
| 2280 } | 2191 } |
| 2281 | 2192 |
| 2282 | 2193 |
| 2283 static v8::Handle<v8::Integer> PrePropertyHandlerQuery(Local<String> key, | 2194 static void PrePropertyHandlerQuery( |
| 2284 const AccessorInfo&) { | 2195 Local<String> key, |
| 2196 const v8::PropertyCallbackInfo<v8::Integer>& info) { |
| 2285 if (v8_str("pre")->Equals(key)) { | 2197 if (v8_str("pre")->Equals(key)) { |
| 2286 return v8::Integer::New(v8::None); | 2198 info.GetReturnValue().Set(static_cast<int32_t>(v8::None)); |
| 2287 } | 2199 } |
| 2288 | |
| 2289 return v8::Handle<v8::Integer>(); // do not intercept the call | |
| 2290 } | 2200 } |
| 2291 | 2201 |
| 2292 | 2202 |
| 2293 THREADED_TEST(PrePropertyHandler) { | 2203 THREADED_TEST(PrePropertyHandler) { |
| 2294 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2204 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 2295 v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(); | 2205 v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(); |
| 2296 desc->InstanceTemplate()->SetNamedPropertyHandler(PrePropertyHandlerGet, | 2206 desc->InstanceTemplate()->SetNamedPropertyHandler(PrePropertyHandlerGet, |
| 2297 0, | 2207 0, |
| 2298 PrePropertyHandlerQuery); | 2208 PrePropertyHandlerQuery); |
| 2299 LocalContext env(NULL, desc->InstanceTemplate()); | 2209 LocalContext env(NULL, desc->InstanceTemplate()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2314 v8::Handle<Value> result = Script::Compile(v8_str( | 2224 v8::Handle<Value> result = Script::Compile(v8_str( |
| 2315 "this.propertyIsEnumerable(undefined)"))->Run(); | 2225 "this.propertyIsEnumerable(undefined)"))->Run(); |
| 2316 CHECK(result->IsFalse()); | 2226 CHECK(result->IsFalse()); |
| 2317 } | 2227 } |
| 2318 | 2228 |
| 2319 | 2229 |
| 2320 v8::Handle<Script> call_recursively_script; | 2230 v8::Handle<Script> call_recursively_script; |
| 2321 static const int kTargetRecursionDepth = 200; // near maximum | 2231 static const int kTargetRecursionDepth = 200; // near maximum |
| 2322 | 2232 |
| 2323 | 2233 |
| 2324 static v8::Handle<Value> CallScriptRecursivelyCall(const v8::Arguments& args) { | 2234 static void CallScriptRecursivelyCall( |
| 2235 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 2325 ApiTestFuzzer::Fuzz(); | 2236 ApiTestFuzzer::Fuzz(); |
| 2326 int depth = args.This()->Get(v8_str("depth"))->Int32Value(); | 2237 int depth = args.This()->Get(v8_str("depth"))->Int32Value(); |
| 2327 if (depth == kTargetRecursionDepth) return v8::Undefined(); | 2238 if (depth == kTargetRecursionDepth) return; |
| 2328 args.This()->Set(v8_str("depth"), v8::Integer::New(depth + 1)); | 2239 args.This()->Set(v8_str("depth"), v8::Integer::New(depth + 1)); |
| 2329 return call_recursively_script->Run(); | 2240 args.GetReturnValue().Set(call_recursively_script->Run()); |
| 2330 } | 2241 } |
| 2331 | 2242 |
| 2332 | 2243 |
| 2333 static v8::Handle<Value> CallFunctionRecursivelyCall( | 2244 static void CallFunctionRecursivelyCall( |
| 2334 const v8::Arguments& args) { | 2245 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 2335 ApiTestFuzzer::Fuzz(); | 2246 ApiTestFuzzer::Fuzz(); |
| 2336 int depth = args.This()->Get(v8_str("depth"))->Int32Value(); | 2247 int depth = args.This()->Get(v8_str("depth"))->Int32Value(); |
| 2337 if (depth == kTargetRecursionDepth) { | 2248 if (depth == kTargetRecursionDepth) { |
| 2338 printf("[depth = %d]\n", depth); | 2249 printf("[depth = %d]\n", depth); |
| 2339 return v8::Undefined(); | 2250 return; |
| 2340 } | 2251 } |
| 2341 args.This()->Set(v8_str("depth"), v8::Integer::New(depth + 1)); | 2252 args.This()->Set(v8_str("depth"), v8::Integer::New(depth + 1)); |
| 2342 v8::Handle<Value> function = | 2253 v8::Handle<Value> function = |
| 2343 args.This()->Get(v8_str("callFunctionRecursively")); | 2254 args.This()->Get(v8_str("callFunctionRecursively")); |
| 2344 return function.As<Function>()->Call(args.This(), 0, NULL); | 2255 args.GetReturnValue().Set( |
| 2256 function.As<Function>()->Call(args.This(), 0, NULL)); |
| 2345 } | 2257 } |
| 2346 | 2258 |
| 2347 | 2259 |
| 2348 THREADED_TEST(DeepCrossLanguageRecursion) { | 2260 THREADED_TEST(DeepCrossLanguageRecursion) { |
| 2349 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2261 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 2350 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); | 2262 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); |
| 2351 global->Set(v8_str("callScriptRecursively"), | 2263 global->Set(v8_str("callScriptRecursively"), |
| 2352 v8::FunctionTemplate::New(CallScriptRecursivelyCall)); | 2264 v8::FunctionTemplate::New(CallScriptRecursivelyCall)); |
| 2353 global->Set(v8_str("callFunctionRecursively"), | 2265 global->Set(v8_str("callFunctionRecursively"), |
| 2354 v8::FunctionTemplate::New(CallFunctionRecursivelyCall)); | 2266 v8::FunctionTemplate::New(CallFunctionRecursivelyCall)); |
| 2355 LocalContext env(NULL, global); | 2267 LocalContext env(NULL, global); |
| 2356 | 2268 |
| 2357 env->Global()->Set(v8_str("depth"), v8::Integer::New(0)); | 2269 env->Global()->Set(v8_str("depth"), v8::Integer::New(0)); |
| 2358 call_recursively_script = v8_compile("callScriptRecursively()"); | 2270 call_recursively_script = v8_compile("callScriptRecursively()"); |
| 2359 call_recursively_script->Run(); | 2271 call_recursively_script->Run(); |
| 2360 call_recursively_script = v8::Handle<Script>(); | 2272 call_recursively_script = v8::Handle<Script>(); |
| 2361 | 2273 |
| 2362 env->Global()->Set(v8_str("depth"), v8::Integer::New(0)); | 2274 env->Global()->Set(v8_str("depth"), v8::Integer::New(0)); |
| 2363 Script::Compile(v8_str("callFunctionRecursively()"))->Run(); | 2275 Script::Compile(v8_str("callFunctionRecursively()"))->Run(); |
| 2364 } | 2276 } |
| 2365 | 2277 |
| 2366 | 2278 |
| 2367 static v8::Handle<Value> | 2279 static void ThrowingPropertyHandlerGet( |
| 2368 ThrowingPropertyHandlerGet(Local<String> key, const AccessorInfo&) { | 2280 Local<String> key, |
| 2281 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 2369 ApiTestFuzzer::Fuzz(); | 2282 ApiTestFuzzer::Fuzz(); |
| 2370 return v8::ThrowException(key); | 2283 info.GetReturnValue().Set(v8::ThrowException(key)); |
| 2371 } | 2284 } |
| 2372 | 2285 |
| 2373 | 2286 |
| 2374 static v8::Handle<Value> ThrowingPropertyHandlerSet(Local<String> key, | 2287 static void ThrowingPropertyHandlerSet( |
| 2375 Local<Value>, | 2288 Local<String> key, |
| 2376 const AccessorInfo&) { | 2289 Local<Value>, |
| 2290 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 2377 v8::ThrowException(key); | 2291 v8::ThrowException(key); |
| 2378 return v8::Undefined(); // not the same as v8::Handle<v8::Value>() | 2292 info.GetReturnValue().SetUndefined(); // not the same as empty handle |
| 2379 } | 2293 } |
| 2380 | 2294 |
| 2381 | 2295 |
| 2382 THREADED_TEST(CallbackExceptionRegression) { | 2296 THREADED_TEST(CallbackExceptionRegression) { |
| 2383 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2297 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 2384 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 2298 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 2385 obj->SetNamedPropertyHandler(ThrowingPropertyHandlerGet, | 2299 obj->SetNamedPropertyHandler(ThrowingPropertyHandlerGet, |
| 2386 ThrowingPropertyHandlerSet); | 2300 ThrowingPropertyHandlerSet); |
| 2387 LocalContext env; | 2301 LocalContext env; |
| 2388 env->Global()->Set(v8_str("obj"), obj->NewInstance()); | 2302 env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2973 // Make sure that the getter and setter from Object.prototype is not invoked. | 2887 // Make sure that the getter and setter from Object.prototype is not invoked. |
| 2974 // If it did we would have full access to the hidden properties in | 2888 // If it did we would have full access to the hidden properties in |
| 2975 // the accessor. | 2889 // the accessor. |
| 2976 CHECK(obj->SetHiddenValue(key, v8::Integer::New(42))); | 2890 CHECK(obj->SetHiddenValue(key, v8::Integer::New(42))); |
| 2977 ExpectFalse("set_called"); | 2891 ExpectFalse("set_called"); |
| 2978 CHECK_EQ(42, obj->GetHiddenValue(key)->Int32Value()); | 2892 CHECK_EQ(42, obj->GetHiddenValue(key)->Int32Value()); |
| 2979 } | 2893 } |
| 2980 | 2894 |
| 2981 | 2895 |
| 2982 static bool interceptor_for_hidden_properties_called; | 2896 static bool interceptor_for_hidden_properties_called; |
| 2983 static v8::Handle<Value> InterceptorForHiddenProperties( | 2897 static void InterceptorForHiddenProperties( |
| 2984 Local<String> name, const AccessorInfo& info) { | 2898 Local<String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 2985 interceptor_for_hidden_properties_called = true; | 2899 interceptor_for_hidden_properties_called = true; |
| 2986 return v8::Handle<Value>(); | |
| 2987 } | 2900 } |
| 2988 | 2901 |
| 2989 | 2902 |
| 2990 THREADED_TEST(HiddenPropertiesWithInterceptors) { | 2903 THREADED_TEST(HiddenPropertiesWithInterceptors) { |
| 2991 LocalContext context; | 2904 LocalContext context; |
| 2992 v8::HandleScope scope(context->GetIsolate()); | 2905 v8::HandleScope scope(context->GetIsolate()); |
| 2993 | 2906 |
| 2994 interceptor_for_hidden_properties_called = false; | 2907 interceptor_for_hidden_properties_called = false; |
| 2995 | 2908 |
| 2996 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); | 2909 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3696 CHECK_EQ(1, arr->Get(0)->Int32Value()); | 3609 CHECK_EQ(1, arr->Get(0)->Int32Value()); |
| 3697 CHECK_EQ(2, arr->Get(1)->Int32Value()); | 3610 CHECK_EQ(2, arr->Get(1)->Int32Value()); |
| 3698 CHECK_EQ(3, arr->Get(2)->Int32Value()); | 3611 CHECK_EQ(3, arr->Get(2)->Int32Value()); |
| 3699 array = v8::Array::New(27); | 3612 array = v8::Array::New(27); |
| 3700 CHECK_EQ(27, array->Length()); | 3613 CHECK_EQ(27, array->Length()); |
| 3701 array = v8::Array::New(-27); | 3614 array = v8::Array::New(-27); |
| 3702 CHECK_EQ(0, array->Length()); | 3615 CHECK_EQ(0, array->Length()); |
| 3703 } | 3616 } |
| 3704 | 3617 |
| 3705 | 3618 |
| 3706 v8::Handle<Value> HandleF(const v8::Arguments& args) { | 3619 void HandleF(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 3707 v8::HandleScope scope(args.GetIsolate()); | 3620 v8::HandleScope scope(args.GetIsolate()); |
| 3708 ApiTestFuzzer::Fuzz(); | 3621 ApiTestFuzzer::Fuzz(); |
| 3709 Local<v8::Array> result = v8::Array::New(args.Length()); | 3622 Local<v8::Array> result = v8::Array::New(args.Length()); |
| 3710 for (int i = 0; i < args.Length(); i++) | 3623 for (int i = 0; i < args.Length(); i++) |
| 3711 result->Set(i, args[i]); | 3624 result->Set(i, args[i]); |
| 3712 return scope.Close(result); | 3625 args.GetReturnValue().Set(scope.Close(result)); |
| 3713 } | 3626 } |
| 3714 | 3627 |
| 3715 | 3628 |
| 3716 THREADED_TEST(Vector) { | 3629 THREADED_TEST(Vector) { |
| 3717 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 3630 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 3718 Local<ObjectTemplate> global = ObjectTemplate::New(); | 3631 Local<ObjectTemplate> global = ObjectTemplate::New(); |
| 3719 global->Set(v8_str("f"), v8::FunctionTemplate::New(HandleF)); | 3632 global->Set(v8_str("f"), v8::FunctionTemplate::New(HandleF)); |
| 3720 LocalContext context(0, global); | 3633 LocalContext context(0, global); |
| 3721 | 3634 |
| 3722 const char* fun = "f()"; | 3635 const char* fun = "f()"; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3826 Local<Script> script = | 3739 Local<Script> script = |
| 3827 Script::Compile(String::New(js_code_causing_out_of_memory)); | 3740 Script::Compile(String::New(js_code_causing_out_of_memory)); |
| 3828 Local<Value> result = script->Run(); | 3741 Local<Value> result = script->Run(); |
| 3829 | 3742 |
| 3830 // Check for out of memory state. | 3743 // Check for out of memory state. |
| 3831 CHECK(result.IsEmpty()); | 3744 CHECK(result.IsEmpty()); |
| 3832 CHECK(context->HasOutOfMemoryException()); | 3745 CHECK(context->HasOutOfMemoryException()); |
| 3833 } | 3746 } |
| 3834 | 3747 |
| 3835 | 3748 |
| 3836 v8::Handle<Value> ProvokeOutOfMemory(const v8::Arguments& args) { | 3749 void ProvokeOutOfMemory(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 3837 ApiTestFuzzer::Fuzz(); | 3750 ApiTestFuzzer::Fuzz(); |
| 3838 | 3751 |
| 3839 LocalContext context; | 3752 LocalContext context; |
| 3840 v8::HandleScope scope(context->GetIsolate()); | 3753 v8::HandleScope scope(context->GetIsolate()); |
| 3841 Local<Script> script = | 3754 Local<Script> script = |
| 3842 Script::Compile(String::New(js_code_causing_out_of_memory)); | 3755 Script::Compile(String::New(js_code_causing_out_of_memory)); |
| 3843 Local<Value> result = script->Run(); | 3756 Local<Value> result = script->Run(); |
| 3844 | 3757 |
| 3845 // Check for out of memory state. | 3758 // Check for out of memory state. |
| 3846 CHECK(result.IsEmpty()); | 3759 CHECK(result.IsEmpty()); |
| 3847 CHECK(context->HasOutOfMemoryException()); | 3760 CHECK(context->HasOutOfMemoryException()); |
| 3848 | 3761 |
| 3849 return result; | 3762 args.GetReturnValue().Set(result); |
| 3850 } | 3763 } |
| 3851 | 3764 |
| 3852 | 3765 |
| 3853 TEST(OutOfMemoryNested) { | 3766 TEST(OutOfMemoryNested) { |
| 3854 // It's not possible to read a snapshot into a heap with different dimensions. | 3767 // It's not possible to read a snapshot into a heap with different dimensions. |
| 3855 if (i::Snapshot::IsEnabled()) return; | 3768 if (i::Snapshot::IsEnabled()) return; |
| 3856 // Set heap limits. | 3769 // Set heap limits. |
| 3857 static const int K = 1024; | 3770 static const int K = 1024; |
| 3858 v8::ResourceConstraints constraints; | 3771 v8::ResourceConstraints constraints; |
| 3859 constraints.set_max_young_space_size(256 * K); | 3772 constraints.set_max_young_space_size(256 * K); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4112 double number_value = obj->NumberValue(); | 4025 double number_value = obj->NumberValue(); |
| 4113 CHECK_NE(0, std::isnan(number_value)); | 4026 CHECK_NE(0, std::isnan(number_value)); |
| 4114 CheckUncle(&try_catch); | 4027 CheckUncle(&try_catch); |
| 4115 | 4028 |
| 4116 int64_t integer_value = obj->IntegerValue(); | 4029 int64_t integer_value = obj->IntegerValue(); |
| 4117 CHECK_EQ(0.0, static_cast<double>(integer_value)); | 4030 CHECK_EQ(0.0, static_cast<double>(integer_value)); |
| 4118 CheckUncle(&try_catch); | 4031 CheckUncle(&try_catch); |
| 4119 } | 4032 } |
| 4120 | 4033 |
| 4121 | 4034 |
| 4122 v8::Handle<Value> ThrowFromC(const v8::Arguments& args) { | 4035 void ThrowFromC(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4123 ApiTestFuzzer::Fuzz(); | 4036 ApiTestFuzzer::Fuzz(); |
| 4124 return v8::ThrowException(v8_str("konto")); | 4037 v8::ThrowException(v8_str("konto")); |
| 4125 } | 4038 } |
| 4126 | 4039 |
| 4127 | 4040 |
| 4128 v8::Handle<Value> CCatcher(const v8::Arguments& args) { | 4041 void CCatcher(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4129 if (args.Length() < 1) return v8::False(); | 4042 if (args.Length() < 1) { |
| 4043 args.GetReturnValue().Set(false); |
| 4044 return; |
| 4045 } |
| 4130 v8::HandleScope scope(args.GetIsolate()); | 4046 v8::HandleScope scope(args.GetIsolate()); |
| 4131 v8::TryCatch try_catch; | 4047 v8::TryCatch try_catch; |
| 4132 Local<Value> result = v8::Script::Compile(args[0]->ToString())->Run(); | 4048 Local<Value> result = v8::Script::Compile(args[0]->ToString())->Run(); |
| 4133 CHECK(!try_catch.HasCaught() || result.IsEmpty()); | 4049 CHECK(!try_catch.HasCaught() || result.IsEmpty()); |
| 4134 return v8::Boolean::New(try_catch.HasCaught()); | 4050 args.GetReturnValue().Set(try_catch.HasCaught()); |
| 4135 } | 4051 } |
| 4136 | 4052 |
| 4137 | 4053 |
| 4138 THREADED_TEST(APICatch) { | 4054 THREADED_TEST(APICatch) { |
| 4139 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4055 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 4140 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4056 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4141 templ->Set(v8_str("ThrowFromC"), | 4057 templ->Set(v8_str("ThrowFromC"), |
| 4142 v8::FunctionTemplate::New(ThrowFromC)); | 4058 v8::FunctionTemplate::New(ThrowFromC)); |
| 4143 LocalContext context(0, templ); | 4059 LocalContext context(0, templ); |
| 4144 CompileRun( | 4060 CompileRun( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4190 | 4106 |
| 4191 | 4107 |
| 4192 static void check_reference_error_message( | 4108 static void check_reference_error_message( |
| 4193 v8::Handle<v8::Message> message, | 4109 v8::Handle<v8::Message> message, |
| 4194 v8::Handle<v8::Value> data) { | 4110 v8::Handle<v8::Value> data) { |
| 4195 const char* reference_error = "Uncaught ReferenceError: asdf is not defined"; | 4111 const char* reference_error = "Uncaught ReferenceError: asdf is not defined"; |
| 4196 CHECK(message->Get()->Equals(v8_str(reference_error))); | 4112 CHECK(message->Get()->Equals(v8_str(reference_error))); |
| 4197 } | 4113 } |
| 4198 | 4114 |
| 4199 | 4115 |
| 4200 static v8::Handle<Value> Fail(const v8::Arguments& args) { | 4116 static void Fail(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4201 ApiTestFuzzer::Fuzz(); | 4117 ApiTestFuzzer::Fuzz(); |
| 4202 CHECK(false); | 4118 CHECK(false); |
| 4203 return v8::Undefined(); | |
| 4204 } | 4119 } |
| 4205 | 4120 |
| 4206 | 4121 |
| 4207 // Test that overwritten methods are not invoked on uncaught exception | 4122 // Test that overwritten methods are not invoked on uncaught exception |
| 4208 // formatting. However, they are invoked when performing normal error | 4123 // formatting. However, they are invoked when performing normal error |
| 4209 // string conversions. | 4124 // string conversions. |
| 4210 TEST(APIThrowMessageOverwrittenToString) { | 4125 TEST(APIThrowMessageOverwrittenToString) { |
| 4211 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4126 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 4212 v8::V8::AddMessageListener(check_reference_error_message); | 4127 v8::V8::AddMessageListener(check_reference_error_message); |
| 4213 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4128 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4337 = Script::Compile(v8_str("ThrowFromC(); throw 'panama';")); | 4252 = Script::Compile(v8_str("ThrowFromC(); throw 'panama';")); |
| 4338 Local<Value> result = script->Run(); | 4253 Local<Value> result = script->Run(); |
| 4339 CHECK(result.IsEmpty()); | 4254 CHECK(result.IsEmpty()); |
| 4340 CHECK(try_catch.HasCaught()); | 4255 CHECK(try_catch.HasCaught()); |
| 4341 String::Utf8Value exception_value(try_catch.Exception()); | 4256 String::Utf8Value exception_value(try_catch.Exception()); |
| 4342 CHECK_EQ("konto", *exception_value); | 4257 CHECK_EQ("konto", *exception_value); |
| 4343 } | 4258 } |
| 4344 | 4259 |
| 4345 | 4260 |
| 4346 | 4261 |
| 4347 v8::Handle<Value> CThrowCountDown(const v8::Arguments& args) { | 4262 void CThrowCountDown(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4348 ApiTestFuzzer::Fuzz(); | 4263 ApiTestFuzzer::Fuzz(); |
| 4349 CHECK_EQ(4, args.Length()); | 4264 CHECK_EQ(4, args.Length()); |
| 4350 int count = args[0]->Int32Value(); | 4265 int count = args[0]->Int32Value(); |
| 4351 int cInterval = args[2]->Int32Value(); | 4266 int cInterval = args[2]->Int32Value(); |
| 4352 if (count == 0) { | 4267 if (count == 0) { |
| 4353 return v8::ThrowException(v8_str("FromC")); | 4268 v8::ThrowException(v8_str("FromC")); |
| 4269 return; |
| 4354 } else { | 4270 } else { |
| 4355 Local<v8::Object> global = Context::GetCurrent()->Global(); | 4271 Local<v8::Object> global = Context::GetCurrent()->Global(); |
| 4356 Local<Value> fun = global->Get(v8_str("JSThrowCountDown")); | 4272 Local<Value> fun = global->Get(v8_str("JSThrowCountDown")); |
| 4357 v8::Handle<Value> argv[] = { v8_num(count - 1), | 4273 v8::Handle<Value> argv[] = { v8_num(count - 1), |
| 4358 args[1], | 4274 args[1], |
| 4359 args[2], | 4275 args[2], |
| 4360 args[3] }; | 4276 args[3] }; |
| 4361 if (count % cInterval == 0) { | 4277 if (count % cInterval == 0) { |
| 4362 v8::TryCatch try_catch; | 4278 v8::TryCatch try_catch; |
| 4363 Local<Value> result = fun.As<Function>()->Call(global, 4, argv); | 4279 Local<Value> result = fun.As<Function>()->Call(global, 4, argv); |
| 4364 int expected = args[3]->Int32Value(); | 4280 int expected = args[3]->Int32Value(); |
| 4365 if (try_catch.HasCaught()) { | 4281 if (try_catch.HasCaught()) { |
| 4366 CHECK_EQ(expected, count); | 4282 CHECK_EQ(expected, count); |
| 4367 CHECK(result.IsEmpty()); | 4283 CHECK(result.IsEmpty()); |
| 4368 CHECK(!i::Isolate::Current()->has_scheduled_exception()); | 4284 CHECK(!i::Isolate::Current()->has_scheduled_exception()); |
| 4369 } else { | 4285 } else { |
| 4370 CHECK_NE(expected, count); | 4286 CHECK_NE(expected, count); |
| 4371 } | 4287 } |
| 4372 return result; | 4288 args.GetReturnValue().Set(result); |
| 4289 return; |
| 4373 } else { | 4290 } else { |
| 4374 return fun.As<Function>()->Call(global, 4, argv); | 4291 args.GetReturnValue().Set(fun.As<Function>()->Call(global, 4, argv)); |
| 4292 return; |
| 4375 } | 4293 } |
| 4376 } | 4294 } |
| 4377 } | 4295 } |
| 4378 | 4296 |
| 4379 | 4297 |
| 4380 v8::Handle<Value> JSCheck(const v8::Arguments& args) { | 4298 void JSCheck(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4381 ApiTestFuzzer::Fuzz(); | 4299 ApiTestFuzzer::Fuzz(); |
| 4382 CHECK_EQ(3, args.Length()); | 4300 CHECK_EQ(3, args.Length()); |
| 4383 bool equality = args[0]->BooleanValue(); | 4301 bool equality = args[0]->BooleanValue(); |
| 4384 int count = args[1]->Int32Value(); | 4302 int count = args[1]->Int32Value(); |
| 4385 int expected = args[2]->Int32Value(); | 4303 int expected = args[2]->Int32Value(); |
| 4386 if (equality) { | 4304 if (equality) { |
| 4387 CHECK_EQ(count, expected); | 4305 CHECK_EQ(count, expected); |
| 4388 } else { | 4306 } else { |
| 4389 CHECK_NE(count, expected); | 4307 CHECK_NE(count, expected); |
| 4390 } | 4308 } |
| 4391 return v8::Undefined(); | |
| 4392 } | 4309 } |
| 4393 | 4310 |
| 4394 | 4311 |
| 4395 THREADED_TEST(EvalInTryFinally) { | 4312 THREADED_TEST(EvalInTryFinally) { |
| 4396 LocalContext context; | 4313 LocalContext context; |
| 4397 v8::HandleScope scope(context->GetIsolate()); | 4314 v8::HandleScope scope(context->GetIsolate()); |
| 4398 v8::TryCatch try_catch; | 4315 v8::TryCatch try_catch; |
| 4399 CompileRun("(function() {" | 4316 CompileRun("(function() {" |
| 4400 " try {" | 4317 " try {" |
| 4401 " eval('asldkf (*&^&*^');" | 4318 " eval('asldkf (*&^&*^');" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4476 | 4393 |
| 4477 // JS[6] *C[5] @JS[4] C[3] JS[2] C[1] JS[0] | 4394 // JS[6] *C[5] @JS[4] C[3] JS[2] C[1] JS[0] |
| 4478 v8::Handle<Value> a4[argc] = { v8_num(6), v8_num(4), v8_num(5), v8_num(4) }; | 4395 v8::Handle<Value> a4[argc] = { v8_num(6), v8_num(4), v8_num(5), v8_num(4) }; |
| 4479 fun->Call(fun, argc, a4); | 4396 fun->Call(fun, argc, a4); |
| 4480 | 4397 |
| 4481 // JS[6] C[5] *JS[4] @C[3] JS[2] C[1] JS[0] | 4398 // JS[6] C[5] *JS[4] @C[3] JS[2] C[1] JS[0] |
| 4482 v8::Handle<Value> a5[argc] = { v8_num(6), v8_num(4), v8_num(3), v8_num(3) }; | 4399 v8::Handle<Value> a5[argc] = { v8_num(6), v8_num(4), v8_num(3), v8_num(3) }; |
| 4483 fun->Call(fun, argc, a5); | 4400 fun->Call(fun, argc, a5); |
| 4484 } | 4401 } |
| 4485 | 4402 |
| 4486 | 4403 void ThrowValue(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4487 v8::Handle<Value> ThrowValue(const v8::Arguments& args) { | |
| 4488 ApiTestFuzzer::Fuzz(); | 4404 ApiTestFuzzer::Fuzz(); |
| 4489 CHECK_EQ(1, args.Length()); | 4405 CHECK_EQ(1, args.Length()); |
| 4490 return v8::ThrowException(args[0]); | 4406 v8::ThrowException(args[0]); |
| 4491 } | 4407 } |
| 4492 | 4408 |
| 4493 | 4409 |
| 4494 THREADED_TEST(ThrowValues) { | 4410 THREADED_TEST(ThrowValues) { |
| 4495 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4411 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 4496 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4412 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4497 templ->Set(v8_str("Throw"), v8::FunctionTemplate::New(ThrowValue)); | 4413 templ->Set(v8_str("Throw"), v8::FunctionTemplate::New(ThrowValue)); |
| 4498 LocalContext context(0, templ); | 4414 LocalContext context(0, templ); |
| 4499 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( | 4415 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( |
| 4500 "function Run(obj) {" | 4416 "function Run(obj) {" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4547 LocalContext context; | 4463 LocalContext context; |
| 4548 v8::HandleScope scope(context->GetIsolate()); | 4464 v8::HandleScope scope(context->GetIsolate()); |
| 4549 v8::TryCatch try_catch; | 4465 v8::TryCatch try_catch; |
| 4550 CHECK(!try_catch.HasCaught()); | 4466 CHECK(!try_catch.HasCaught()); |
| 4551 CompileRun("function f(k) { try { this[k]; } finally { return 0; } };"); | 4467 CompileRun("function f(k) { try { this[k]; } finally { return 0; } };"); |
| 4552 CompileRun("f({toString: function() { throw 42; }});"); | 4468 CompileRun("f({toString: function() { throw 42; }});"); |
| 4553 CHECK(!try_catch.HasCaught()); | 4469 CHECK(!try_catch.HasCaught()); |
| 4554 } | 4470 } |
| 4555 | 4471 |
| 4556 | 4472 |
| 4557 v8::Handle<v8::Value> WithTryCatch(const v8::Arguments& args) { | 4473 void WithTryCatch(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4558 v8::TryCatch try_catch; | 4474 v8::TryCatch try_catch; |
| 4559 return v8::Undefined(); | |
| 4560 } | 4475 } |
| 4561 | 4476 |
| 4562 | 4477 |
| 4563 THREADED_TEST(TryCatchAndFinally) { | 4478 THREADED_TEST(TryCatchAndFinally) { |
| 4564 LocalContext context; | 4479 LocalContext context; |
| 4565 v8::HandleScope scope(context->GetIsolate()); | 4480 v8::HandleScope scope(context->GetIsolate()); |
| 4566 context->Global()->Set( | 4481 context->Global()->Set( |
| 4567 v8_str("native_with_try_catch"), | 4482 v8_str("native_with_try_catch"), |
| 4568 v8::FunctionTemplate::New(WithTryCatch)->GetFunction()); | 4483 v8::FunctionTemplate::New(WithTryCatch)->GetFunction()); |
| 4569 v8::TryCatch try_catch; | 4484 v8::TryCatch try_catch; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4637 | 4552 |
| 4638 THREADED_TEST(MultiRun) { | 4553 THREADED_TEST(MultiRun) { |
| 4639 LocalContext context; | 4554 LocalContext context; |
| 4640 v8::HandleScope scope(context->GetIsolate()); | 4555 v8::HandleScope scope(context->GetIsolate()); |
| 4641 Local<Script> script = Script::Compile(v8_str("x")); | 4556 Local<Script> script = Script::Compile(v8_str("x")); |
| 4642 for (int i = 0; i < 10; i++) | 4557 for (int i = 0; i < 10; i++) |
| 4643 script->Run(); | 4558 script->Run(); |
| 4644 } | 4559 } |
| 4645 | 4560 |
| 4646 | 4561 |
| 4647 static v8::Handle<Value> GetXValue(Local<String> name, | 4562 static void GetXValue(Local<String> name, |
| 4648 const AccessorInfo& info) { | 4563 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 4649 ApiTestFuzzer::Fuzz(); | 4564 ApiTestFuzzer::Fuzz(); |
| 4650 CHECK_EQ(info.Data(), v8_str("donut")); | 4565 CHECK_EQ(info.Data(), v8_str("donut")); |
| 4651 CHECK_EQ(name, v8_str("x")); | 4566 CHECK_EQ(name, v8_str("x")); |
| 4652 return name; | 4567 info.GetReturnValue().Set(name); |
| 4653 } | 4568 } |
| 4654 | 4569 |
| 4655 | 4570 |
| 4656 THREADED_TEST(SimplePropertyRead) { | 4571 THREADED_TEST(SimplePropertyRead) { |
| 4657 LocalContext context; | 4572 LocalContext context; |
| 4658 v8::HandleScope scope(context->GetIsolate()); | 4573 v8::HandleScope scope(context->GetIsolate()); |
| 4659 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4574 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4660 templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")); | 4575 templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")); |
| 4661 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 4576 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 4662 Local<Script> script = Script::Compile(v8_str("obj.x")); | 4577 Local<Script> script = Script::Compile(v8_str("obj.x")); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4879 v8::TryCatch try_catch; | 4794 v8::TryCatch try_catch; |
| 4880 CompileRun("Object.defineProperty(obj2, 'x'," | 4795 CompileRun("Object.defineProperty(obj2, 'x'," |
| 4881 "{get: function() { return 'func'; }})"); | 4796 "{get: function() { return 'func'; }})"); |
| 4882 CHECK(try_catch.HasCaught()); | 4797 CHECK(try_catch.HasCaught()); |
| 4883 String::Utf8Value exception_value(try_catch.Exception()); | 4798 String::Utf8Value exception_value(try_catch.Exception()); |
| 4884 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); | 4799 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); |
| 4885 } | 4800 } |
| 4886 } | 4801 } |
| 4887 | 4802 |
| 4888 | 4803 |
| 4889 static v8::Handle<Value> Get239Value(Local<String> name, | 4804 static void Get239Value(Local<String> name, |
| 4890 const AccessorInfo& info) { | 4805 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 4891 ApiTestFuzzer::Fuzz(); | 4806 ApiTestFuzzer::Fuzz(); |
| 4892 CHECK_EQ(info.Data(), v8_str("donut")); | 4807 CHECK_EQ(info.Data(), v8_str("donut")); |
| 4893 CHECK_EQ(name, v8_str("239")); | 4808 CHECK_EQ(name, v8_str("239")); |
| 4894 return name; | 4809 info.GetReturnValue().Set(name); |
| 4895 } | 4810 } |
| 4896 | 4811 |
| 4897 | 4812 |
| 4898 THREADED_TEST(ElementAPIAccessor) { | 4813 THREADED_TEST(ElementAPIAccessor) { |
| 4899 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4814 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 4900 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4815 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4901 LocalContext context; | 4816 LocalContext context; |
| 4902 | 4817 |
| 4903 context->Global()->Set(v8_str("obj1"), templ->NewInstance()); | 4818 context->Global()->Set(v8_str("obj1"), templ->NewInstance()); |
| 4904 CompileRun("var obj2 = {};"); | 4819 CompileRun("var obj2 = {};"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4917 ExpectString("obj1['239']", "239"); | 4832 ExpectString("obj1['239']", "239"); |
| 4918 ExpectString("obj2['239']", "239"); | 4833 ExpectString("obj2['239']", "239"); |
| 4919 } | 4834 } |
| 4920 | 4835 |
| 4921 | 4836 |
| 4922 v8::Persistent<Value> xValue; | 4837 v8::Persistent<Value> xValue; |
| 4923 | 4838 |
| 4924 | 4839 |
| 4925 static void SetXValue(Local<String> name, | 4840 static void SetXValue(Local<String> name, |
| 4926 Local<Value> value, | 4841 Local<Value> value, |
| 4927 const AccessorInfo& info) { | 4842 const v8::PropertyCallbackInfo<void>& info) { |
| 4928 CHECK_EQ(value, v8_num(4)); | 4843 CHECK_EQ(value, v8_num(4)); |
| 4929 CHECK_EQ(info.Data(), v8_str("donut")); | 4844 CHECK_EQ(info.Data(), v8_str("donut")); |
| 4930 CHECK_EQ(name, v8_str("x")); | 4845 CHECK_EQ(name, v8_str("x")); |
| 4931 CHECK(xValue.IsEmpty()); | 4846 CHECK(xValue.IsEmpty()); |
| 4932 xValue.Reset(info.GetIsolate(), value); | 4847 xValue.Reset(info.GetIsolate(), value); |
| 4933 } | 4848 } |
| 4934 | 4849 |
| 4935 | 4850 |
| 4936 THREADED_TEST(SimplePropertyWrite) { | 4851 THREADED_TEST(SimplePropertyWrite) { |
| 4937 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4852 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 4964 xValue.Dispose(context->GetIsolate()); | 4879 xValue.Dispose(context->GetIsolate()); |
| 4965 xValue.Clear(); | 4880 xValue.Clear(); |
| 4966 } | 4881 } |
| 4967 } | 4882 } |
| 4968 | 4883 |
| 4969 | 4884 |
| 4970 THREADED_TEST(NoAccessors) { | 4885 THREADED_TEST(NoAccessors) { |
| 4971 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4886 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 4972 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4887 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4973 templ->SetAccessor(v8_str("x"), | 4888 templ->SetAccessor(v8_str("x"), |
| 4974 static_cast<v8::AccessorGetter>(NULL), | 4889 static_cast<v8::AccessorGetterCallback>(NULL), |
| 4975 NULL, | 4890 NULL, |
| 4976 v8_str("donut")); | 4891 v8_str("donut")); |
| 4977 LocalContext context; | 4892 LocalContext context; |
| 4978 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 4893 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 4979 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); | 4894 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); |
| 4980 for (int i = 0; i < 10; i++) { | 4895 for (int i = 0; i < 10; i++) { |
| 4981 script->Run(); | 4896 script->Run(); |
| 4982 } | 4897 } |
| 4983 } | 4898 } |
| 4984 | 4899 |
| 4985 | 4900 |
| 4986 static v8::Handle<Value> XPropertyGetter(Local<String> property, | 4901 static void XPropertyGetter(Local<String> property, |
| 4987 const AccessorInfo& info) { | 4902 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 4988 ApiTestFuzzer::Fuzz(); | 4903 ApiTestFuzzer::Fuzz(); |
| 4989 CHECK(info.Data()->IsUndefined()); | 4904 CHECK(info.Data()->IsUndefined()); |
| 4990 return property; | 4905 info.GetReturnValue().Set(property); |
| 4991 } | 4906 } |
| 4992 | 4907 |
| 4993 | 4908 |
| 4994 THREADED_TEST(NamedInterceptorPropertyRead) { | 4909 THREADED_TEST(NamedInterceptorPropertyRead) { |
| 4995 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4910 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 4996 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4911 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4997 templ->SetNamedPropertyHandler(XPropertyGetter); | 4912 templ->SetNamedPropertyHandler(XPropertyGetter); |
| 4998 LocalContext context; | 4913 LocalContext context; |
| 4999 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 4914 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 5000 Local<Script> script = Script::Compile(v8_str("obj.x")); | 4915 Local<Script> script = Script::Compile(v8_str("obj.x")); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5069 } | 4984 } |
| 5070 | 4985 |
| 5071 // Return to the original context and force some object to the slow case | 4986 // Return to the original context and force some object to the slow case |
| 5072 // to cause the NormalizedMapCache to verify. | 4987 // to cause the NormalizedMapCache to verify. |
| 5073 context1->Enter(); | 4988 context1->Enter(); |
| 5074 CompileRun("var obj = { x : 0 }; delete obj.x;"); | 4989 CompileRun("var obj = { x : 0 }; delete obj.x;"); |
| 5075 context1->Exit(); | 4990 context1->Exit(); |
| 5076 } | 4991 } |
| 5077 | 4992 |
| 5078 | 4993 |
| 5079 static v8::Handle<Value> SetXOnPrototypeGetter(Local<String> property, | 4994 static void SetXOnPrototypeGetter( |
| 5080 const AccessorInfo& info) { | 4995 Local<String> property, |
| 4996 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 5081 // Set x on the prototype object and do not handle the get request. | 4997 // Set x on the prototype object and do not handle the get request. |
| 5082 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); | 4998 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); |
| 5083 proto.As<v8::Object>()->Set(v8_str("x"), v8::Integer::New(23)); | 4999 proto.As<v8::Object>()->Set(v8_str("x"), v8::Integer::New(23)); |
| 5084 return v8::Handle<Value>(); | |
| 5085 } | 5000 } |
| 5086 | 5001 |
| 5087 | 5002 |
| 5088 // This is a regression test for http://crbug.com/20104. Map | 5003 // This is a regression test for http://crbug.com/20104. Map |
| 5089 // transitions should not interfere with post interceptor lookup. | 5004 // transitions should not interfere with post interceptor lookup. |
| 5090 THREADED_TEST(NamedInterceptorMapTransitionRead) { | 5005 THREADED_TEST(NamedInterceptorMapTransitionRead) { |
| 5091 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5006 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 5092 Local<v8::FunctionTemplate> function_template = v8::FunctionTemplate::New(); | 5007 Local<v8::FunctionTemplate> function_template = v8::FunctionTemplate::New(); |
| 5093 Local<v8::ObjectTemplate> instance_template | 5008 Local<v8::ObjectTemplate> instance_template |
| 5094 = function_template->InstanceTemplate(); | 5009 = function_template->InstanceTemplate(); |
| 5095 instance_template->SetNamedPropertyHandler(SetXOnPrototypeGetter); | 5010 instance_template->SetNamedPropertyHandler(SetXOnPrototypeGetter); |
| 5096 LocalContext context; | 5011 LocalContext context; |
| 5097 context->Global()->Set(v8_str("F"), function_template->GetFunction()); | 5012 context->Global()->Set(v8_str("F"), function_template->GetFunction()); |
| 5098 // Create an instance of F and introduce a map transition for x. | 5013 // Create an instance of F and introduce a map transition for x. |
| 5099 CompileRun("var o = new F(); o.x = 23;"); | 5014 CompileRun("var o = new F(); o.x = 23;"); |
| 5100 // Create an instance of F and invoke the getter. The result should be 23. | 5015 // Create an instance of F and invoke the getter. The result should be 23. |
| 5101 Local<Value> result = CompileRun("o = new F(); o.x"); | 5016 Local<Value> result = CompileRun("o = new F(); o.x"); |
| 5102 CHECK_EQ(result->Int32Value(), 23); | 5017 CHECK_EQ(result->Int32Value(), 23); |
| 5103 } | 5018 } |
| 5104 | 5019 |
| 5105 | 5020 |
| 5106 static v8::Handle<Value> IndexedPropertyGetter(uint32_t index, | 5021 static void IndexedPropertyGetter( |
| 5107 const AccessorInfo& info) { | 5022 uint32_t index, |
| 5023 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 5108 ApiTestFuzzer::Fuzz(); | 5024 ApiTestFuzzer::Fuzz(); |
| 5109 if (index == 37) { | 5025 if (index == 37) { |
| 5110 return v8::Handle<Value>(v8_num(625)); | 5026 info.GetReturnValue().Set(v8_num(625)); |
| 5111 } | 5027 } |
| 5112 return v8::Handle<Value>(); | |
| 5113 } | 5028 } |
| 5114 | 5029 |
| 5115 | 5030 |
| 5116 static v8::Handle<Value> IndexedPropertySetter(uint32_t index, | 5031 static void IndexedPropertySetter( |
| 5117 Local<Value> value, | 5032 uint32_t index, |
| 5118 const AccessorInfo& info) { | 5033 Local<Value> value, |
| 5034 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 5119 ApiTestFuzzer::Fuzz(); | 5035 ApiTestFuzzer::Fuzz(); |
| 5120 if (index == 39) { | 5036 if (index == 39) { |
| 5121 return value; | 5037 info.GetReturnValue().Set(value); |
| 5122 } | 5038 } |
| 5123 return v8::Handle<Value>(); | |
| 5124 } | 5039 } |
| 5125 | 5040 |
| 5126 | 5041 |
| 5127 THREADED_TEST(IndexedInterceptorWithIndexedAccessor) { | 5042 THREADED_TEST(IndexedInterceptorWithIndexedAccessor) { |
| 5128 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5043 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 5129 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5044 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5130 templ->SetIndexedPropertyHandler(IndexedPropertyGetter, | 5045 templ->SetIndexedPropertyHandler(IndexedPropertyGetter, |
| 5131 IndexedPropertySetter); | 5046 IndexedPropertySetter); |
| 5132 LocalContext context; | 5047 LocalContext context; |
| 5133 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5048 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5147 CHECK_EQ(v8_num(5), result); | 5062 CHECK_EQ(v8_num(5), result); |
| 5148 result = setter_script->Run(); | 5063 result = setter_script->Run(); |
| 5149 CHECK_EQ(v8_num(23), result); | 5064 CHECK_EQ(v8_num(23), result); |
| 5150 result = interceptor_setter_script->Run(); | 5065 result = interceptor_setter_script->Run(); |
| 5151 CHECK_EQ(v8_num(23), result); | 5066 CHECK_EQ(v8_num(23), result); |
| 5152 result = interceptor_getter_script->Run(); | 5067 result = interceptor_getter_script->Run(); |
| 5153 CHECK_EQ(v8_num(625), result); | 5068 CHECK_EQ(v8_num(625), result); |
| 5154 } | 5069 } |
| 5155 | 5070 |
| 5156 | 5071 |
| 5157 static v8::Handle<Value> UnboxedDoubleIndexedPropertyGetter( | 5072 static void UnboxedDoubleIndexedPropertyGetter( |
| 5158 uint32_t index, | 5073 uint32_t index, |
| 5159 const AccessorInfo& info) { | 5074 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 5160 ApiTestFuzzer::Fuzz(); | 5075 ApiTestFuzzer::Fuzz(); |
| 5161 if (index < 25) { | 5076 if (index < 25) { |
| 5162 return v8::Handle<Value>(v8_num(index)); | 5077 info.GetReturnValue().Set(v8_num(index)); |
| 5163 } | 5078 } |
| 5164 return v8::Handle<Value>(); | |
| 5165 } | 5079 } |
| 5166 | 5080 |
| 5167 | 5081 |
| 5168 static v8::Handle<Value> UnboxedDoubleIndexedPropertySetter( | 5082 static void UnboxedDoubleIndexedPropertySetter( |
| 5169 uint32_t index, | 5083 uint32_t index, |
| 5170 Local<Value> value, | 5084 Local<Value> value, |
| 5171 const AccessorInfo& info) { | 5085 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 5172 ApiTestFuzzer::Fuzz(); | 5086 ApiTestFuzzer::Fuzz(); |
| 5173 if (index < 25) { | 5087 if (index < 25) { |
| 5174 return v8::Handle<Value>(v8_num(index)); | 5088 info.GetReturnValue().Set(v8_num(index)); |
| 5175 } | 5089 } |
| 5176 return v8::Handle<Value>(); | |
| 5177 } | 5090 } |
| 5178 | 5091 |
| 5179 | 5092 |
| 5180 Handle<v8::Array> UnboxedDoubleIndexedPropertyEnumerator( | 5093 void UnboxedDoubleIndexedPropertyEnumerator( |
| 5181 const AccessorInfo& info) { | 5094 const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 5182 // Force the list of returned keys to be stored in a FastDoubleArray. | 5095 // Force the list of returned keys to be stored in a FastDoubleArray. |
| 5183 Local<Script> indexed_property_names_script = Script::Compile(v8_str( | 5096 Local<Script> indexed_property_names_script = Script::Compile(v8_str( |
| 5184 "keys = new Array(); keys[125000] = 1;" | 5097 "keys = new Array(); keys[125000] = 1;" |
| 5185 "for(i = 0; i < 80000; i++) { keys[i] = i; };" | 5098 "for(i = 0; i < 80000; i++) { keys[i] = i; };" |
| 5186 "keys.length = 25; keys;")); | 5099 "keys.length = 25; keys;")); |
| 5187 Local<Value> result = indexed_property_names_script->Run(); | 5100 Local<Value> result = indexed_property_names_script->Run(); |
| 5188 return Local<v8::Array>::Cast(result); | 5101 info.GetReturnValue().Set(Local<v8::Array>::Cast(result)); |
| 5189 } | 5102 } |
| 5190 | 5103 |
| 5191 | 5104 |
| 5192 // Make sure that the the interceptor code in the runtime properly handles | 5105 // Make sure that the the interceptor code in the runtime properly handles |
| 5193 // merging property name lists for double-array-backed arrays. | 5106 // merging property name lists for double-array-backed arrays. |
| 5194 THREADED_TEST(IndexedInterceptorUnboxedDoubleWithIndexedAccessor) { | 5107 THREADED_TEST(IndexedInterceptorUnboxedDoubleWithIndexedAccessor) { |
| 5195 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5108 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 5196 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5109 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5197 templ->SetIndexedPropertyHandler(UnboxedDoubleIndexedPropertyGetter, | 5110 templ->SetIndexedPropertyHandler(UnboxedDoubleIndexedPropertyGetter, |
| 5198 UnboxedDoubleIndexedPropertySetter, | 5111 UnboxedDoubleIndexedPropertySetter, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 5209 "obj;")); | 5122 "obj;")); |
| 5210 Local<Value> result = create_unboxed_double_script->Run(); | 5123 Local<Value> result = create_unboxed_double_script->Run(); |
| 5211 CHECK(result->ToObject()->HasRealIndexedProperty(2000)); | 5124 CHECK(result->ToObject()->HasRealIndexedProperty(2000)); |
| 5212 Local<Script> key_count_check = Script::Compile(v8_str( | 5125 Local<Script> key_count_check = Script::Compile(v8_str( |
| 5213 "key_count;")); | 5126 "key_count;")); |
| 5214 result = key_count_check->Run(); | 5127 result = key_count_check->Run(); |
| 5215 CHECK_EQ(v8_num(40013), result); | 5128 CHECK_EQ(v8_num(40013), result); |
| 5216 } | 5129 } |
| 5217 | 5130 |
| 5218 | 5131 |
| 5219 Handle<v8::Array> NonStrictArgsIndexedPropertyEnumerator( | 5132 void NonStrictArgsIndexedPropertyEnumerator( |
| 5220 const AccessorInfo& info) { | 5133 const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 5221 // Force the list of returned keys to be stored in a Arguments object. | 5134 // Force the list of returned keys to be stored in a Arguments object. |
| 5222 Local<Script> indexed_property_names_script = Script::Compile(v8_str( | 5135 Local<Script> indexed_property_names_script = Script::Compile(v8_str( |
| 5223 "function f(w,x) {" | 5136 "function f(w,x) {" |
| 5224 " return arguments;" | 5137 " return arguments;" |
| 5225 "}" | 5138 "}" |
| 5226 "keys = f(0, 1, 2, 3);" | 5139 "keys = f(0, 1, 2, 3);" |
| 5227 "keys;")); | 5140 "keys;")); |
| 5228 Local<Object> result = | 5141 Local<Object> result = |
| 5229 Local<Object>::Cast(indexed_property_names_script->Run()); | 5142 Local<Object>::Cast(indexed_property_names_script->Run()); |
| 5230 // Have to populate the handle manually, as it's not Cast-able. | 5143 // Have to populate the handle manually, as it's not Cast-able. |
| 5231 i::Handle<i::JSObject> o = | 5144 i::Handle<i::JSObject> o = |
| 5232 v8::Utils::OpenHandle<Object, i::JSObject>(result); | 5145 v8::Utils::OpenHandle<Object, i::JSObject>(result); |
| 5233 i::Handle<i::JSArray> array(reinterpret_cast<i::JSArray*>(*o)); | 5146 i::Handle<i::JSArray> array(reinterpret_cast<i::JSArray*>(*o)); |
| 5234 return v8::Utils::ToLocal(array); | 5147 info.GetReturnValue().Set(v8::Utils::ToLocal(array)); |
| 5235 } | 5148 } |
| 5236 | 5149 |
| 5237 | 5150 |
| 5238 static v8::Handle<Value> NonStrictIndexedPropertyGetter( | 5151 static void NonStrictIndexedPropertyGetter( |
| 5239 uint32_t index, | 5152 uint32_t index, |
| 5240 const AccessorInfo& info) { | 5153 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 5241 ApiTestFuzzer::Fuzz(); | 5154 ApiTestFuzzer::Fuzz(); |
| 5242 if (index < 4) { | 5155 if (index < 4) { |
| 5243 return v8::Handle<Value>(v8_num(index)); | 5156 info.GetReturnValue().Set(v8_num(index)); |
| 5244 } | 5157 } |
| 5245 return v8::Handle<Value>(); | |
| 5246 } | 5158 } |
| 5247 | 5159 |
| 5248 | 5160 |
| 5249 // Make sure that the the interceptor code in the runtime properly handles | 5161 // Make sure that the the interceptor code in the runtime properly handles |
| 5250 // merging property name lists for non-string arguments arrays. | 5162 // merging property name lists for non-string arguments arrays. |
| 5251 THREADED_TEST(IndexedInterceptorNonStrictArgsWithIndexedAccessor) { | 5163 THREADED_TEST(IndexedInterceptorNonStrictArgsWithIndexedAccessor) { |
| 5252 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5164 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 5253 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5165 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5254 templ->SetIndexedPropertyHandler(NonStrictIndexedPropertyGetter, | 5166 templ->SetIndexedPropertyHandler(NonStrictIndexedPropertyGetter, |
| 5255 0, | 5167 0, |
| 5256 0, | 5168 0, |
| 5257 0, | 5169 0, |
| 5258 NonStrictArgsIndexedPropertyEnumerator); | 5170 NonStrictArgsIndexedPropertyEnumerator); |
| 5259 LocalContext context; | 5171 LocalContext context; |
| 5260 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5172 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 5261 Local<Script> create_args_script = | 5173 Local<Script> create_args_script = |
| 5262 Script::Compile(v8_str( | 5174 Script::Compile(v8_str( |
| 5263 "var key_count = 0;" | 5175 "var key_count = 0;" |
| 5264 "for (x in obj) {key_count++;} key_count;")); | 5176 "for (x in obj) {key_count++;} key_count;")); |
| 5265 Local<Value> result = create_args_script->Run(); | 5177 Local<Value> result = create_args_script->Run(); |
| 5266 CHECK_EQ(v8_num(4), result); | 5178 CHECK_EQ(v8_num(4), result); |
| 5267 } | 5179 } |
| 5268 | 5180 |
| 5269 | 5181 |
| 5270 static v8::Handle<Value> IdentityIndexedPropertyGetter( | 5182 static void IdentityIndexedPropertyGetter( |
| 5271 uint32_t index, | 5183 uint32_t index, |
| 5272 const AccessorInfo& info) { | 5184 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 5273 return v8::Integer::NewFromUnsigned(index); | 5185 info.GetReturnValue().Set(index); |
| 5274 } | 5186 } |
| 5275 | 5187 |
| 5276 | 5188 |
| 5277 THREADED_TEST(IndexedInterceptorWithGetOwnPropertyDescriptor) { | 5189 THREADED_TEST(IndexedInterceptorWithGetOwnPropertyDescriptor) { |
| 5278 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5190 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 5279 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5191 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5280 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 5192 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); |
| 5281 | 5193 |
| 5282 LocalContext context; | 5194 LocalContext context; |
| 5283 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5195 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5834 p_str.Dispose(); | 5746 p_str.Dispose(); |
| 5835 Local<Script> scr = Script::Compile(v8_str("")); | 5747 Local<Script> scr = Script::Compile(v8_str("")); |
| 5836 v8::Persistent<Script> p_scr(isolate, scr); | 5748 v8::Persistent<Script> p_scr(isolate, scr); |
| 5837 p_scr.Dispose(); | 5749 p_scr.Dispose(); |
| 5838 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5750 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5839 v8::Persistent<ObjectTemplate> p_templ(isolate, templ); | 5751 v8::Persistent<ObjectTemplate> p_templ(isolate, templ); |
| 5840 p_templ.Dispose(); | 5752 p_templ.Dispose(); |
| 5841 } | 5753 } |
| 5842 | 5754 |
| 5843 | 5755 |
| 5844 static v8::Handle<Value> HandleLogDelegator(const v8::Arguments& args) { | 5756 static void HandleLogDelegator( |
| 5757 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 5845 ApiTestFuzzer::Fuzz(); | 5758 ApiTestFuzzer::Fuzz(); |
| 5846 return v8::Undefined(); | |
| 5847 } | 5759 } |
| 5848 | 5760 |
| 5849 | 5761 |
| 5850 THREADED_TEST(GlobalObjectTemplate) { | 5762 THREADED_TEST(GlobalObjectTemplate) { |
| 5851 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 5763 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 5852 v8::HandleScope handle_scope(isolate); | 5764 v8::HandleScope handle_scope(isolate); |
| 5853 Local<ObjectTemplate> global_template = ObjectTemplate::New(); | 5765 Local<ObjectTemplate> global_template = ObjectTemplate::New(); |
| 5854 global_template->Set(v8_str("JSNI_Log"), | 5766 global_template->Set(v8_str("JSNI_Log"), |
| 5855 v8::FunctionTemplate::New(HandleLogDelegator)); | 5767 v8::FunctionTemplate::New(HandleLogDelegator)); |
| 5856 v8::Local<Context> context = Context::New(isolate, 0, global_template); | 5768 v8::Local<Context> context = Context::New(isolate, 0, global_template); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6071 Context::Scope lock(context); | 5983 Context::Scope lock(context); |
| 6072 v8::Handle<Value> result = Script::Compile(v8_str(kNativeCallTest))->Run(); | 5984 v8::Handle<Value> result = Script::Compile(v8_str(kNativeCallTest))->Run(); |
| 6073 CHECK_EQ(result, v8::Integer::New(3)); | 5985 CHECK_EQ(result, v8::Integer::New(3)); |
| 6074 } | 5986 } |
| 6075 | 5987 |
| 6076 | 5988 |
| 6077 class NativeFunctionExtension : public Extension { | 5989 class NativeFunctionExtension : public Extension { |
| 6078 public: | 5990 public: |
| 6079 NativeFunctionExtension(const char* name, | 5991 NativeFunctionExtension(const char* name, |
| 6080 const char* source, | 5992 const char* source, |
| 6081 v8::InvocationCallback fun = &Echo) | 5993 v8::FunctionCallback fun = &Echo) |
| 6082 : Extension(name, source), | 5994 : Extension(name, source), |
| 6083 function_(fun) { } | 5995 function_(fun) { } |
| 6084 | 5996 |
| 6085 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( | 5997 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( |
| 6086 v8::Handle<v8::String> name) { | 5998 v8::Handle<v8::String> name) { |
| 6087 return v8::FunctionTemplate::New(function_); | 5999 return v8::FunctionTemplate::New(function_); |
| 6088 } | 6000 } |
| 6089 | 6001 |
| 6090 static v8::Handle<v8::Value> Echo(const v8::Arguments& args) { | 6002 static void Echo(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 6091 if (args.Length() >= 1) return (args[0]); | 6003 if (args.Length() >= 1) args.GetReturnValue().Set(args[0]); |
| 6092 return v8::Undefined(); | |
| 6093 } | 6004 } |
| 6094 private: | 6005 private: |
| 6095 v8::InvocationCallback function_; | 6006 v8::FunctionCallback function_; |
| 6096 }; | 6007 }; |
| 6097 | 6008 |
| 6098 | 6009 |
| 6099 THREADED_TEST(NativeFunctionDeclaration) { | 6010 THREADED_TEST(NativeFunctionDeclaration) { |
| 6100 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6011 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
| 6101 const char* name = "nativedecl"; | 6012 const char* name = "nativedecl"; |
| 6102 v8::RegisterExtension(new NativeFunctionExtension(name, | 6013 v8::RegisterExtension(new NativeFunctionExtension(name, |
| 6103 "native function foo();")); | 6014 "native function foo();")); |
| 6104 const char* extension_names[] = { name }; | 6015 const char* extension_names[] = { name }; |
| 6105 v8::ExtensionConfiguration extensions(1, extension_names); | 6016 v8::ExtensionConfiguration extensions(1, extension_names); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6182 "native function A();" | 6093 "native function A();" |
| 6183 "native function B();" | 6094 "native function B();" |
| 6184 "native function C();" | 6095 "native function C();" |
| 6185 "function Foo(i) {" | 6096 "function Foo(i) {" |
| 6186 " if (i == 0) return A();" | 6097 " if (i == 0) return A();" |
| 6187 " if (i == 1) return B();" | 6098 " if (i == 1) return B();" |
| 6188 " if (i == 2) return C();" | 6099 " if (i == 2) return C();" |
| 6189 "}"; | 6100 "}"; |
| 6190 | 6101 |
| 6191 | 6102 |
| 6192 static v8::Handle<Value> CallFun(const v8::Arguments& args) { | 6103 static void CallFun(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 6193 ApiTestFuzzer::Fuzz(); | 6104 ApiTestFuzzer::Fuzz(); |
| 6194 if (args.IsConstructCall()) { | 6105 if (args.IsConstructCall()) { |
| 6195 args.This()->Set(v8_str("data"), args.Data()); | 6106 args.This()->Set(v8_str("data"), args.Data()); |
| 6196 return v8::Null(); | 6107 args.GetReturnValue().SetNull(); |
| 6108 return; |
| 6197 } | 6109 } |
| 6198 return args.Data(); | 6110 args.GetReturnValue().Set(args.Data()); |
| 6199 } | 6111 } |
| 6200 | 6112 |
| 6201 | 6113 |
| 6202 class FunctionExtension : public Extension { | 6114 class FunctionExtension : public Extension { |
| 6203 public: | 6115 public: |
| 6204 FunctionExtension() : Extension("functiontest", kExtensionTestScript) { } | 6116 FunctionExtension() : Extension("functiontest", kExtensionTestScript) { } |
| 6205 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( | 6117 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( |
| 6206 v8::Handle<String> name); | 6118 v8::Handle<String> name); |
| 6207 }; | 6119 }; |
| 6208 | 6120 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6353 v8::Persistent<Script> script_; | 6265 v8::Persistent<Script> script_; |
| 6354 }; | 6266 }; |
| 6355 | 6267 |
| 6356 static void HandleWeakReference(v8::Isolate* isolate, | 6268 static void HandleWeakReference(v8::Isolate* isolate, |
| 6357 v8::Persistent<v8::Value>* obj, | 6269 v8::Persistent<v8::Value>* obj, |
| 6358 Snorkel* snorkel) { | 6270 Snorkel* snorkel) { |
| 6359 delete snorkel; | 6271 delete snorkel; |
| 6360 obj->ClearWeak(isolate); | 6272 obj->ClearWeak(isolate); |
| 6361 } | 6273 } |
| 6362 | 6274 |
| 6363 v8::Handle<Value> WhammyPropertyGetter(Local<String> name, | 6275 void WhammyPropertyGetter(Local<String> name, |
| 6364 const AccessorInfo& info) { | 6276 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 6365 Whammy* whammy = | 6277 Whammy* whammy = |
| 6366 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); | 6278 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); |
| 6367 | 6279 |
| 6368 v8::Persistent<v8::Object>& prev = whammy->objects_[whammy->cursor_]; | 6280 v8::Persistent<v8::Object>& prev = whammy->objects_[whammy->cursor_]; |
| 6369 | 6281 |
| 6370 v8::Handle<v8::Object> obj = v8::Object::New(); | 6282 v8::Handle<v8::Object> obj = v8::Object::New(); |
| 6371 if (!prev.IsEmpty()) { | 6283 if (!prev.IsEmpty()) { |
| 6372 v8::Local<v8::Object>::New(info.GetIsolate(), prev) | 6284 v8::Local<v8::Object>::New(info.GetIsolate(), prev) |
| 6373 ->Set(v8_str("next"), obj); | 6285 ->Set(v8_str("next"), obj); |
| 6374 prev.MakeWeak<Value, Snorkel>(new Snorkel(), &HandleWeakReference); | 6286 prev.MakeWeak<Value, Snorkel>(new Snorkel(), &HandleWeakReference); |
| 6375 whammy->objects_[whammy->cursor_].Clear(); | 6287 whammy->objects_[whammy->cursor_].Clear(); |
| 6376 } | 6288 } |
| 6377 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); | 6289 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); |
| 6378 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; | 6290 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; |
| 6379 return whammy->getScript()->Run(); | 6291 info.GetReturnValue().Set(whammy->getScript()->Run()); |
| 6380 } | 6292 } |
| 6381 | 6293 |
| 6382 THREADED_TEST(WeakReference) { | 6294 THREADED_TEST(WeakReference) { |
| 6383 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6295 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
| 6384 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(); | 6296 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(); |
| 6385 Whammy* whammy = new Whammy(v8::Isolate::GetCurrent()); | 6297 Whammy* whammy = new Whammy(v8::Isolate::GetCurrent()); |
| 6386 templ->SetNamedPropertyHandler(WhammyPropertyGetter, | 6298 templ->SetNamedPropertyHandler(WhammyPropertyGetter, |
| 6387 0, 0, 0, 0, | 6299 0, 0, 0, 0, |
| 6388 v8::External::New(whammy)); | 6300 v8::External::New(whammy)); |
| 6389 const char* extension_list[] = { "v8/gc" }; | 6301 const char* extension_list[] = { "v8/gc" }; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6539 v8::Local<String> y_str = v8_str("y"); | 6451 v8::Local<String> y_str = v8_str("y"); |
| 6540 CHECK_EQ(v8::Integer::New(1), o->Get(v8_str("x"))); | 6452 CHECK_EQ(v8::Integer::New(1), o->Get(v8_str("x"))); |
| 6541 CHECK(o->Get(y_str)->Equals(y_str)); | 6453 CHECK(o->Get(y_str)->Equals(y_str)); |
| 6542 } | 6454 } |
| 6543 } | 6455 } |
| 6544 | 6456 |
| 6545 | 6457 |
| 6546 v8::Handle<Function> args_fun; | 6458 v8::Handle<Function> args_fun; |
| 6547 | 6459 |
| 6548 | 6460 |
| 6549 static v8::Handle<Value> ArgumentsTestCallback(const v8::Arguments& args) { | 6461 static void ArgumentsTestCallback( |
| 6462 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 6550 ApiTestFuzzer::Fuzz(); | 6463 ApiTestFuzzer::Fuzz(); |
| 6551 CHECK_EQ(args_fun, args.Callee()); | 6464 CHECK_EQ(args_fun, args.Callee()); |
| 6552 CHECK_EQ(3, args.Length()); | 6465 CHECK_EQ(3, args.Length()); |
| 6553 CHECK_EQ(v8::Integer::New(1), args[0]); | 6466 CHECK_EQ(v8::Integer::New(1), args[0]); |
| 6554 CHECK_EQ(v8::Integer::New(2), args[1]); | 6467 CHECK_EQ(v8::Integer::New(2), args[1]); |
| 6555 CHECK_EQ(v8::Integer::New(3), args[2]); | 6468 CHECK_EQ(v8::Integer::New(3), args[2]); |
| 6556 CHECK_EQ(v8::Undefined(), args[3]); | 6469 CHECK_EQ(v8::Undefined(), args[3]); |
| 6557 v8::HandleScope scope(args.GetIsolate()); | 6470 v8::HandleScope scope(args.GetIsolate()); |
| 6558 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 6471 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 6559 return v8::Undefined(); | |
| 6560 } | 6472 } |
| 6561 | 6473 |
| 6562 | 6474 |
| 6563 THREADED_TEST(Arguments) { | 6475 THREADED_TEST(Arguments) { |
| 6564 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 6476 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 6565 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); | 6477 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); |
| 6566 global->Set(v8_str("f"), v8::FunctionTemplate::New(ArgumentsTestCallback)); | 6478 global->Set(v8_str("f"), v8::FunctionTemplate::New(ArgumentsTestCallback)); |
| 6567 LocalContext context(NULL, global); | 6479 LocalContext context(NULL, global); |
| 6568 args_fun = context->Global()->Get(v8_str("f")).As<Function>(); | 6480 args_fun = context->Global()->Get(v8_str("f")).As<Function>(); |
| 6569 v8_compile("f(1, 2, 3)")->Run(); | 6481 v8_compile("f(1, 2, 3)")->Run(); |
| 6570 } | 6482 } |
| 6571 | 6483 |
| 6572 | 6484 |
| 6573 static v8::Handle<Value> NoBlockGetterX(Local<String> name, | 6485 static void NoBlockGetterX(Local<String> name, |
| 6574 const AccessorInfo&) { | 6486 const v8::PropertyCallbackInfo<v8::Value>&) { |
| 6575 return v8::Handle<Value>(); | |
| 6576 } | 6487 } |
| 6577 | 6488 |
| 6578 | 6489 |
| 6579 static v8::Handle<Value> NoBlockGetterI(uint32_t index, | 6490 static void NoBlockGetterI(uint32_t index, |
| 6580 const AccessorInfo&) { | 6491 const v8::PropertyCallbackInfo<v8::Value>&) { |
| 6581 return v8::Handle<Value>(); | |
| 6582 } | 6492 } |
| 6583 | 6493 |
| 6584 | 6494 |
| 6585 static v8::Handle<v8::Boolean> PDeleter(Local<String> name, | 6495 static void PDeleter(Local<String> name, |
| 6586 const AccessorInfo&) { | 6496 const v8::PropertyCallbackInfo<v8::Boolean>& info) { |
| 6587 if (!name->Equals(v8_str("foo"))) { | 6497 if (!name->Equals(v8_str("foo"))) { |
| 6588 return v8::Handle<v8::Boolean>(); // not intercepted | 6498 return; // not intercepted |
| 6589 } | 6499 } |
| 6590 | 6500 |
| 6591 return v8::False(); // intercepted, and don't delete the property | 6501 info.GetReturnValue().Set(false); // intercepted, don't delete the property |
| 6592 } | 6502 } |
| 6593 | 6503 |
| 6594 | 6504 |
| 6595 static v8::Handle<v8::Boolean> IDeleter(uint32_t index, const AccessorInfo&) { | 6505 static void IDeleter(uint32_t index, |
| 6506 const v8::PropertyCallbackInfo<v8::Boolean>& info) { |
| 6596 if (index != 2) { | 6507 if (index != 2) { |
| 6597 return v8::Handle<v8::Boolean>(); // not intercepted | 6508 return; // not intercepted |
| 6598 } | 6509 } |
| 6599 | 6510 |
| 6600 return v8::False(); // intercepted, and don't delete the property | 6511 info.GetReturnValue().Set(false); // intercepted, don't delete the property |
| 6601 } | 6512 } |
| 6602 | 6513 |
| 6603 | 6514 |
| 6604 THREADED_TEST(Deleter) { | 6515 THREADED_TEST(Deleter) { |
| 6605 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 6516 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 6606 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 6517 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 6607 obj->SetNamedPropertyHandler(NoBlockGetterX, NULL, NULL, PDeleter, NULL); | 6518 obj->SetNamedPropertyHandler(NoBlockGetterX, NULL, NULL, PDeleter, NULL); |
| 6608 obj->SetIndexedPropertyHandler(NoBlockGetterI, NULL, NULL, IDeleter, NULL); | 6519 obj->SetIndexedPropertyHandler(NoBlockGetterI, NULL, NULL, IDeleter, NULL); |
| 6609 LocalContext context; | 6520 LocalContext context; |
| 6610 context->Global()->Set(v8_str("k"), obj->NewInstance()); | 6521 context->Global()->Set(v8_str("k"), obj->NewInstance()); |
| 6611 CompileRun( | 6522 CompileRun( |
| 6612 "k.foo = 'foo';" | 6523 "k.foo = 'foo';" |
| 6613 "k.bar = 'bar';" | 6524 "k.bar = 'bar';" |
| 6614 "k[2] = 2;" | 6525 "k[2] = 2;" |
| 6615 "k[4] = 4;"); | 6526 "k[4] = 4;"); |
| 6616 CHECK(v8_compile("delete k.foo")->Run()->IsFalse()); | 6527 CHECK(v8_compile("delete k.foo")->Run()->IsFalse()); |
| 6617 CHECK(v8_compile("delete k.bar")->Run()->IsTrue()); | 6528 CHECK(v8_compile("delete k.bar")->Run()->IsTrue()); |
| 6618 | 6529 |
| 6619 CHECK_EQ(v8_compile("k.foo")->Run(), v8_str("foo")); | 6530 CHECK_EQ(v8_compile("k.foo")->Run(), v8_str("foo")); |
| 6620 CHECK(v8_compile("k.bar")->Run()->IsUndefined()); | 6531 CHECK(v8_compile("k.bar")->Run()->IsUndefined()); |
| 6621 | 6532 |
| 6622 CHECK(v8_compile("delete k[2]")->Run()->IsFalse()); | 6533 CHECK(v8_compile("delete k[2]")->Run()->IsFalse()); |
| 6623 CHECK(v8_compile("delete k[4]")->Run()->IsTrue()); | 6534 CHECK(v8_compile("delete k[4]")->Run()->IsTrue()); |
| 6624 | 6535 |
| 6625 CHECK_EQ(v8_compile("k[2]")->Run(), v8_num(2)); | 6536 CHECK_EQ(v8_compile("k[2]")->Run(), v8_num(2)); |
| 6626 CHECK(v8_compile("k[4]")->Run()->IsUndefined()); | 6537 CHECK(v8_compile("k[4]")->Run()->IsUndefined()); |
| 6627 } | 6538 } |
| 6628 | 6539 |
| 6629 | 6540 |
| 6630 static v8::Handle<Value> GetK(Local<String> name, const AccessorInfo&) { | 6541 static void GetK(Local<String> name, |
| 6542 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 6631 ApiTestFuzzer::Fuzz(); | 6543 ApiTestFuzzer::Fuzz(); |
| 6632 if (name->Equals(v8_str("foo")) || | 6544 if (name->Equals(v8_str("foo")) || |
| 6633 name->Equals(v8_str("bar")) || | 6545 name->Equals(v8_str("bar")) || |
| 6634 name->Equals(v8_str("baz"))) { | 6546 name->Equals(v8_str("baz"))) { |
| 6635 return v8::Undefined(); | 6547 info.GetReturnValue().SetUndefined(); |
| 6636 } | 6548 } |
| 6637 return v8::Handle<Value>(); | |
| 6638 } | 6549 } |
| 6639 | 6550 |
| 6640 | 6551 |
| 6641 static v8::Handle<Value> IndexedGetK(uint32_t index, const AccessorInfo&) { | 6552 static void IndexedGetK(uint32_t index, |
| 6553 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 6642 ApiTestFuzzer::Fuzz(); | 6554 ApiTestFuzzer::Fuzz(); |
| 6643 if (index == 0 || index == 1) return v8::Undefined(); | 6555 if (index == 0 || index == 1) info.GetReturnValue().SetUndefined(); |
| 6644 return v8::Handle<Value>(); | |
| 6645 } | 6556 } |
| 6646 | 6557 |
| 6647 | 6558 |
| 6648 static v8::Handle<v8::Array> NamedEnum(const AccessorInfo&) { | 6559 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 6649 ApiTestFuzzer::Fuzz(); | 6560 ApiTestFuzzer::Fuzz(); |
| 6650 v8::Handle<v8::Array> result = v8::Array::New(3); | 6561 v8::Handle<v8::Array> result = v8::Array::New(3); |
| 6651 result->Set(v8::Integer::New(0), v8_str("foo")); | 6562 result->Set(v8::Integer::New(0), v8_str("foo")); |
| 6652 result->Set(v8::Integer::New(1), v8_str("bar")); | 6563 result->Set(v8::Integer::New(1), v8_str("bar")); |
| 6653 result->Set(v8::Integer::New(2), v8_str("baz")); | 6564 result->Set(v8::Integer::New(2), v8_str("baz")); |
| 6654 return result; | 6565 info.GetReturnValue().Set(result); |
| 6655 } | 6566 } |
| 6656 | 6567 |
| 6657 | 6568 |
| 6658 static v8::Handle<v8::Array> IndexedEnum(const AccessorInfo&) { | 6569 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 6659 ApiTestFuzzer::Fuzz(); | 6570 ApiTestFuzzer::Fuzz(); |
| 6660 v8::Handle<v8::Array> result = v8::Array::New(2); | 6571 v8::Handle<v8::Array> result = v8::Array::New(2); |
| 6661 result->Set(v8::Integer::New(0), v8_str("0")); | 6572 result->Set(v8::Integer::New(0), v8_str("0")); |
| 6662 result->Set(v8::Integer::New(1), v8_str("1")); | 6573 result->Set(v8::Integer::New(1), v8_str("1")); |
| 6663 return result; | 6574 info.GetReturnValue().Set(result); |
| 6664 } | 6575 } |
| 6665 | 6576 |
| 6666 | 6577 |
| 6667 THREADED_TEST(Enumerators) { | 6578 THREADED_TEST(Enumerators) { |
| 6668 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 6579 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 6669 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 6580 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 6670 obj->SetNamedPropertyHandler(GetK, NULL, NULL, NULL, NamedEnum); | 6581 obj->SetNamedPropertyHandler(GetK, NULL, NULL, NULL, NamedEnum); |
| 6671 obj->SetIndexedPropertyHandler(IndexedGetK, NULL, NULL, NULL, IndexedEnum); | 6582 obj->SetIndexedPropertyHandler(IndexedGetK, NULL, NULL, NULL, IndexedEnum); |
| 6672 LocalContext context; | 6583 LocalContext context; |
| 6673 context->Global()->Set(v8_str("k"), obj->NewInstance()); | 6584 context->Global()->Set(v8_str("k"), obj->NewInstance()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6718 CHECK_EQ(v8_str("foo"), result->Get(v8::Integer::New(14))); | 6629 CHECK_EQ(v8_str("foo"), result->Get(v8::Integer::New(14))); |
| 6719 CHECK_EQ(v8_str("bar"), result->Get(v8::Integer::New(15))); | 6630 CHECK_EQ(v8_str("bar"), result->Get(v8::Integer::New(15))); |
| 6720 CHECK_EQ(v8_str("baz"), result->Get(v8::Integer::New(16))); | 6631 CHECK_EQ(v8_str("baz"), result->Get(v8::Integer::New(16))); |
| 6721 } | 6632 } |
| 6722 | 6633 |
| 6723 | 6634 |
| 6724 int p_getter_count; | 6635 int p_getter_count; |
| 6725 int p_getter_count2; | 6636 int p_getter_count2; |
| 6726 | 6637 |
| 6727 | 6638 |
| 6728 static v8::Handle<Value> PGetter(Local<String> name, const AccessorInfo& info) { | 6639 static void PGetter(Local<String> name, |
| 6640 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 6729 ApiTestFuzzer::Fuzz(); | 6641 ApiTestFuzzer::Fuzz(); |
| 6730 p_getter_count++; | 6642 p_getter_count++; |
| 6731 v8::Handle<v8::Object> global = Context::GetCurrent()->Global(); | 6643 v8::Handle<v8::Object> global = Context::GetCurrent()->Global(); |
| 6732 CHECK_EQ(info.Holder(), global->Get(v8_str("o1"))); | 6644 CHECK_EQ(info.Holder(), global->Get(v8_str("o1"))); |
| 6733 if (name->Equals(v8_str("p1"))) { | 6645 if (name->Equals(v8_str("p1"))) { |
| 6734 CHECK_EQ(info.This(), global->Get(v8_str("o1"))); | 6646 CHECK_EQ(info.This(), global->Get(v8_str("o1"))); |
| 6735 } else if (name->Equals(v8_str("p2"))) { | 6647 } else if (name->Equals(v8_str("p2"))) { |
| 6736 CHECK_EQ(info.This(), global->Get(v8_str("o2"))); | 6648 CHECK_EQ(info.This(), global->Get(v8_str("o2"))); |
| 6737 } else if (name->Equals(v8_str("p3"))) { | 6649 } else if (name->Equals(v8_str("p3"))) { |
| 6738 CHECK_EQ(info.This(), global->Get(v8_str("o3"))); | 6650 CHECK_EQ(info.This(), global->Get(v8_str("o3"))); |
| 6739 } else if (name->Equals(v8_str("p4"))) { | 6651 } else if (name->Equals(v8_str("p4"))) { |
| 6740 CHECK_EQ(info.This(), global->Get(v8_str("o4"))); | 6652 CHECK_EQ(info.This(), global->Get(v8_str("o4"))); |
| 6741 } | 6653 } |
| 6742 return v8::Undefined(); | |
| 6743 } | 6654 } |
| 6744 | 6655 |
| 6745 | 6656 |
| 6746 static void RunHolderTest(v8::Handle<v8::ObjectTemplate> obj) { | 6657 static void RunHolderTest(v8::Handle<v8::ObjectTemplate> obj) { |
| 6747 ApiTestFuzzer::Fuzz(); | 6658 ApiTestFuzzer::Fuzz(); |
| 6748 LocalContext context; | 6659 LocalContext context; |
| 6749 context->Global()->Set(v8_str("o1"), obj->NewInstance()); | 6660 context->Global()->Set(v8_str("o1"), obj->NewInstance()); |
| 6750 CompileRun( | 6661 CompileRun( |
| 6751 "o1.__proto__ = { };" | 6662 "o1.__proto__ = { };" |
| 6752 "var o2 = { __proto__: o1 };" | 6663 "var o2 = { __proto__: o1 };" |
| 6753 "var o3 = { __proto__: o2 };" | 6664 "var o3 = { __proto__: o2 };" |
| 6754 "var o4 = { __proto__: o3 };" | 6665 "var o4 = { __proto__: o3 };" |
| 6755 "for (var i = 0; i < 10; i++) o4.p4;" | 6666 "for (var i = 0; i < 10; i++) o4.p4;" |
| 6756 "for (var i = 0; i < 10; i++) o3.p3;" | 6667 "for (var i = 0; i < 10; i++) o3.p3;" |
| 6757 "for (var i = 0; i < 10; i++) o2.p2;" | 6668 "for (var i = 0; i < 10; i++) o2.p2;" |
| 6758 "for (var i = 0; i < 10; i++) o1.p1;"); | 6669 "for (var i = 0; i < 10; i++) o1.p1;"); |
| 6759 } | 6670 } |
| 6760 | 6671 |
| 6761 | 6672 |
| 6762 static v8::Handle<Value> PGetter2(Local<String> name, | 6673 static void PGetter2(Local<String> name, |
| 6763 const AccessorInfo& info) { | 6674 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 6764 ApiTestFuzzer::Fuzz(); | 6675 ApiTestFuzzer::Fuzz(); |
| 6765 p_getter_count2++; | 6676 p_getter_count2++; |
| 6766 v8::Handle<v8::Object> global = Context::GetCurrent()->Global(); | 6677 v8::Handle<v8::Object> global = Context::GetCurrent()->Global(); |
| 6767 CHECK_EQ(info.Holder(), global->Get(v8_str("o1"))); | 6678 CHECK_EQ(info.Holder(), global->Get(v8_str("o1"))); |
| 6768 if (name->Equals(v8_str("p1"))) { | 6679 if (name->Equals(v8_str("p1"))) { |
| 6769 CHECK_EQ(info.This(), global->Get(v8_str("o1"))); | 6680 CHECK_EQ(info.This(), global->Get(v8_str("o1"))); |
| 6770 } else if (name->Equals(v8_str("p2"))) { | 6681 } else if (name->Equals(v8_str("p2"))) { |
| 6771 CHECK_EQ(info.This(), global->Get(v8_str("o2"))); | 6682 CHECK_EQ(info.This(), global->Get(v8_str("o2"))); |
| 6772 } else if (name->Equals(v8_str("p3"))) { | 6683 } else if (name->Equals(v8_str("p3"))) { |
| 6773 CHECK_EQ(info.This(), global->Get(v8_str("o3"))); | 6684 CHECK_EQ(info.This(), global->Get(v8_str("o3"))); |
| 6774 } else if (name->Equals(v8_str("p4"))) { | 6685 } else if (name->Equals(v8_str("p4"))) { |
| 6775 CHECK_EQ(info.This(), global->Get(v8_str("o4"))); | 6686 CHECK_EQ(info.This(), global->Get(v8_str("o4"))); |
| 6776 } | 6687 } |
| 6777 return v8::Undefined(); | |
| 6778 } | 6688 } |
| 6779 | 6689 |
| 6780 | 6690 |
| 6781 THREADED_TEST(GetterHolders) { | 6691 THREADED_TEST(GetterHolders) { |
| 6782 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 6692 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 6783 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 6693 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 6784 obj->SetAccessor(v8_str("p1"), PGetter); | 6694 obj->SetAccessor(v8_str("p1"), PGetter); |
| 6785 obj->SetAccessor(v8_str("p2"), PGetter); | 6695 obj->SetAccessor(v8_str("p2"), PGetter); |
| 6786 obj->SetAccessor(v8_str("p3"), PGetter); | 6696 obj->SetAccessor(v8_str("p3"), PGetter); |
| 6787 obj->SetAccessor(v8_str("p4"), PGetter); | 6697 obj->SetAccessor(v8_str("p4"), PGetter); |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7361 CHECK(syntax_error.As<v8::Object>()->Get(message)->Equals(foo)); | 7271 CHECK(syntax_error.As<v8::Object>()->Get(message)->Equals(foo)); |
| 7362 v8::Handle<Value> type_error = v8::Exception::TypeError(foo); | 7272 v8::Handle<Value> type_error = v8::Exception::TypeError(foo); |
| 7363 CHECK(type_error->IsObject()); | 7273 CHECK(type_error->IsObject()); |
| 7364 CHECK(type_error.As<v8::Object>()->Get(message)->Equals(foo)); | 7274 CHECK(type_error.As<v8::Object>()->Get(message)->Equals(foo)); |
| 7365 v8::Handle<Value> error = v8::Exception::Error(foo); | 7275 v8::Handle<Value> error = v8::Exception::Error(foo); |
| 7366 CHECK(error->IsObject()); | 7276 CHECK(error->IsObject()); |
| 7367 CHECK(error.As<v8::Object>()->Get(message)->Equals(foo)); | 7277 CHECK(error.As<v8::Object>()->Get(message)->Equals(foo)); |
| 7368 } | 7278 } |
| 7369 | 7279 |
| 7370 | 7280 |
| 7371 static v8::Handle<Value> YGetter(Local<String> name, const AccessorInfo& info) { | 7281 static void YGetter(Local<String> name, |
| 7282 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 7372 ApiTestFuzzer::Fuzz(); | 7283 ApiTestFuzzer::Fuzz(); |
| 7373 return v8_num(10); | 7284 info.GetReturnValue().Set(v8_num(10)); |
| 7374 } | 7285 } |
| 7375 | 7286 |
| 7376 | 7287 |
| 7377 static void YSetter(Local<String> name, | 7288 static void YSetter(Local<String> name, |
| 7378 Local<Value> value, | 7289 Local<Value> value, |
| 7379 const AccessorInfo& info) { | 7290 const v8::PropertyCallbackInfo<void>& info) { |
| 7380 if (info.This()->Has(name)) { | 7291 if (info.This()->Has(name)) { |
| 7381 info.This()->Delete(name); | 7292 info.This()->Delete(name); |
| 7382 } | 7293 } |
| 7383 info.This()->Set(name, value); | 7294 info.This()->Set(name, value); |
| 7384 } | 7295 } |
| 7385 | 7296 |
| 7386 | 7297 |
| 7387 THREADED_TEST(DeleteAccessor) { | 7298 THREADED_TEST(DeleteAccessor) { |
| 7388 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 7299 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 7389 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 7300 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7444 // Always allow read access. | 7355 // Always allow read access. |
| 7445 if (type == v8::ACCESS_GET) | 7356 if (type == v8::ACCESS_GET) |
| 7446 return true; | 7357 return true; |
| 7447 | 7358 |
| 7448 // Sometimes allow other access. | 7359 // Sometimes allow other access. |
| 7449 return g_security_callback_result; | 7360 return g_security_callback_result; |
| 7450 } | 7361 } |
| 7451 | 7362 |
| 7452 | 7363 |
| 7453 static int trouble_nesting = 0; | 7364 static int trouble_nesting = 0; |
| 7454 static v8::Handle<Value> TroubleCallback(const v8::Arguments& args) { | 7365 static void TroubleCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 7455 ApiTestFuzzer::Fuzz(); | 7366 ApiTestFuzzer::Fuzz(); |
| 7456 trouble_nesting++; | 7367 trouble_nesting++; |
| 7457 | 7368 |
| 7458 // Call a JS function that throws an uncaught exception. | 7369 // Call a JS function that throws an uncaught exception. |
| 7459 Local<v8::Object> arg_this = Context::GetCurrent()->Global(); | 7370 Local<v8::Object> arg_this = Context::GetCurrent()->Global(); |
| 7460 Local<Value> trouble_callee = (trouble_nesting == 3) ? | 7371 Local<Value> trouble_callee = (trouble_nesting == 3) ? |
| 7461 arg_this->Get(v8_str("trouble_callee")) : | 7372 arg_this->Get(v8_str("trouble_callee")) : |
| 7462 arg_this->Get(v8_str("trouble_caller")); | 7373 arg_this->Get(v8_str("trouble_caller")); |
| 7463 CHECK(trouble_callee->IsFunction()); | 7374 CHECK(trouble_callee->IsFunction()); |
| 7464 return Function::Cast(*trouble_callee)->Call(arg_this, 0, NULL); | 7375 args.GetReturnValue().Set( |
| 7376 Function::Cast(*trouble_callee)->Call(arg_this, 0, NULL)); |
| 7465 } | 7377 } |
| 7466 | 7378 |
| 7467 | 7379 |
| 7468 static int report_count = 0; | 7380 static int report_count = 0; |
| 7469 static void ApiUncaughtExceptionTestListener(v8::Handle<v8::Message>, | 7381 static void ApiUncaughtExceptionTestListener(v8::Handle<v8::Message>, |
| 7470 v8::Handle<Value>) { | 7382 v8::Handle<Value>) { |
| 7471 report_count++; | 7383 report_count++; |
| 7472 } | 7384 } |
| 7473 | 7385 |
| 7474 | 7386 |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7984 static bool IndexedAccessBlocker(Local<v8::Object> global, | 7896 static bool IndexedAccessBlocker(Local<v8::Object> global, |
| 7985 uint32_t key, | 7897 uint32_t key, |
| 7986 v8::AccessType type, | 7898 v8::AccessType type, |
| 7987 Local<Value> data) { | 7899 Local<Value> data) { |
| 7988 return Context::GetCurrent()->Global()->Equals(global) || | 7900 return Context::GetCurrent()->Global()->Equals(global) || |
| 7989 allowed_access_type[type]; | 7901 allowed_access_type[type]; |
| 7990 } | 7902 } |
| 7991 | 7903 |
| 7992 | 7904 |
| 7993 static int g_echo_value = -1; | 7905 static int g_echo_value = -1; |
| 7994 static v8::Handle<Value> EchoGetter(Local<String> name, | 7906 static void EchoGetter( |
| 7995 const AccessorInfo& info) { | 7907 Local<String> name, |
| 7996 return v8_num(g_echo_value); | 7908 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 7909 info.GetReturnValue().Set(v8_num(g_echo_value)); |
| 7997 } | 7910 } |
| 7998 | 7911 |
| 7999 | 7912 |
| 8000 static void EchoSetter(Local<String> name, | 7913 static void EchoSetter(Local<String> name, |
| 8001 Local<Value> value, | 7914 Local<Value> value, |
| 8002 const AccessorInfo&) { | 7915 const v8::PropertyCallbackInfo<void>&) { |
| 8003 if (value->IsNumber()) | 7916 if (value->IsNumber()) |
| 8004 g_echo_value = value->Int32Value(); | 7917 g_echo_value = value->Int32Value(); |
| 8005 } | 7918 } |
| 8006 | 7919 |
| 8007 | 7920 |
| 8008 static v8::Handle<Value> UnreachableGetter(Local<String> name, | 7921 static void UnreachableGetter( |
| 8009 const AccessorInfo& info) { | 7922 Local<String> name, |
| 7923 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 8010 CHECK(false); // This function should not be called.. | 7924 CHECK(false); // This function should not be called.. |
| 8011 return v8::Undefined(); | |
| 8012 } | 7925 } |
| 8013 | 7926 |
| 8014 | 7927 |
| 8015 static void UnreachableSetter(Local<String>, Local<Value>, | 7928 static void UnreachableSetter(Local<String>, |
| 8016 const AccessorInfo&) { | 7929 Local<Value>, |
| 7930 const v8::PropertyCallbackInfo<void>&) { |
| 8017 CHECK(false); // This function should nto be called. | 7931 CHECK(false); // This function should nto be called. |
| 8018 } | 7932 } |
| 8019 | 7933 |
| 8020 | 7934 |
| 8021 TEST(AccessControl) { | 7935 TEST(AccessControl) { |
| 8022 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 7936 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 8023 v8::HandleScope handle_scope(isolate); | 7937 v8::HandleScope handle_scope(isolate); |
| 8024 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 7938 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 8025 | 7939 |
| 8026 global_template->SetAccessCheckCallbacks(NamedAccessBlocker, | 7940 global_template->SetAccessCheckCallbacks(NamedAccessBlocker, |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8383 CHECK(value->IsTrue()); | 8297 CHECK(value->IsTrue()); |
| 8384 | 8298 |
| 8385 value = CompileRun("Object.getOwnPropertyNames(object).length == 0"); | 8299 value = CompileRun("Object.getOwnPropertyNames(object).length == 0"); |
| 8386 CHECK(value->IsTrue()); | 8300 CHECK(value->IsTrue()); |
| 8387 | 8301 |
| 8388 context1->Exit(); | 8302 context1->Exit(); |
| 8389 context0->Exit(); | 8303 context0->Exit(); |
| 8390 } | 8304 } |
| 8391 | 8305 |
| 8392 | 8306 |
| 8393 static v8::Handle<v8::Array> IndexedPropertyEnumerator(const AccessorInfo&) { | 8307 static void IndexedPropertyEnumerator( |
| 8308 const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 8394 v8::Handle<v8::Array> result = v8::Array::New(2); | 8309 v8::Handle<v8::Array> result = v8::Array::New(2); |
| 8395 result->Set(0, v8::Integer::New(7)); | 8310 result->Set(0, v8::Integer::New(7)); |
| 8396 result->Set(1, v8::Object::New()); | 8311 result->Set(1, v8::Object::New()); |
| 8397 return result; | 8312 info.GetReturnValue().Set(result); |
| 8398 } | 8313 } |
| 8399 | 8314 |
| 8400 | 8315 |
| 8401 static v8::Handle<v8::Array> NamedPropertyEnumerator(const AccessorInfo& info) { | 8316 static void NamedPropertyEnumerator( |
| 8317 const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 8402 v8::Handle<v8::Array> result = v8::Array::New(2); | 8318 v8::Handle<v8::Array> result = v8::Array::New(2); |
| 8403 result->Set(0, v8_str("x")); | 8319 result->Set(0, v8_str("x")); |
| 8404 result->Set(1, v8::Object::New()); | 8320 result->Set(1, v8::Object::New()); |
| 8405 return result; | 8321 info.GetReturnValue().Set(result); |
| 8406 } | 8322 } |
| 8407 | 8323 |
| 8408 | 8324 |
| 8409 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { | 8325 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { |
| 8410 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 8326 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
| 8411 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); | 8327 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); |
| 8412 | 8328 |
| 8413 obj_template->Set(v8_str("7"), v8::Integer::New(7)); | 8329 obj_template->Set(v8_str("7"), v8::Integer::New(7)); |
| 8414 obj_template->Set(v8_str("x"), v8::Integer::New(42)); | 8330 obj_template->Set(v8_str("x"), v8::Integer::New(42)); |
| 8415 obj_template->SetIndexedPropertyHandler(NULL, NULL, NULL, NULL, | 8331 obj_template->SetIndexedPropertyHandler(NULL, NULL, NULL, NULL, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 8428 CHECK_EQ(3, result_array->Length()); | 8344 CHECK_EQ(3, result_array->Length()); |
| 8429 CHECK(result_array->Get(0)->IsString()); | 8345 CHECK(result_array->Get(0)->IsString()); |
| 8430 CHECK(result_array->Get(1)->IsString()); | 8346 CHECK(result_array->Get(1)->IsString()); |
| 8431 CHECK(result_array->Get(2)->IsString()); | 8347 CHECK(result_array->Get(2)->IsString()); |
| 8432 CHECK_EQ(v8_str("7"), result_array->Get(0)); | 8348 CHECK_EQ(v8_str("7"), result_array->Get(0)); |
| 8433 CHECK_EQ(v8_str("[object Object]"), result_array->Get(1)); | 8349 CHECK_EQ(v8_str("[object Object]"), result_array->Get(1)); |
| 8434 CHECK_EQ(v8_str("x"), result_array->Get(2)); | 8350 CHECK_EQ(v8_str("x"), result_array->Get(2)); |
| 8435 } | 8351 } |
| 8436 | 8352 |
| 8437 | 8353 |
| 8438 static v8::Handle<Value> ConstTenGetter(Local<String> name, | 8354 static void ConstTenGetter(Local<String> name, |
| 8439 const AccessorInfo& info) { | 8355 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 8440 return v8_num(10); | 8356 info.GetReturnValue().Set(v8_num(10)); |
| 8441 } | 8357 } |
| 8442 | 8358 |
| 8443 | 8359 |
| 8444 THREADED_TEST(CrossDomainAccessors) { | 8360 THREADED_TEST(CrossDomainAccessors) { |
| 8445 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 8361 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 8446 v8::HandleScope handle_scope(isolate); | 8362 v8::HandleScope handle_scope(isolate); |
| 8447 | 8363 |
| 8448 v8::Handle<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); | 8364 v8::Handle<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); |
| 8449 | 8365 |
| 8450 v8::Handle<v8::ObjectTemplate> global_template = | 8366 v8::Handle<v8::ObjectTemplate> global_template = |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8694 v8::Handle<Value> value; | 8610 v8::Handle<Value> value; |
| 8695 | 8611 |
| 8696 value = v8_compile("var p = 'as' + 'df';")->Run(); | 8612 value = v8_compile("var p = 'as' + 'df';")->Run(); |
| 8697 value = v8_compile("obj[p];")->Run(); | 8613 value = v8_compile("obj[p];")->Run(); |
| 8698 | 8614 |
| 8699 context1->Exit(); | 8615 context1->Exit(); |
| 8700 context0->Exit(); | 8616 context0->Exit(); |
| 8701 } | 8617 } |
| 8702 | 8618 |
| 8703 | 8619 |
| 8704 static v8::Handle<Value> AccessControlNamedGetter( | 8620 static void AccessControlNamedGetter( |
| 8705 Local<String>, const AccessorInfo&) { | 8621 Local<String>, |
| 8706 return v8::Integer::New(42); | 8622 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 8623 info.GetReturnValue().Set(42); |
| 8707 } | 8624 } |
| 8708 | 8625 |
| 8709 | 8626 |
| 8710 static v8::Handle<Value> AccessControlNamedSetter( | 8627 static void AccessControlNamedSetter( |
| 8711 Local<String>, Local<Value> value, const AccessorInfo&) { | 8628 Local<String>, |
| 8712 return value; | 8629 Local<Value> value, |
| 8630 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 8631 info.GetReturnValue().Set(value); |
| 8713 } | 8632 } |
| 8714 | 8633 |
| 8715 | 8634 |
| 8716 static v8::Handle<Value> AccessControlIndexedGetter( | 8635 static void AccessControlIndexedGetter( |
| 8717 uint32_t index, | 8636 uint32_t index, |
| 8718 const AccessorInfo& info) { | 8637 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 8719 return v8_num(42); | 8638 info.GetReturnValue().Set(v8_num(42)); |
| 8720 } | 8639 } |
| 8721 | 8640 |
| 8722 | 8641 |
| 8723 static v8::Handle<Value> AccessControlIndexedSetter( | 8642 static void AccessControlIndexedSetter( |
| 8724 uint32_t, Local<Value> value, const AccessorInfo&) { | 8643 uint32_t, |
| 8725 return value; | 8644 Local<Value> value, |
| 8645 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 8646 info.GetReturnValue().Set(value); |
| 8726 } | 8647 } |
| 8727 | 8648 |
| 8728 | 8649 |
| 8729 THREADED_TEST(AccessControlInterceptorIC) { | 8650 THREADED_TEST(AccessControlInterceptorIC) { |
| 8730 named_access_count = 0; | 8651 named_access_count = 0; |
| 8731 indexed_access_count = 0; | 8652 indexed_access_count = 0; |
| 8732 | 8653 |
| 8733 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 8654 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 8734 v8::HandleScope handle_scope(isolate); | 8655 v8::HandleScope handle_scope(isolate); |
| 8735 | 8656 |
| (...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10185 "for (var i = 0; i < 10; i++) {" | 10106 "for (var i = 0; i < 10; i++) {" |
| 10186 " result += o.y;" | 10107 " result += o.y;" |
| 10187 "}" | 10108 "}" |
| 10188 "result;", | 10109 "result;", |
| 10189 42 * 10); | 10110 42 * 10); |
| 10190 } | 10111 } |
| 10191 | 10112 |
| 10192 | 10113 |
| 10193 static void SetOnThis(Local<String> name, | 10114 static void SetOnThis(Local<String> name, |
| 10194 Local<Value> value, | 10115 Local<Value> value, |
| 10195 const AccessorInfo& info) { | 10116 const v8::PropertyCallbackInfo<void>& info) { |
| 10196 info.This()->ForceSet(name, value); | 10117 info.This()->ForceSet(name, value); |
| 10197 } | 10118 } |
| 10198 | 10119 |
| 10199 | 10120 |
| 10200 THREADED_TEST(InterceptorLoadICWithCallbackOnHolder) { | 10121 THREADED_TEST(InterceptorLoadICWithCallbackOnHolder) { |
| 10201 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10122 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 10202 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10123 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10203 templ->SetNamedPropertyHandler(InterceptorLoadXICGetter); | 10124 templ->SetNamedPropertyHandler(InterceptorLoadXICGetter); |
| 10204 templ->SetAccessor(v8_str("y"), Return239); | 10125 templ->SetAccessor(v8_str("y"), Return239Callback); |
| 10205 LocalContext context; | 10126 LocalContext context; |
| 10206 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 10127 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 10207 | 10128 |
| 10208 // Check the case when receiver and interceptor's holder | 10129 // Check the case when receiver and interceptor's holder |
| 10209 // are the same objects. | 10130 // are the same objects. |
| 10210 v8::Handle<Value> value = CompileRun( | 10131 v8::Handle<Value> value = CompileRun( |
| 10211 "var result = 0;" | 10132 "var result = 0;" |
| 10212 "for (var i = 0; i < 7; i++) {" | 10133 "for (var i = 0; i < 7; i++) {" |
| 10213 " result = o.y;" | 10134 " result = o.y;" |
| 10214 "}"); | 10135 "}"); |
| 10215 CHECK_EQ(239, value->Int32Value()); | 10136 CHECK_EQ(239, value->Int32Value()); |
| 10216 | 10137 |
| 10217 // Check the case when interceptor's holder is in proto chain | 10138 // Check the case when interceptor's holder is in proto chain |
| 10218 // of receiver. | 10139 // of receiver. |
| 10219 value = CompileRun( | 10140 value = CompileRun( |
| 10220 "r = { __proto__: o };" | 10141 "r = { __proto__: o };" |
| 10221 "var result = 0;" | 10142 "var result = 0;" |
| 10222 "for (var i = 0; i < 7; i++) {" | 10143 "for (var i = 0; i < 7; i++) {" |
| 10223 " result = r.y;" | 10144 " result = r.y;" |
| 10224 "}"); | 10145 "}"); |
| 10225 CHECK_EQ(239, value->Int32Value()); | 10146 CHECK_EQ(239, value->Int32Value()); |
| 10226 } | 10147 } |
| 10227 | 10148 |
| 10228 | 10149 |
| 10229 THREADED_TEST(InterceptorLoadICWithCallbackOnProto) { | 10150 THREADED_TEST(InterceptorLoadICWithCallbackOnProto) { |
| 10230 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10151 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 10231 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); | 10152 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); |
| 10232 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); | 10153 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); |
| 10233 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); | 10154 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); |
| 10234 templ_p->SetAccessor(v8_str("y"), Return239); | 10155 templ_p->SetAccessor(v8_str("y"), Return239Callback); |
| 10235 | 10156 |
| 10236 LocalContext context; | 10157 LocalContext context; |
| 10237 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); | 10158 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); |
| 10238 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); | 10159 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); |
| 10239 | 10160 |
| 10240 // Check the case when receiver and interceptor's holder | 10161 // Check the case when receiver and interceptor's holder |
| 10241 // are the same objects. | 10162 // are the same objects. |
| 10242 v8::Handle<Value> value = CompileRun( | 10163 v8::Handle<Value> value = CompileRun( |
| 10243 "o.__proto__ = p;" | 10164 "o.__proto__ = p;" |
| 10244 "var result = 0;" | 10165 "var result = 0;" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 10256 " result = r.x + r.y;" | 10177 " result = r.x + r.y;" |
| 10257 "}"); | 10178 "}"); |
| 10258 CHECK_EQ(239 + 42, value->Int32Value()); | 10179 CHECK_EQ(239 + 42, value->Int32Value()); |
| 10259 } | 10180 } |
| 10260 | 10181 |
| 10261 | 10182 |
| 10262 THREADED_TEST(InterceptorLoadICForCallbackWithOverride) { | 10183 THREADED_TEST(InterceptorLoadICForCallbackWithOverride) { |
| 10263 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10184 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 10264 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10185 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10265 templ->SetNamedPropertyHandler(InterceptorLoadXICGetter); | 10186 templ->SetNamedPropertyHandler(InterceptorLoadXICGetter); |
| 10266 templ->SetAccessor(v8_str("y"), Return239); | 10187 templ->SetAccessor(v8_str("y"), Return239Callback); |
| 10267 | 10188 |
| 10268 LocalContext context; | 10189 LocalContext context; |
| 10269 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 10190 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 10270 | 10191 |
| 10271 v8::Handle<Value> value = CompileRun( | 10192 v8::Handle<Value> value = CompileRun( |
| 10272 "fst = new Object(); fst.__proto__ = o;" | 10193 "fst = new Object(); fst.__proto__ = o;" |
| 10273 "snd = new Object(); snd.__proto__ = fst;" | 10194 "snd = new Object(); snd.__proto__ = fst;" |
| 10274 "var result1 = 0;" | 10195 "var result1 = 0;" |
| 10275 "for (var i = 0; i < 7; i++) {" | 10196 "for (var i = 0; i < 7; i++) {" |
| 10276 " result1 = snd.x;" | 10197 " result1 = snd.x;" |
| 10277 "}" | 10198 "}" |
| 10278 "fst.x = 239;" | 10199 "fst.x = 239;" |
| 10279 "var result = 0;" | 10200 "var result = 0;" |
| 10280 "for (var i = 0; i < 7; i++) {" | 10201 "for (var i = 0; i < 7; i++) {" |
| 10281 " result = snd.x;" | 10202 " result = snd.x;" |
| 10282 "}" | 10203 "}" |
| 10283 "result + result1"); | 10204 "result + result1"); |
| 10284 CHECK_EQ(239 + 42, value->Int32Value()); | 10205 CHECK_EQ(239 + 42, value->Int32Value()); |
| 10285 } | 10206 } |
| 10286 | 10207 |
| 10287 | 10208 |
| 10288 // Test the case when we stored callback into | 10209 // Test the case when we stored callback into |
| 10289 // a stub, but interceptor produced value on its own. | 10210 // a stub, but interceptor produced value on its own. |
| 10290 THREADED_TEST(InterceptorLoadICCallbackNotNeeded) { | 10211 THREADED_TEST(InterceptorLoadICCallbackNotNeeded) { |
| 10291 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10212 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 10292 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); | 10213 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); |
| 10293 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); | 10214 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); |
| 10294 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); | 10215 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); |
| 10295 templ_p->SetAccessor(v8_str("y"), Return239); | 10216 templ_p->SetAccessor(v8_str("y"), Return239Callback); |
| 10296 | 10217 |
| 10297 LocalContext context; | 10218 LocalContext context; |
| 10298 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); | 10219 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); |
| 10299 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); | 10220 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); |
| 10300 | 10221 |
| 10301 v8::Handle<Value> value = CompileRun( | 10222 v8::Handle<Value> value = CompileRun( |
| 10302 "o.__proto__ = p;" | 10223 "o.__proto__ = p;" |
| 10303 "for (var i = 0; i < 7; i++) {" | 10224 "for (var i = 0; i < 7; i++) {" |
| 10304 " o.x;" | 10225 " o.x;" |
| 10305 // Now it should be ICed and keep a reference to x defined on p | 10226 // Now it should be ICed and keep a reference to x defined on p |
| 10306 "}" | 10227 "}" |
| 10307 "var result = 0;" | 10228 "var result = 0;" |
| 10308 "for (var i = 0; i < 7; i++) {" | 10229 "for (var i = 0; i < 7; i++) {" |
| 10309 " result += o.x;" | 10230 " result += o.x;" |
| 10310 "}" | 10231 "}" |
| 10311 "result"); | 10232 "result"); |
| 10312 CHECK_EQ(42 * 7, value->Int32Value()); | 10233 CHECK_EQ(42 * 7, value->Int32Value()); |
| 10313 } | 10234 } |
| 10314 | 10235 |
| 10315 | 10236 |
| 10316 // Test the case when we stored callback into | 10237 // Test the case when we stored callback into |
| 10317 // a stub, but it got invalidated later on. | 10238 // a stub, but it got invalidated later on. |
| 10318 THREADED_TEST(InterceptorLoadICInvalidatedCallback) { | 10239 THREADED_TEST(InterceptorLoadICInvalidatedCallback) { |
| 10319 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10240 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 10320 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); | 10241 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); |
| 10321 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); | 10242 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); |
| 10322 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); | 10243 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); |
| 10323 templ_p->SetAccessor(v8_str("y"), Return239, SetOnThis); | 10244 templ_p->SetAccessor(v8_str("y"), Return239Callback, SetOnThis); |
| 10324 | 10245 |
| 10325 LocalContext context; | 10246 LocalContext context; |
| 10326 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); | 10247 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); |
| 10327 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); | 10248 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); |
| 10328 | 10249 |
| 10329 v8::Handle<Value> value = CompileRun( | 10250 v8::Handle<Value> value = CompileRun( |
| 10330 "inbetween = new Object();" | 10251 "inbetween = new Object();" |
| 10331 "o.__proto__ = inbetween;" | 10252 "o.__proto__ = inbetween;" |
| 10332 "inbetween.__proto__ = p;" | 10253 "inbetween.__proto__ = p;" |
| 10333 "for (var i = 0; i < 10; i++) {" | 10254 "for (var i = 0; i < 10; i++) {" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 10345 | 10266 |
| 10346 | 10267 |
| 10347 // Test the case when we stored callback into | 10268 // Test the case when we stored callback into |
| 10348 // a stub, but it got invalidated later on due to override on | 10269 // a stub, but it got invalidated later on due to override on |
| 10349 // global object which is between interceptor and callbacks' holders. | 10270 // global object which is between interceptor and callbacks' holders. |
| 10350 THREADED_TEST(InterceptorLoadICInvalidatedCallbackViaGlobal) { | 10271 THREADED_TEST(InterceptorLoadICInvalidatedCallbackViaGlobal) { |
| 10351 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10272 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 10352 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); | 10273 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); |
| 10353 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); | 10274 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); |
| 10354 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); | 10275 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); |
| 10355 templ_p->SetAccessor(v8_str("y"), Return239, SetOnThis); | 10276 templ_p->SetAccessor(v8_str("y"), Return239Callback, SetOnThis); |
| 10356 | 10277 |
| 10357 LocalContext context; | 10278 LocalContext context; |
| 10358 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); | 10279 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); |
| 10359 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); | 10280 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); |
| 10360 | 10281 |
| 10361 v8::Handle<Value> value = CompileRun( | 10282 v8::Handle<Value> value = CompileRun( |
| 10362 "o.__proto__ = this;" | 10283 "o.__proto__ = this;" |
| 10363 "this.__proto__ = p;" | 10284 "this.__proto__ = p;" |
| 10364 "for (var i = 0; i < 10; i++) {" | 10285 "for (var i = 0; i < 10; i++) {" |
| 10365 " if (o.y != 239) throw 'oops: ' + o.y;" | 10286 " if (o.y != 239) throw 'oops: ' + o.y;" |
| (...skipping 9087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19453 i::Semaphore* sem_; | 19374 i::Semaphore* sem_; |
| 19454 volatile int sem_value_; | 19375 volatile int sem_value_; |
| 19455 }; | 19376 }; |
| 19456 | 19377 |
| 19457 | 19378 |
| 19458 THREADED_TEST(SemaphoreInterruption) { | 19379 THREADED_TEST(SemaphoreInterruption) { |
| 19459 ThreadInterruptTest().RunTest(); | 19380 ThreadInterruptTest().RunTest(); |
| 19460 } | 19381 } |
| 19461 | 19382 |
| 19462 #endif // WIN32 | 19383 #endif // WIN32 |
| OLD | NEW |