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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 CHECK(env->GetIsolate() == CcTest::isolate()); | 178 CHECK(env->GetIsolate() == CcTest::isolate()); |
179 env->Enter(); | 179 env->Enter(); |
180 CHECK(env->GetIsolate()->InContext()); | 180 CHECK(env->GetIsolate()->InContext()); |
181 CHECK(env->GetIsolate() == CcTest::isolate()); | 181 CHECK(env->GetIsolate() == CcTest::isolate()); |
182 env->Exit(); | 182 env->Exit(); |
183 CHECK(!env->GetIsolate()->InContext()); | 183 CHECK(!env->GetIsolate()->InContext()); |
184 CHECK(env->GetIsolate() == CcTest::isolate()); | 184 CHECK(env->GetIsolate() == CcTest::isolate()); |
185 } | 185 } |
186 | 186 |
187 | 187 |
188 static void TestSignature(const char* loop_js, Local<Value> receiver) { | 188 static void TestSignature(const char* loop_js, Local<Value> receiver, |
| 189 v8::Isolate* isolate) { |
189 i::ScopedVector<char> source(200); | 190 i::ScopedVector<char> source(200); |
190 i::SNPrintF(source, | 191 i::SNPrintF(source, |
191 "for (var i = 0; i < 10; i++) {" | 192 "for (var i = 0; i < 10; i++) {" |
192 " %s" | 193 " %s" |
193 "}", | 194 "}", |
194 loop_js); | 195 loop_js); |
195 signature_callback_count = 0; | 196 signature_callback_count = 0; |
196 signature_expected_receiver = receiver; | 197 signature_expected_receiver = receiver; |
197 bool expected_to_throw = receiver.IsEmpty(); | 198 bool expected_to_throw = receiver.IsEmpty(); |
198 v8::TryCatch try_catch; | 199 v8::TryCatch try_catch; |
199 CompileRun(source.start()); | 200 CompileRun(source.start()); |
200 CHECK_EQ(expected_to_throw, try_catch.HasCaught()); | 201 CHECK_EQ(expected_to_throw, try_catch.HasCaught()); |
201 if (!expected_to_throw) { | 202 if (!expected_to_throw) { |
202 CHECK_EQ(10, signature_callback_count); | 203 CHECK_EQ(10, signature_callback_count); |
203 } else { | 204 } else { |
204 CHECK_EQ(v8_str("TypeError: Illegal invocation"), | 205 CHECK_EQ(v8_str("TypeError: Illegal invocation"), |
205 try_catch.Exception()->ToString()); | 206 try_catch.Exception()->ToString(isolate)); |
206 } | 207 } |
207 } | 208 } |
208 | 209 |
209 | 210 |
210 THREADED_TEST(ReceiverSignature) { | 211 THREADED_TEST(ReceiverSignature) { |
211 LocalContext env; | 212 LocalContext env; |
212 v8::Isolate* isolate = env->GetIsolate(); | 213 v8::Isolate* isolate = env->GetIsolate(); |
213 v8::HandleScope scope(isolate); | 214 v8::HandleScope scope(isolate); |
214 // Setup templates. | 215 // Setup templates. |
215 v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(isolate); | 216 v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(isolate); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 "copy_props(unrel);"); | 261 "copy_props(unrel);"); |
261 // Test with and without ICs | 262 // Test with and without ICs |
262 const char* test_objects[] = { | 263 const char* test_objects[] = { |
263 "fun_instance", "sub_fun_instance", "obj", "unrel" }; | 264 "fun_instance", "sub_fun_instance", "obj", "unrel" }; |
264 unsigned bad_signature_start_offset = 2; | 265 unsigned bad_signature_start_offset = 2; |
265 for (unsigned i = 0; i < arraysize(test_objects); i++) { | 266 for (unsigned i = 0; i < arraysize(test_objects); i++) { |
266 i::ScopedVector<char> source(200); | 267 i::ScopedVector<char> source(200); |
267 i::SNPrintF( | 268 i::SNPrintF( |
268 source, "var test_object = %s; test_object", test_objects[i]); | 269 source, "var test_object = %s; test_object", test_objects[i]); |
269 Local<Value> test_object = CompileRun(source.start()); | 270 Local<Value> test_object = CompileRun(source.start()); |
270 TestSignature("test_object.prop();", test_object); | 271 TestSignature("test_object.prop();", test_object, isolate); |
271 TestSignature("test_object.accessor;", test_object); | 272 TestSignature("test_object.accessor;", test_object, isolate); |
272 TestSignature("test_object[accessor_key];", test_object); | 273 TestSignature("test_object[accessor_key];", test_object, isolate); |
273 TestSignature("test_object.accessor = 1;", test_object); | 274 TestSignature("test_object.accessor = 1;", test_object, isolate); |
274 TestSignature("test_object[accessor_key] = 1;", test_object); | 275 TestSignature("test_object[accessor_key] = 1;", test_object, isolate); |
275 if (i >= bad_signature_start_offset) test_object = Local<Value>(); | 276 if (i >= bad_signature_start_offset) test_object = Local<Value>(); |
276 TestSignature("test_object.prop_sig();", test_object); | 277 TestSignature("test_object.prop_sig();", test_object, isolate); |
277 TestSignature("test_object.accessor_sig;", test_object); | 278 TestSignature("test_object.accessor_sig;", test_object, isolate); |
278 TestSignature("test_object[accessor_sig_key];", test_object); | 279 TestSignature("test_object[accessor_sig_key];", test_object, isolate); |
279 TestSignature("test_object.accessor_sig = 1;", test_object); | 280 TestSignature("test_object.accessor_sig = 1;", test_object, isolate); |
280 TestSignature("test_object[accessor_sig_key] = 1;", test_object); | 281 TestSignature("test_object[accessor_sig_key] = 1;", test_object, isolate); |
281 } | 282 } |
282 } | 283 } |
283 | 284 |
284 | 285 |
285 THREADED_TEST(ArgumentSignature) { | 286 THREADED_TEST(ArgumentSignature) { |
286 LocalContext env; | 287 LocalContext env; |
287 v8::Isolate* isolate = env->GetIsolate(); | 288 v8::Isolate* isolate = env->GetIsolate(); |
288 v8::HandleScope scope(isolate); | 289 v8::HandleScope scope(isolate); |
289 v8::Handle<v8::FunctionTemplate> cons = v8::FunctionTemplate::New(isolate); | 290 v8::Handle<v8::FunctionTemplate> cons = v8::FunctionTemplate::New(isolate); |
290 cons->SetClassName(v8_str("Cons")); | 291 cons->SetClassName(v8_str("Cons")); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 "Fun2(new Cons1(), new Cons2()) == '[object Cons1],[object Cons2]'"); | 350 "Fun2(new Cons1(), new Cons2()) == '[object Cons1],[object Cons2]'"); |
350 CHECK(value8->IsTrue()); | 351 CHECK(value8->IsTrue()); |
351 } | 352 } |
352 | 353 |
353 | 354 |
354 THREADED_TEST(HulIgennem) { | 355 THREADED_TEST(HulIgennem) { |
355 LocalContext env; | 356 LocalContext env; |
356 v8::Isolate* isolate = env->GetIsolate(); | 357 v8::Isolate* isolate = env->GetIsolate(); |
357 v8::HandleScope scope(isolate); | 358 v8::HandleScope scope(isolate); |
358 v8::Handle<v8::Primitive> undef = v8::Undefined(isolate); | 359 v8::Handle<v8::Primitive> undef = v8::Undefined(isolate); |
359 Local<String> undef_str = undef->ToString(); | 360 Local<String> undef_str = undef->ToString(isolate); |
360 char* value = i::NewArray<char>(undef_str->Utf8Length() + 1); | 361 char* value = i::NewArray<char>(undef_str->Utf8Length() + 1); |
361 undef_str->WriteUtf8(value); | 362 undef_str->WriteUtf8(value); |
362 CHECK_EQ(0, strcmp(value, "undefined")); | 363 CHECK_EQ(0, strcmp(value, "undefined")); |
363 i::DeleteArray(value); | 364 i::DeleteArray(value); |
364 } | 365 } |
365 | 366 |
366 | 367 |
367 THREADED_TEST(Access) { | 368 THREADED_TEST(Access) { |
368 LocalContext env; | 369 LocalContext env; |
369 v8::Isolate* isolate = env->GetIsolate(); | 370 v8::Isolate* isolate = env->GetIsolate(); |
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 object_template->Set(isolate, "callback", | 1227 object_template->Set(isolate, "callback", |
1227 v8::FunctionTemplate::New(isolate, callback)); | 1228 v8::FunctionTemplate::New(isolate, callback)); |
1228 v8::Local<v8::Object> object = object_template->NewInstance(); | 1229 v8::Local<v8::Object> object = object_template->NewInstance(); |
1229 (*env)->Global()->Set(v8_str("callback_object"), object); | 1230 (*env)->Global()->Set(v8_str("callback_object"), object); |
1230 return scope.Escape(CompileRun("callback_object.callback()")); | 1231 return scope.Escape(CompileRun("callback_object.callback()")); |
1231 } | 1232 } |
1232 | 1233 |
1233 | 1234 |
1234 THREADED_PROFILED_TEST(FastReturnValues) { | 1235 THREADED_PROFILED_TEST(FastReturnValues) { |
1235 LocalContext env; | 1236 LocalContext env; |
1236 v8::HandleScope scope(CcTest::isolate()); | 1237 v8::Isolate* isolate = env->GetIsolate(); |
| 1238 v8::HandleScope scope(isolate); |
1237 v8::Handle<v8::Value> value; | 1239 v8::Handle<v8::Value> value; |
1238 // check int32_t and uint32_t | 1240 // check int32_t and uint32_t |
1239 int32_t int_values[] = { | 1241 int32_t int_values[] = { |
1240 0, 234, -723, | 1242 0, 234, -723, |
1241 i::Smi::kMinValue, i::Smi::kMaxValue | 1243 i::Smi::kMinValue, i::Smi::kMaxValue |
1242 }; | 1244 }; |
1243 for (size_t i = 0; i < arraysize(int_values); i++) { | 1245 for (size_t i = 0; i < arraysize(int_values); i++) { |
1244 for (int modifier = -1; modifier <= 1; modifier++) { | 1246 for (int modifier = -1; modifier <= 1; modifier++) { |
1245 int int_value = int_values[i] + modifier; | 1247 int int_value = int_values[i] + modifier; |
1246 // check int32_t | 1248 // check int32_t |
1247 fast_return_value_int32 = int_value; | 1249 fast_return_value_int32 = int_value; |
1248 value = TestFastReturnValues<int32_t>(); | 1250 value = TestFastReturnValues<int32_t>(); |
1249 CHECK(value->IsInt32()); | 1251 CHECK(value->IsInt32()); |
1250 CHECK(fast_return_value_int32 == value->Int32Value()); | 1252 CHECK(fast_return_value_int32 == value->Int32Value()); |
1251 // check uint32_t | 1253 // check uint32_t |
1252 fast_return_value_uint32 = static_cast<uint32_t>(int_value); | 1254 fast_return_value_uint32 = static_cast<uint32_t>(int_value); |
1253 value = TestFastReturnValues<uint32_t>(); | 1255 value = TestFastReturnValues<uint32_t>(); |
1254 CHECK(value->IsUint32()); | 1256 CHECK(value->IsUint32()); |
1255 CHECK(fast_return_value_uint32 == value->Uint32Value()); | 1257 CHECK(fast_return_value_uint32 == value->Uint32Value()); |
1256 } | 1258 } |
1257 } | 1259 } |
1258 // check double | 1260 // check double |
1259 value = TestFastReturnValues<double>(); | 1261 value = TestFastReturnValues<double>(); |
1260 CHECK(value->IsNumber()); | 1262 CHECK(value->IsNumber()); |
1261 CHECK_EQ(kFastReturnValueDouble, value->ToNumber()->Value()); | 1263 CHECK_EQ(kFastReturnValueDouble, value->ToNumber(isolate)->Value()); |
1262 // check bool values | 1264 // check bool values |
1263 for (int i = 0; i < 2; i++) { | 1265 for (int i = 0; i < 2; i++) { |
1264 fast_return_value_bool = i == 0; | 1266 fast_return_value_bool = i == 0; |
1265 value = TestFastReturnValues<bool>(); | 1267 value = TestFastReturnValues<bool>(); |
1266 CHECK(value->IsBoolean()); | 1268 CHECK(value->IsBoolean()); |
1267 CHECK_EQ(fast_return_value_bool, value->ToBoolean()->Value()); | 1269 CHECK_EQ(fast_return_value_bool, value->ToBoolean(isolate)->Value()); |
1268 } | 1270 } |
1269 // check oddballs | 1271 // check oddballs |
1270 ReturnValueOddball oddballs[] = { | 1272 ReturnValueOddball oddballs[] = { |
1271 kNullReturnValue, | 1273 kNullReturnValue, |
1272 kUndefinedReturnValue, | 1274 kUndefinedReturnValue, |
1273 kEmptyStringReturnValue | 1275 kEmptyStringReturnValue |
1274 }; | 1276 }; |
1275 for (size_t i = 0; i < arraysize(oddballs); i++) { | 1277 for (size_t i = 0; i < arraysize(oddballs); i++) { |
1276 fast_return_value_void = oddballs[i]; | 1278 fast_return_value_void = oddballs[i]; |
1277 value = TestFastReturnValues<void>(); | 1279 value = TestFastReturnValues<void>(); |
(...skipping 3102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4380 Local<Value> result = script->Run(); | 4382 Local<Value> result = script->Run(); |
4381 CHECK(result.IsEmpty()); | 4383 CHECK(result.IsEmpty()); |
4382 CHECK(try_catch.HasCaught()); | 4384 CHECK(try_catch.HasCaught()); |
4383 String::Utf8Value exception_value(try_catch.Exception()); | 4385 String::Utf8Value exception_value(try_catch.Exception()); |
4384 CHECK_EQ(*exception_value, "panama!"); | 4386 CHECK_EQ(*exception_value, "panama!"); |
4385 } | 4387 } |
4386 | 4388 |
4387 | 4389 |
4388 TEST(TryCatchCustomException) { | 4390 TEST(TryCatchCustomException) { |
4389 LocalContext env; | 4391 LocalContext env; |
4390 v8::HandleScope scope(env->GetIsolate()); | 4392 v8::Isolate* isolate = env->GetIsolate(); |
| 4393 v8::HandleScope scope(isolate); |
4391 v8::TryCatch try_catch; | 4394 v8::TryCatch try_catch; |
4392 CompileRun("function CustomError() { this.a = 'b'; }" | 4395 CompileRun("function CustomError() { this.a = 'b'; }" |
4393 "(function f() { throw new CustomError(); })();"); | 4396 "(function f() { throw new CustomError(); })();"); |
4394 CHECK(try_catch.HasCaught()); | 4397 CHECK(try_catch.HasCaught()); |
4395 CHECK(try_catch.Exception()->ToObject()-> | 4398 CHECK(try_catch.Exception()->ToObject(isolate)->Get(v8_str("a"))->Equals( |
4396 Get(v8_str("a"))->Equals(v8_str("b"))); | 4399 v8_str("b"))); |
4397 } | 4400 } |
4398 | 4401 |
4399 | 4402 |
4400 bool message_received; | 4403 bool message_received; |
4401 | 4404 |
4402 | 4405 |
4403 static void check_message_0(v8::Handle<v8::Message> message, | 4406 static void check_message_0(v8::Handle<v8::Message> message, |
4404 v8::Handle<Value> data) { | 4407 v8::Handle<Value> data) { |
4405 CHECK_EQ(5.76, data->NumberValue()); | 4408 CHECK_EQ(5.76, data->NumberValue()); |
4406 CHECK_EQ(6.75, message->GetScriptOrigin().ResourceName()->NumberValue()); | 4409 CHECK_EQ(6.75, message->GetScriptOrigin().ResourceName()->NumberValue()); |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4880 static void CheckUncle(v8::TryCatch* try_catch) { | 4883 static void CheckUncle(v8::TryCatch* try_catch) { |
4881 CHECK(try_catch->HasCaught()); | 4884 CHECK(try_catch->HasCaught()); |
4882 String::Utf8Value str_value(try_catch->Exception()); | 4885 String::Utf8Value str_value(try_catch->Exception()); |
4883 CHECK_EQ(*str_value, "uncle?"); | 4886 CHECK_EQ(*str_value, "uncle?"); |
4884 try_catch->Reset(); | 4887 try_catch->Reset(); |
4885 } | 4888 } |
4886 | 4889 |
4887 | 4890 |
4888 THREADED_TEST(ConversionNumber) { | 4891 THREADED_TEST(ConversionNumber) { |
4889 LocalContext env; | 4892 LocalContext env; |
4890 v8::HandleScope scope(env->GetIsolate()); | 4893 v8::Isolate* isolate = env->GetIsolate(); |
| 4894 v8::HandleScope scope(isolate); |
4891 // Very large number. | 4895 // Very large number. |
4892 CompileRun("var obj = Math.pow(2,32) * 1237;"); | 4896 CompileRun("var obj = Math.pow(2,32) * 1237;"); |
4893 Local<Value> obj = env->Global()->Get(v8_str("obj")); | 4897 Local<Value> obj = env->Global()->Get(v8_str("obj")); |
4894 CHECK_EQ(5312874545152.0, obj->ToNumber()->Value()); | 4898 CHECK_EQ(5312874545152.0, obj->ToNumber(isolate)->Value()); |
4895 CHECK_EQ(0, obj->ToInt32()->Value()); | 4899 CHECK_EQ(0, obj->ToInt32(isolate)->Value()); |
4896 CHECK(0u == obj->ToUint32()->Value()); // NOLINT - no CHECK_EQ for unsigned. | 4900 CHECK(0u == |
| 4901 obj->ToUint32(isolate)->Value()); // NOLINT - no CHECK_EQ for unsigned. |
4897 // Large number. | 4902 // Large number. |
4898 CompileRun("var obj = -1234567890123;"); | 4903 CompileRun("var obj = -1234567890123;"); |
4899 obj = env->Global()->Get(v8_str("obj")); | 4904 obj = env->Global()->Get(v8_str("obj")); |
4900 CHECK_EQ(-1234567890123.0, obj->ToNumber()->Value()); | 4905 CHECK_EQ(-1234567890123.0, obj->ToNumber(isolate)->Value()); |
4901 CHECK_EQ(-1912276171, obj->ToInt32()->Value()); | 4906 CHECK_EQ(-1912276171, obj->ToInt32(isolate)->Value()); |
4902 CHECK(2382691125u == obj->ToUint32()->Value()); // NOLINT | 4907 CHECK(2382691125u == obj->ToUint32(isolate)->Value()); // NOLINT |
4903 // Small positive integer. | 4908 // Small positive integer. |
4904 CompileRun("var obj = 42;"); | 4909 CompileRun("var obj = 42;"); |
4905 obj = env->Global()->Get(v8_str("obj")); | 4910 obj = env->Global()->Get(v8_str("obj")); |
4906 CHECK_EQ(42.0, obj->ToNumber()->Value()); | 4911 CHECK_EQ(42.0, obj->ToNumber(isolate)->Value()); |
4907 CHECK_EQ(42, obj->ToInt32()->Value()); | 4912 CHECK_EQ(42, obj->ToInt32(isolate)->Value()); |
4908 CHECK(42u == obj->ToUint32()->Value()); // NOLINT | 4913 CHECK(42u == obj->ToUint32(isolate)->Value()); // NOLINT |
4909 // Negative integer. | 4914 // Negative integer. |
4910 CompileRun("var obj = -37;"); | 4915 CompileRun("var obj = -37;"); |
4911 obj = env->Global()->Get(v8_str("obj")); | 4916 obj = env->Global()->Get(v8_str("obj")); |
4912 CHECK_EQ(-37.0, obj->ToNumber()->Value()); | 4917 CHECK_EQ(-37.0, obj->ToNumber(isolate)->Value()); |
4913 CHECK_EQ(-37, obj->ToInt32()->Value()); | 4918 CHECK_EQ(-37, obj->ToInt32(isolate)->Value()); |
4914 CHECK(4294967259u == obj->ToUint32()->Value()); // NOLINT | 4919 CHECK(4294967259u == obj->ToUint32(isolate)->Value()); // NOLINT |
4915 // Positive non-int32 integer. | 4920 // Positive non-int32 integer. |
4916 CompileRun("var obj = 0x81234567;"); | 4921 CompileRun("var obj = 0x81234567;"); |
4917 obj = env->Global()->Get(v8_str("obj")); | 4922 obj = env->Global()->Get(v8_str("obj")); |
4918 CHECK_EQ(2166572391.0, obj->ToNumber()->Value()); | 4923 CHECK_EQ(2166572391.0, obj->ToNumber(isolate)->Value()); |
4919 CHECK_EQ(-2128394905, obj->ToInt32()->Value()); | 4924 CHECK_EQ(-2128394905, obj->ToInt32(isolate)->Value()); |
4920 CHECK(2166572391u == obj->ToUint32()->Value()); // NOLINT | 4925 CHECK(2166572391u == obj->ToUint32(isolate)->Value()); // NOLINT |
4921 // Fraction. | 4926 // Fraction. |
4922 CompileRun("var obj = 42.3;"); | 4927 CompileRun("var obj = 42.3;"); |
4923 obj = env->Global()->Get(v8_str("obj")); | 4928 obj = env->Global()->Get(v8_str("obj")); |
4924 CHECK_EQ(42.3, obj->ToNumber()->Value()); | 4929 CHECK_EQ(42.3, obj->ToNumber(isolate)->Value()); |
4925 CHECK_EQ(42, obj->ToInt32()->Value()); | 4930 CHECK_EQ(42, obj->ToInt32(isolate)->Value()); |
4926 CHECK(42u == obj->ToUint32()->Value()); // NOLINT | 4931 CHECK(42u == obj->ToUint32(isolate)->Value()); // NOLINT |
4927 // Large negative fraction. | 4932 // Large negative fraction. |
4928 CompileRun("var obj = -5726623061.75;"); | 4933 CompileRun("var obj = -5726623061.75;"); |
4929 obj = env->Global()->Get(v8_str("obj")); | 4934 obj = env->Global()->Get(v8_str("obj")); |
4930 CHECK_EQ(-5726623061.75, obj->ToNumber()->Value()); | 4935 CHECK_EQ(-5726623061.75, obj->ToNumber(isolate)->Value()); |
4931 CHECK_EQ(-1431655765, obj->ToInt32()->Value()); | 4936 CHECK_EQ(-1431655765, obj->ToInt32(isolate)->Value()); |
4932 CHECK(2863311531u == obj->ToUint32()->Value()); // NOLINT | 4937 CHECK(2863311531u == obj->ToUint32(isolate)->Value()); // NOLINT |
4933 } | 4938 } |
4934 | 4939 |
4935 | 4940 |
4936 THREADED_TEST(isNumberType) { | 4941 THREADED_TEST(isNumberType) { |
4937 LocalContext env; | 4942 LocalContext env; |
4938 v8::HandleScope scope(env->GetIsolate()); | 4943 v8::HandleScope scope(env->GetIsolate()); |
4939 // Very large number. | 4944 // Very large number. |
4940 CompileRun("var obj = Math.pow(2,32) * 1237;"); | 4945 CompileRun("var obj = Math.pow(2,32) * 1237;"); |
4941 Local<Value> obj = env->Global()->Get(v8_str("obj")); | 4946 Local<Value> obj = env->Global()->Get(v8_str("obj")); |
4942 CHECK(!obj->IsInt32()); | 4947 CHECK(!obj->IsInt32()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4987 THREADED_TEST(ConversionException) { | 4992 THREADED_TEST(ConversionException) { |
4988 LocalContext env; | 4993 LocalContext env; |
4989 v8::Isolate* isolate = env->GetIsolate(); | 4994 v8::Isolate* isolate = env->GetIsolate(); |
4990 v8::HandleScope scope(isolate); | 4995 v8::HandleScope scope(isolate); |
4991 CompileRun( | 4996 CompileRun( |
4992 "function TestClass() { };" | 4997 "function TestClass() { };" |
4993 "TestClass.prototype.toString = function () { throw 'uncle?'; };" | 4998 "TestClass.prototype.toString = function () { throw 'uncle?'; };" |
4994 "var obj = new TestClass();"); | 4999 "var obj = new TestClass();"); |
4995 Local<Value> obj = env->Global()->Get(v8_str("obj")); | 5000 Local<Value> obj = env->Global()->Get(v8_str("obj")); |
4996 | 5001 |
4997 v8::TryCatch try_catch; | 5002 v8::TryCatch try_catch(isolate); |
4998 | 5003 |
4999 Local<Value> to_string_result = obj->ToString(); | 5004 Local<Value> to_string_result = obj->ToString(isolate); |
5000 CHECK(to_string_result.IsEmpty()); | 5005 CHECK(to_string_result.IsEmpty()); |
5001 CheckUncle(&try_catch); | 5006 CheckUncle(&try_catch); |
5002 | 5007 |
5003 Local<Value> to_number_result = obj->ToNumber(); | 5008 Local<Value> to_number_result = obj->ToNumber(isolate); |
5004 CHECK(to_number_result.IsEmpty()); | 5009 CHECK(to_number_result.IsEmpty()); |
5005 CheckUncle(&try_catch); | 5010 CheckUncle(&try_catch); |
5006 | 5011 |
5007 Local<Value> to_integer_result = obj->ToInteger(); | 5012 Local<Value> to_integer_result = obj->ToInteger(isolate); |
5008 CHECK(to_integer_result.IsEmpty()); | 5013 CHECK(to_integer_result.IsEmpty()); |
5009 CheckUncle(&try_catch); | 5014 CheckUncle(&try_catch); |
5010 | 5015 |
5011 Local<Value> to_uint32_result = obj->ToUint32(); | 5016 Local<Value> to_uint32_result = obj->ToUint32(isolate); |
5012 CHECK(to_uint32_result.IsEmpty()); | 5017 CHECK(to_uint32_result.IsEmpty()); |
5013 CheckUncle(&try_catch); | 5018 CheckUncle(&try_catch); |
5014 | 5019 |
5015 Local<Value> to_int32_result = obj->ToInt32(); | 5020 Local<Value> to_int32_result = obj->ToInt32(isolate); |
5016 CHECK(to_int32_result.IsEmpty()); | 5021 CHECK(to_int32_result.IsEmpty()); |
5017 CheckUncle(&try_catch); | 5022 CheckUncle(&try_catch); |
5018 | 5023 |
5019 Local<Value> to_object_result = v8::Undefined(isolate)->ToObject(); | 5024 Local<Value> to_object_result = v8::Undefined(isolate)->ToObject(isolate); |
5020 CHECK(to_object_result.IsEmpty()); | 5025 CHECK(to_object_result.IsEmpty()); |
5021 CHECK(try_catch.HasCaught()); | 5026 CHECK(try_catch.HasCaught()); |
5022 try_catch.Reset(); | 5027 try_catch.Reset(); |
5023 | 5028 |
5024 int32_t int32_value = obj->Int32Value(); | 5029 int32_t int32_value = obj->Int32Value(); |
5025 CHECK_EQ(0, int32_value); | 5030 CHECK_EQ(0, int32_value); |
5026 CheckUncle(&try_catch); | 5031 CheckUncle(&try_catch); |
5027 | 5032 |
5028 uint32_t uint32_value = obj->Uint32Value(); | 5033 uint32_t uint32_value = obj->Uint32Value(); |
5029 CHECK_EQ(0, uint32_value); | 5034 CHECK_EQ(0, uint32_value); |
(...skipping 15 matching lines...) Expand all Loading... |
5045 } | 5050 } |
5046 | 5051 |
5047 | 5052 |
5048 void CCatcher(const v8::FunctionCallbackInfo<v8::Value>& args) { | 5053 void CCatcher(const v8::FunctionCallbackInfo<v8::Value>& args) { |
5049 if (args.Length() < 1) { | 5054 if (args.Length() < 1) { |
5050 args.GetReturnValue().Set(false); | 5055 args.GetReturnValue().Set(false); |
5051 return; | 5056 return; |
5052 } | 5057 } |
5053 v8::HandleScope scope(args.GetIsolate()); | 5058 v8::HandleScope scope(args.GetIsolate()); |
5054 v8::TryCatch try_catch; | 5059 v8::TryCatch try_catch; |
5055 Local<Value> result = CompileRun(args[0]->ToString()); | 5060 Local<Value> result = CompileRun(args[0]->ToString(args.GetIsolate())); |
5056 CHECK(!try_catch.HasCaught() || result.IsEmpty()); | 5061 CHECK(!try_catch.HasCaught() || result.IsEmpty()); |
5057 args.GetReturnValue().Set(try_catch.HasCaught()); | 5062 args.GetReturnValue().Set(try_catch.HasCaught()); |
5058 } | 5063 } |
5059 | 5064 |
5060 | 5065 |
5061 THREADED_TEST(APICatch) { | 5066 THREADED_TEST(APICatch) { |
5062 v8::Isolate* isolate = CcTest::isolate(); | 5067 v8::Isolate* isolate = CcTest::isolate(); |
5063 v8::HandleScope scope(isolate); | 5068 v8::HandleScope scope(isolate); |
5064 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 5069 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
5065 templ->Set(v8_str("ThrowFromC"), | 5070 templ->Set(v8_str("ThrowFromC"), |
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6324 UnboxedDoubleIndexedPropertyEnumerator); | 6329 UnboxedDoubleIndexedPropertyEnumerator); |
6325 LocalContext context; | 6330 LocalContext context; |
6326 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 6331 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
6327 // When obj is created, force it to be Stored in a FastDoubleArray. | 6332 // When obj is created, force it to be Stored in a FastDoubleArray. |
6328 Local<Script> create_unboxed_double_script = v8_compile( | 6333 Local<Script> create_unboxed_double_script = v8_compile( |
6329 "obj[125000] = 1; for(i = 0; i < 80000; i+=2) { obj[i] = i; } " | 6334 "obj[125000] = 1; for(i = 0; i < 80000; i+=2) { obj[i] = i; } " |
6330 "key_count = 0; " | 6335 "key_count = 0; " |
6331 "for (x in obj) {key_count++;};" | 6336 "for (x in obj) {key_count++;};" |
6332 "obj;"); | 6337 "obj;"); |
6333 Local<Value> result = create_unboxed_double_script->Run(); | 6338 Local<Value> result = create_unboxed_double_script->Run(); |
6334 CHECK(result->ToObject()->HasRealIndexedProperty(2000)); | 6339 CHECK(result->ToObject(isolate)->HasRealIndexedProperty(2000)); |
6335 Local<Script> key_count_check = v8_compile("key_count;"); | 6340 Local<Script> key_count_check = v8_compile("key_count;"); |
6336 result = key_count_check->Run(); | 6341 result = key_count_check->Run(); |
6337 CHECK_EQ(v8_num(40013), result); | 6342 CHECK_EQ(v8_num(40013), result); |
6338 } | 6343 } |
6339 | 6344 |
6340 | 6345 |
6341 void SloppyArgsIndexedPropertyEnumerator( | 6346 void SloppyArgsIndexedPropertyEnumerator( |
6342 const v8::PropertyCallbackInfo<v8::Array>& info) { | 6347 const v8::PropertyCallbackInfo<v8::Array>& info) { |
6343 // Force the list of returned keys to be stored in a Arguments object. | 6348 // Force the list of returned keys to be stored in a Arguments object. |
6344 Local<Script> indexed_property_names_script = v8_compile( | 6349 Local<Script> indexed_property_names_script = v8_compile( |
(...skipping 2566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8911 CompileRun( | 8916 CompileRun( |
8912 "(function()" | 8917 "(function()" |
8913 " { try { throw ''; } finally { throw 0; }" | 8918 " { try { throw ''; } finally { throw 0; }" |
8914 "})()"); | 8919 "})()"); |
8915 CHECK(try_catch.HasCaught()); | 8920 CHECK(try_catch.HasCaught()); |
8916 } | 8921 } |
8917 | 8922 |
8918 | 8923 |
8919 void CEvaluate(const v8::FunctionCallbackInfo<v8::Value>& args) { | 8924 void CEvaluate(const v8::FunctionCallbackInfo<v8::Value>& args) { |
8920 v8::HandleScope scope(args.GetIsolate()); | 8925 v8::HandleScope scope(args.GetIsolate()); |
8921 CompileRun(args[0]->ToString()); | 8926 CompileRun(args[0]->ToString(args.GetIsolate())); |
8922 } | 8927 } |
8923 | 8928 |
8924 | 8929 |
8925 TEST(TryCatchFinallyStoresMessageUsingTryCatchHandler) { | 8930 TEST(TryCatchFinallyStoresMessageUsingTryCatchHandler) { |
8926 v8::Isolate* isolate = CcTest::isolate(); | 8931 v8::Isolate* isolate = CcTest::isolate(); |
8927 v8::HandleScope scope(isolate); | 8932 v8::HandleScope scope(isolate); |
8928 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 8933 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
8929 templ->Set(v8_str("CEvaluate"), | 8934 templ->Set(v8_str("CEvaluate"), |
8930 v8::FunctionTemplate::New(isolate, CEvaluate)); | 8935 v8::FunctionTemplate::New(isolate, CEvaluate)); |
8931 LocalContext context(0, templ); | 8936 LocalContext context(0, templ); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9185 | 9190 |
9186 named_security_check_with_gc_called = false; | 9191 named_security_check_with_gc_called = false; |
9187 CompileRun("obj.foo = new String(1001);"); | 9192 CompileRun("obj.foo = new String(1001);"); |
9188 CHECK(named_security_check_with_gc_called); | 9193 CHECK(named_security_check_with_gc_called); |
9189 | 9194 |
9190 indexed_security_check_with_gc_called = false; | 9195 indexed_security_check_with_gc_called = false; |
9191 CompileRun("obj[0] = new String(1002);"); | 9196 CompileRun("obj[0] = new String(1002);"); |
9192 CHECK(indexed_security_check_with_gc_called); | 9197 CHECK(indexed_security_check_with_gc_called); |
9193 | 9198 |
9194 named_security_check_with_gc_called = false; | 9199 named_security_check_with_gc_called = false; |
9195 CHECK(CompileRun("obj.foo")->ToString()->Equals(v8_str("1001"))); | 9200 CHECK(CompileRun("obj.foo")->ToString(isolate)->Equals(v8_str("1001"))); |
9196 CHECK(named_security_check_with_gc_called); | 9201 CHECK(named_security_check_with_gc_called); |
9197 | 9202 |
9198 indexed_security_check_with_gc_called = false; | 9203 indexed_security_check_with_gc_called = false; |
9199 CHECK(CompileRun("obj[0]")->ToString()->Equals(v8_str("1002"))); | 9204 CHECK(CompileRun("obj[0]")->ToString(isolate)->Equals(v8_str("1002"))); |
9200 CHECK(indexed_security_check_with_gc_called); | 9205 CHECK(indexed_security_check_with_gc_called); |
9201 } | 9206 } |
9202 | 9207 |
9203 | 9208 |
9204 THREADED_TEST(CrossDomainDelete) { | 9209 THREADED_TEST(CrossDomainDelete) { |
9205 LocalContext env1; | 9210 LocalContext env1; |
9206 v8::HandleScope handle_scope(env1->GetIsolate()); | 9211 v8::HandleScope handle_scope(env1->GetIsolate()); |
9207 v8::Handle<Context> env2 = Context::New(env1->GetIsolate()); | 9212 v8::Handle<Context> env2 = Context::New(env1->GetIsolate()); |
9208 | 9213 |
9209 Local<Value> foo = v8_str("foo"); | 9214 Local<Value> foo = v8_str("foo"); |
(...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11050 value = object1->Get(v8_str("a")); | 11055 value = object1->Get(v8_str("a")); |
11051 CHECK(value->IsInt32()); | 11056 CHECK(value->IsInt32()); |
11052 CHECK(!try_catch.HasCaught()); | 11057 CHECK(!try_catch.HasCaught()); |
11053 CHECK_EQ(28, value->Int32Value()); | 11058 CHECK_EQ(28, value->Int32Value()); |
11054 | 11059 |
11055 // Call the Object's constructor with a String. | 11060 // Call the Object's constructor with a String. |
11056 value = CompileRun( | 11061 value = CompileRun( |
11057 "(function() { var o = new obj('tipli'); return o.a; })()"); | 11062 "(function() { var o = new obj('tipli'); return o.a; })()"); |
11058 CHECK(!try_catch.HasCaught()); | 11063 CHECK(!try_catch.HasCaught()); |
11059 CHECK(value->IsString()); | 11064 CHECK(value->IsString()); |
11060 String::Utf8Value string_value1(value->ToString()); | 11065 String::Utf8Value string_value1(value->ToString(isolate)); |
11061 CHECK_EQ("tipli", *string_value1); | 11066 CHECK_EQ("tipli", *string_value1); |
11062 | 11067 |
11063 Local<Value> args2[] = { v8_str("tipli") }; | 11068 Local<Value> args2[] = { v8_str("tipli") }; |
11064 Local<Value> value_obj2 = instance->CallAsConstructor(1, args2); | 11069 Local<Value> value_obj2 = instance->CallAsConstructor(1, args2); |
11065 CHECK(value_obj2->IsObject()); | 11070 CHECK(value_obj2->IsObject()); |
11066 Local<Object> object2 = Local<Object>::Cast(value_obj2); | 11071 Local<Object> object2 = Local<Object>::Cast(value_obj2); |
11067 value = object2->Get(v8_str("a")); | 11072 value = object2->Get(v8_str("a")); |
11068 CHECK(!try_catch.HasCaught()); | 11073 CHECK(!try_catch.HasCaught()); |
11069 CHECK(value->IsString()); | 11074 CHECK(value->IsString()); |
11070 String::Utf8Value string_value2(value->ToString()); | 11075 String::Utf8Value string_value2(value->ToString(isolate)); |
11071 CHECK_EQ("tipli", *string_value2); | 11076 CHECK_EQ("tipli", *string_value2); |
11072 | 11077 |
11073 // Call the Object's constructor with a Boolean. | 11078 // Call the Object's constructor with a Boolean. |
11074 value = CompileRun("(function() { var o = new obj(true); return o.a; })()"); | 11079 value = CompileRun("(function() { var o = new obj(true); return o.a; })()"); |
11075 CHECK(!try_catch.HasCaught()); | 11080 CHECK(!try_catch.HasCaught()); |
11076 CHECK(value->IsBoolean()); | 11081 CHECK(value->IsBoolean()); |
11077 CHECK_EQ(true, value->BooleanValue()); | 11082 CHECK_EQ(true, value->BooleanValue()); |
11078 | 11083 |
11079 Handle<Value> args3[] = { v8::True(isolate) }; | 11084 Handle<Value> args3[] = { v8::True(isolate) }; |
11080 Local<Value> value_obj3 = instance->CallAsConstructor(1, args3); | 11085 Local<Value> value_obj3 = instance->CallAsConstructor(1, args3); |
(...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12856 "for (var i = 0; i < 100; i++) {" | 12861 "for (var i = 0; i < 100; i++) {" |
12857 " result = receiver.method(41);" | 12862 " result = receiver.method(41);" |
12858 " if (i == 50) {" | 12863 " if (i == 50) {" |
12859 " saved_result = result;" | 12864 " saved_result = result;" |
12860 " receiver = 333;" | 12865 " receiver = 333;" |
12861 " }" | 12866 " }" |
12862 "}"); | 12867 "}"); |
12863 CHECK(try_catch.HasCaught()); | 12868 CHECK(try_catch.HasCaught()); |
12864 // TODO(verwaest): Adjust message. | 12869 // TODO(verwaest): Adjust message. |
12865 CHECK_EQ(v8_str("TypeError: undefined is not a function"), | 12870 CHECK_EQ(v8_str("TypeError: undefined is not a function"), |
12866 try_catch.Exception()->ToString()); | 12871 try_catch.Exception()->ToString(isolate)); |
12867 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 12872 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
12868 CHECK_GE(interceptor_call_count, 50); | 12873 CHECK_GE(interceptor_call_count, 50); |
12869 } | 12874 } |
12870 | 12875 |
12871 | 12876 |
12872 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) { | 12877 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) { |
12873 int interceptor_call_count = 0; | 12878 int interceptor_call_count = 0; |
12874 v8::Isolate* isolate = CcTest::isolate(); | 12879 v8::Isolate* isolate = CcTest::isolate(); |
12875 v8::HandleScope scope(isolate); | 12880 v8::HandleScope scope(isolate); |
12876 v8::Handle<v8::FunctionTemplate> fun_templ = | 12881 v8::Handle<v8::FunctionTemplate> fun_templ = |
(...skipping 21 matching lines...) Expand all Loading... |
12898 "var saved_result = 0;" | 12903 "var saved_result = 0;" |
12899 "for (var i = 0; i < 100; i++) {" | 12904 "for (var i = 0; i < 100; i++) {" |
12900 " result = receiver.method(41);" | 12905 " result = receiver.method(41);" |
12901 " if (i == 50) {" | 12906 " if (i == 50) {" |
12902 " saved_result = result;" | 12907 " saved_result = result;" |
12903 " receiver = {method: receiver.method};" | 12908 " receiver = {method: receiver.method};" |
12904 " }" | 12909 " }" |
12905 "}"); | 12910 "}"); |
12906 CHECK(try_catch.HasCaught()); | 12911 CHECK(try_catch.HasCaught()); |
12907 CHECK_EQ(v8_str("TypeError: Illegal invocation"), | 12912 CHECK_EQ(v8_str("TypeError: Illegal invocation"), |
12908 try_catch.Exception()->ToString()); | 12913 try_catch.Exception()->ToString(isolate)); |
12909 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 12914 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
12910 CHECK_GE(interceptor_call_count, 50); | 12915 CHECK_GE(interceptor_call_count, 50); |
12911 } | 12916 } |
12912 | 12917 |
12913 | 12918 |
12914 THREADED_PROFILED_TEST(CallICFastApi_TrivialSignature) { | 12919 THREADED_PROFILED_TEST(CallICFastApi_TrivialSignature) { |
12915 v8::Isolate* isolate = CcTest::isolate(); | 12920 v8::Isolate* isolate = CcTest::isolate(); |
12916 v8::HandleScope scope(isolate); | 12921 v8::HandleScope scope(isolate); |
12917 v8::Handle<v8::FunctionTemplate> fun_templ = | 12922 v8::Handle<v8::FunctionTemplate> fun_templ = |
12918 v8::FunctionTemplate::New(isolate); | 12923 v8::FunctionTemplate::New(isolate); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13031 "for (var i = 0; i < 100; i++) {" | 13036 "for (var i = 0; i < 100; i++) {" |
13032 " result = receiver.method(41);" | 13037 " result = receiver.method(41);" |
13033 " if (i == 50) {" | 13038 " if (i == 50) {" |
13034 " saved_result = result;" | 13039 " saved_result = result;" |
13035 " receiver = 333;" | 13040 " receiver = 333;" |
13036 " }" | 13041 " }" |
13037 "}"); | 13042 "}"); |
13038 CHECK(try_catch.HasCaught()); | 13043 CHECK(try_catch.HasCaught()); |
13039 // TODO(verwaest): Adjust message. | 13044 // TODO(verwaest): Adjust message. |
13040 CHECK_EQ(v8_str("TypeError: undefined is not a function"), | 13045 CHECK_EQ(v8_str("TypeError: undefined is not a function"), |
13041 try_catch.Exception()->ToString()); | 13046 try_catch.Exception()->ToString(isolate)); |
13042 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 13047 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
13043 } | 13048 } |
13044 | 13049 |
13045 | 13050 |
13046 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) { | 13051 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) { |
13047 v8::Isolate* isolate = CcTest::isolate(); | 13052 v8::Isolate* isolate = CcTest::isolate(); |
13048 v8::HandleScope scope(isolate); | 13053 v8::HandleScope scope(isolate); |
13049 v8::Handle<v8::FunctionTemplate> fun_templ = | 13054 v8::Handle<v8::FunctionTemplate> fun_templ = |
13050 v8::FunctionTemplate::New(isolate); | 13055 v8::FunctionTemplate::New(isolate); |
13051 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( | 13056 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
(...skipping 17 matching lines...) Expand all Loading... |
13069 "var saved_result = 0;" | 13074 "var saved_result = 0;" |
13070 "for (var i = 0; i < 100; i++) {" | 13075 "for (var i = 0; i < 100; i++) {" |
13071 " result = receiver.method(41);" | 13076 " result = receiver.method(41);" |
13072 " if (i == 50) {" | 13077 " if (i == 50) {" |
13073 " saved_result = result;" | 13078 " saved_result = result;" |
13074 " receiver = Object.create(receiver);" | 13079 " receiver = Object.create(receiver);" |
13075 " }" | 13080 " }" |
13076 "}"); | 13081 "}"); |
13077 CHECK(try_catch.HasCaught()); | 13082 CHECK(try_catch.HasCaught()); |
13078 CHECK_EQ(v8_str("TypeError: Illegal invocation"), | 13083 CHECK_EQ(v8_str("TypeError: Illegal invocation"), |
13079 try_catch.Exception()->ToString()); | 13084 try_catch.Exception()->ToString(isolate)); |
13080 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 13085 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
13081 } | 13086 } |
13082 | 13087 |
13083 | 13088 |
13084 v8::Handle<Value> keyed_call_ic_function; | 13089 v8::Handle<Value> keyed_call_ic_function; |
13085 | 13090 |
13086 static void InterceptorKeyedCallICGetter( | 13091 static void InterceptorKeyedCallICGetter( |
13087 Local<String> name, | 13092 Local<String> name, |
13088 const v8::PropertyCallbackInfo<v8::Value>& info) { | 13093 const v8::PropertyCallbackInfo<v8::Value>& info) { |
13089 ApiTestFuzzer::Fuzz(); | 13094 ApiTestFuzzer::Fuzz(); |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13656 | 13661 |
13657 Local<String> customized_tostring = v8_str("customized toString"); | 13662 Local<String> customized_tostring = v8_str("customized toString"); |
13658 | 13663 |
13659 // Replace Object.prototype.toString | 13664 // Replace Object.prototype.toString |
13660 v8_compile("Object.prototype.toString = function() {" | 13665 v8_compile("Object.prototype.toString = function() {" |
13661 " return 'customized toString';" | 13666 " return 'customized toString';" |
13662 "}")->Run(); | 13667 "}")->Run(); |
13663 | 13668 |
13664 // Normal ToString call should call replaced Object.prototype.toString | 13669 // Normal ToString call should call replaced Object.prototype.toString |
13665 Local<v8::Object> instance = templ->GetFunction()->NewInstance(); | 13670 Local<v8::Object> instance = templ->GetFunction()->NewInstance(); |
13666 Local<String> value = instance->ToString(); | 13671 Local<String> value = instance->ToString(isolate); |
13667 CHECK(value->IsString() && value->Equals(customized_tostring)); | 13672 CHECK(value->IsString() && value->Equals(customized_tostring)); |
13668 | 13673 |
13669 // ObjectProtoToString should not call replace toString function. | 13674 // ObjectProtoToString should not call replace toString function. |
13670 value = instance->ObjectProtoToString(); | 13675 value = instance->ObjectProtoToString(); |
13671 CHECK(value->IsString() && value->Equals(v8_str("[object MyClass]"))); | 13676 CHECK(value->IsString() && value->Equals(v8_str("[object MyClass]"))); |
13672 | 13677 |
13673 // Check global | 13678 // Check global |
13674 value = context->Global()->ObjectProtoToString(); | 13679 value = context->Global()->ObjectProtoToString(); |
13675 CHECK(value->IsString() && value->Equals(v8_str("[object global]"))); | 13680 CHECK(value->IsString() && value->Equals(v8_str("[object global]"))); |
13676 | 13681 |
(...skipping 16 matching lines...) Expand all Loading... |
13693 Local<String> customized_tostring = v8_str("customized toString"); | 13698 Local<String> customized_tostring = v8_str("customized toString"); |
13694 | 13699 |
13695 // Replace Object.prototype.toString | 13700 // Replace Object.prototype.toString |
13696 CompileRun( | 13701 CompileRun( |
13697 "Object.prototype.toString = function() {" | 13702 "Object.prototype.toString = function() {" |
13698 " return 'customized toString';" | 13703 " return 'customized toString';" |
13699 "}"); | 13704 "}"); |
13700 | 13705 |
13701 // Normal ToString call should call replaced Object.prototype.toString | 13706 // Normal ToString call should call replaced Object.prototype.toString |
13702 Local<v8::Object> instance = templ->GetFunction()->NewInstance(); | 13707 Local<v8::Object> instance = templ->GetFunction()->NewInstance(); |
13703 Local<String> value = instance->ToString(); | 13708 Local<String> value = instance->ToString(isolate); |
13704 CHECK(value->IsString() && value->Equals(customized_tostring)); | 13709 CHECK(value->IsString() && value->Equals(customized_tostring)); |
13705 | 13710 |
13706 // ObjectProtoToString should not call replace toString function. | 13711 // ObjectProtoToString should not call replace toString function. |
13707 value = instance->ObjectProtoToString(); | 13712 value = instance->ObjectProtoToString(); |
13708 CHECK(value->IsString() && value->Equals(v8_str("[object MyClass]"))); | 13713 CHECK(value->IsString() && value->Equals(v8_str("[object MyClass]"))); |
13709 | 13714 |
13710 // Check global | 13715 // Check global |
13711 value = context->Global()->ObjectProtoToString(); | 13716 value = context->Global()->ObjectProtoToString(); |
13712 CHECK(value->IsString() && value->Equals(v8_str("[object global]"))); | 13717 CHECK(value->IsString() && value->Equals(v8_str("[object global]"))); |
13713 | 13718 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13792 { | 13797 { |
13793 TryCatch try_catch; | 13798 TryCatch try_catch; |
13794 value = obj.As<v8::Object>()->ObjectProtoToString(); | 13799 value = obj.As<v8::Object>()->ObjectProtoToString(); |
13795 CHECK(value->IsString() && value->Equals(v8_str("[object Test]"))); | 13800 CHECK(value->IsString() && value->Equals(v8_str("[object Test]"))); |
13796 CHECK(!try_catch.HasCaught()); | 13801 CHECK(!try_catch.HasCaught()); |
13797 } | 13802 } |
13798 } | 13803 } |
13799 | 13804 |
13800 | 13805 |
13801 THREADED_TEST(ObjectGetConstructorName) { | 13806 THREADED_TEST(ObjectGetConstructorName) { |
| 13807 v8::Isolate* isolate = CcTest::isolate(); |
13802 LocalContext context; | 13808 LocalContext context; |
13803 v8::HandleScope scope(context->GetIsolate()); | 13809 v8::HandleScope scope(isolate); |
13804 v8_compile("function Parent() {};" | 13810 v8_compile("function Parent() {};" |
13805 "function Child() {};" | 13811 "function Child() {};" |
13806 "Child.prototype = new Parent();" | 13812 "Child.prototype = new Parent();" |
13807 "var outer = { inner: function() { } };" | 13813 "var outer = { inner: function() { } };" |
13808 "var p = new Parent();" | 13814 "var p = new Parent();" |
13809 "var c = new Child();" | 13815 "var c = new Child();" |
13810 "var x = new outer.inner();")->Run(); | 13816 "var x = new outer.inner();")->Run(); |
13811 | 13817 |
13812 Local<v8::Value> p = context->Global()->Get(v8_str("p")); | 13818 Local<v8::Value> p = context->Global()->Get(v8_str("p")); |
13813 CHECK(p->IsObject() && p->ToObject()->GetConstructorName()->Equals( | 13819 CHECK(p->IsObject() && |
13814 v8_str("Parent"))); | 13820 p->ToObject(isolate)->GetConstructorName()->Equals(v8_str("Parent"))); |
13815 | 13821 |
13816 Local<v8::Value> c = context->Global()->Get(v8_str("c")); | 13822 Local<v8::Value> c = context->Global()->Get(v8_str("c")); |
13817 CHECK(c->IsObject() && c->ToObject()->GetConstructorName()->Equals( | 13823 CHECK(c->IsObject() && |
13818 v8_str("Child"))); | 13824 c->ToObject(isolate)->GetConstructorName()->Equals(v8_str("Child"))); |
13819 | 13825 |
13820 Local<v8::Value> x = context->Global()->Get(v8_str("x")); | 13826 Local<v8::Value> x = context->Global()->Get(v8_str("x")); |
13821 CHECK(x->IsObject() && x->ToObject()->GetConstructorName()->Equals( | 13827 CHECK(x->IsObject() && |
13822 v8_str("outer.inner"))); | 13828 x->ToObject(isolate)->GetConstructorName()->Equals( |
| 13829 v8_str("outer.inner"))); |
13823 } | 13830 } |
13824 | 13831 |
13825 | 13832 |
13826 bool ApiTestFuzzer::fuzzing_ = false; | 13833 bool ApiTestFuzzer::fuzzing_ = false; |
13827 v8::base::Semaphore ApiTestFuzzer::all_tests_done_(0); | 13834 v8::base::Semaphore ApiTestFuzzer::all_tests_done_(0); |
13828 int ApiTestFuzzer::active_tests_; | 13835 int ApiTestFuzzer::active_tests_; |
13829 int ApiTestFuzzer::tests_being_run_; | 13836 int ApiTestFuzzer::tests_being_run_; |
13830 int ApiTestFuzzer::current_; | 13837 int ApiTestFuzzer::current_; |
13831 | 13838 |
13832 | 13839 |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14360 return value; | 14367 return value; |
14361 } | 14368 } |
14362 | 14369 |
14363 | 14370 |
14364 THREADED_TEST(NestedHandleScopeAndContexts) { | 14371 THREADED_TEST(NestedHandleScopeAndContexts) { |
14365 v8::Isolate* isolate = CcTest::isolate(); | 14372 v8::Isolate* isolate = CcTest::isolate(); |
14366 v8::HandleScope outer(isolate); | 14373 v8::HandleScope outer(isolate); |
14367 v8::Local<Context> env = Context::New(isolate); | 14374 v8::Local<Context> env = Context::New(isolate); |
14368 env->Enter(); | 14375 env->Enter(); |
14369 v8::Handle<Value> value = NestedScope(env); | 14376 v8::Handle<Value> value = NestedScope(env); |
14370 v8::Handle<String> str(value->ToString()); | 14377 v8::Handle<String> str(value->ToString(isolate)); |
14371 CHECK(!str.IsEmpty()); | 14378 CHECK(!str.IsEmpty()); |
14372 env->Exit(); | 14379 env->Exit(); |
14373 } | 14380 } |
14374 | 14381 |
14375 | 14382 |
14376 static bool MatchPointers(void* key1, void* key2) { | 14383 static bool MatchPointers(void* key1, void* key2) { |
14377 return key1 == key2; | 14384 return key1 == key2; |
14378 } | 14385 } |
14379 | 14386 |
14380 | 14387 |
(...skipping 4414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18795 } | 18802 } |
18796 } | 18803 } |
18797 | 18804 |
18798 private: | 18805 private: |
18799 v8::String::ExternalStringResource* resource_[4]; | 18806 v8::String::ExternalStringResource* resource_[4]; |
18800 bool found_resource_[4]; | 18807 bool found_resource_[4]; |
18801 }; | 18808 }; |
18802 | 18809 |
18803 | 18810 |
18804 TEST(ExternalizeOldSpaceTwoByteCons) { | 18811 TEST(ExternalizeOldSpaceTwoByteCons) { |
| 18812 v8::Isolate* isolate = CcTest::isolate(); |
18805 LocalContext env; | 18813 LocalContext env; |
18806 v8::HandleScope scope(env->GetIsolate()); | 18814 v8::HandleScope scope(isolate); |
18807 v8::Local<v8::String> cons = | 18815 v8::Local<v8::String> cons = |
18808 CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString(); | 18816 CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString(isolate); |
18809 CHECK(v8::Utils::OpenHandle(*cons)->IsConsString()); | 18817 CHECK(v8::Utils::OpenHandle(*cons)->IsConsString()); |
18810 CcTest::heap()->CollectAllAvailableGarbage(); | 18818 CcTest::heap()->CollectAllAvailableGarbage(); |
18811 CHECK(CcTest::heap()->old_pointer_space()->Contains( | 18819 CHECK(CcTest::heap()->old_pointer_space()->Contains( |
18812 *v8::Utils::OpenHandle(*cons))); | 18820 *v8::Utils::OpenHandle(*cons))); |
18813 | 18821 |
18814 TestResource* resource = new TestResource( | 18822 TestResource* resource = new TestResource( |
18815 AsciiToTwoByteString("Romeo Montague Juliet Capulet")); | 18823 AsciiToTwoByteString("Romeo Montague Juliet Capulet")); |
18816 cons->MakeExternal(resource); | 18824 cons->MakeExternal(resource); |
18817 | 18825 |
18818 CHECK(cons->IsExternal()); | 18826 CHECK(cons->IsExternal()); |
18819 CHECK_EQ(resource, cons->GetExternalStringResource()); | 18827 CHECK_EQ(resource, cons->GetExternalStringResource()); |
18820 String::Encoding encoding; | 18828 String::Encoding encoding; |
18821 CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding)); | 18829 CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding)); |
18822 CHECK_EQ(String::TWO_BYTE_ENCODING, encoding); | 18830 CHECK_EQ(String::TWO_BYTE_ENCODING, encoding); |
18823 } | 18831 } |
18824 | 18832 |
18825 | 18833 |
18826 TEST(ExternalizeOldSpaceOneByteCons) { | 18834 TEST(ExternalizeOldSpaceOneByteCons) { |
| 18835 v8::Isolate* isolate = CcTest::isolate(); |
18827 LocalContext env; | 18836 LocalContext env; |
18828 v8::HandleScope scope(env->GetIsolate()); | 18837 v8::HandleScope scope(isolate); |
18829 v8::Local<v8::String> cons = | 18838 v8::Local<v8::String> cons = |
18830 CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString(); | 18839 CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString(isolate); |
18831 CHECK(v8::Utils::OpenHandle(*cons)->IsConsString()); | 18840 CHECK(v8::Utils::OpenHandle(*cons)->IsConsString()); |
18832 CcTest::heap()->CollectAllAvailableGarbage(); | 18841 CcTest::heap()->CollectAllAvailableGarbage(); |
18833 CHECK(CcTest::heap()->old_pointer_space()->Contains( | 18842 CHECK(CcTest::heap()->old_pointer_space()->Contains( |
18834 *v8::Utils::OpenHandle(*cons))); | 18843 *v8::Utils::OpenHandle(*cons))); |
18835 | 18844 |
18836 TestOneByteResource* resource = | 18845 TestOneByteResource* resource = |
18837 new TestOneByteResource(i::StrDup("Romeo Montague Juliet Capulet")); | 18846 new TestOneByteResource(i::StrDup("Romeo Montague Juliet Capulet")); |
18838 cons->MakeExternal(resource); | 18847 cons->MakeExternal(resource); |
18839 | 18848 |
18840 CHECK(cons->IsExternalOneByte()); | 18849 CHECK(cons->IsExternalOneByte()); |
18841 CHECK_EQ(resource, cons->GetExternalOneByteStringResource()); | 18850 CHECK_EQ(resource, cons->GetExternalOneByteStringResource()); |
18842 String::Encoding encoding; | 18851 String::Encoding encoding; |
18843 CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding)); | 18852 CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding)); |
18844 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding); | 18853 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding); |
18845 } | 18854 } |
18846 | 18855 |
18847 | 18856 |
18848 TEST(VisitExternalStrings) { | 18857 TEST(VisitExternalStrings) { |
| 18858 v8::Isolate* isolate = CcTest::isolate(); |
18849 LocalContext env; | 18859 LocalContext env; |
18850 v8::HandleScope scope(env->GetIsolate()); | 18860 v8::HandleScope scope(isolate); |
18851 const char* string = "Some string"; | 18861 const char* string = "Some string"; |
18852 uint16_t* two_byte_string = AsciiToTwoByteString(string); | 18862 uint16_t* two_byte_string = AsciiToTwoByteString(string); |
18853 TestResource* resource[4]; | 18863 TestResource* resource[4]; |
18854 resource[0] = new TestResource(two_byte_string); | 18864 resource[0] = new TestResource(two_byte_string); |
18855 v8::Local<v8::String> string0 = | 18865 v8::Local<v8::String> string0 = |
18856 v8::String::NewExternal(env->GetIsolate(), resource[0]); | 18866 v8::String::NewExternal(env->GetIsolate(), resource[0]); |
18857 resource[1] = new TestResource(two_byte_string, NULL, false); | 18867 resource[1] = new TestResource(two_byte_string, NULL, false); |
18858 v8::Local<v8::String> string1 = | 18868 v8::Local<v8::String> string1 = |
18859 v8::String::NewExternal(env->GetIsolate(), resource[1]); | 18869 v8::String::NewExternal(env->GetIsolate(), resource[1]); |
18860 | 18870 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18910 TEST(ExternalInternalizedStringCollectedAtTearDown) { | 18920 TEST(ExternalInternalizedStringCollectedAtTearDown) { |
18911 int destroyed = 0; | 18921 int destroyed = 0; |
18912 v8::Isolate* isolate = v8::Isolate::New(); | 18922 v8::Isolate* isolate = v8::Isolate::New(); |
18913 { v8::Isolate::Scope isolate_scope(isolate); | 18923 { v8::Isolate::Scope isolate_scope(isolate); |
18914 LocalContext env(isolate); | 18924 LocalContext env(isolate); |
18915 v8::HandleScope handle_scope(isolate); | 18925 v8::HandleScope handle_scope(isolate); |
18916 CompileRun("var ring = 'One string to test them all';"); | 18926 CompileRun("var ring = 'One string to test them all';"); |
18917 const char* s = "One string to test them all"; | 18927 const char* s = "One string to test them all"; |
18918 TestOneByteResource* inscription = | 18928 TestOneByteResource* inscription = |
18919 new TestOneByteResource(i::StrDup(s), &destroyed); | 18929 new TestOneByteResource(i::StrDup(s), &destroyed); |
18920 v8::Local<v8::String> ring = CompileRun("ring")->ToString(); | 18930 v8::Local<v8::String> ring = CompileRun("ring")->ToString(isolate); |
18921 CHECK(v8::Utils::OpenHandle(*ring)->IsInternalizedString()); | 18931 CHECK(v8::Utils::OpenHandle(*ring)->IsInternalizedString()); |
18922 ring->MakeExternal(inscription); | 18932 ring->MakeExternal(inscription); |
18923 // Ring is still alive. Orcs are roaming freely across our lands. | 18933 // Ring is still alive. Orcs are roaming freely across our lands. |
18924 CHECK_EQ(0, destroyed); | 18934 CHECK_EQ(0, destroyed); |
18925 USE(ring); | 18935 USE(ring); |
18926 } | 18936 } |
18927 | 18937 |
18928 isolate->Dispose(); | 18938 isolate->Dispose(); |
18929 // Ring has been destroyed. Free Peoples of Middle-earth Rejoice. | 18939 // Ring has been destroyed. Free Peoples of Middle-earth Rejoice. |
18930 CHECK_EQ(1, destroyed); | 18940 CHECK_EQ(1, destroyed); |
18931 } | 18941 } |
18932 | 18942 |
18933 | 18943 |
18934 TEST(ExternalInternalizedStringCollectedAtGC) { | 18944 TEST(ExternalInternalizedStringCollectedAtGC) { |
18935 int destroyed = 0; | 18945 int destroyed = 0; |
18936 { LocalContext env; | 18946 { LocalContext env; |
18937 v8::HandleScope handle_scope(env->GetIsolate()); | 18947 v8::HandleScope handle_scope(env->GetIsolate()); |
18938 CompileRun("var ring = 'One string to test them all';"); | 18948 CompileRun("var ring = 'One string to test them all';"); |
18939 const char* s = "One string to test them all"; | 18949 const char* s = "One string to test them all"; |
18940 TestOneByteResource* inscription = | 18950 TestOneByteResource* inscription = |
18941 new TestOneByteResource(i::StrDup(s), &destroyed); | 18951 new TestOneByteResource(i::StrDup(s), &destroyed); |
18942 v8::Local<v8::String> ring = CompileRun("ring")->ToString(); | 18952 v8::Local<v8::String> ring = CompileRun("ring").As<v8::String>(); |
18943 CHECK(v8::Utils::OpenHandle(*ring)->IsInternalizedString()); | 18953 CHECK(v8::Utils::OpenHandle(*ring)->IsInternalizedString()); |
18944 ring->MakeExternal(inscription); | 18954 ring->MakeExternal(inscription); |
18945 // Ring is still alive. Orcs are roaming freely across our lands. | 18955 // Ring is still alive. Orcs are roaming freely across our lands. |
18946 CHECK_EQ(0, destroyed); | 18956 CHECK_EQ(0, destroyed); |
18947 USE(ring); | 18957 USE(ring); |
18948 } | 18958 } |
18949 | 18959 |
18950 // Garbage collector deals swift blows to evil. | 18960 // Garbage collector deals swift blows to evil. |
18951 CcTest::i_isolate()->compilation_cache()->Clear(); | 18961 CcTest::i_isolate()->compilation_cache()->Clear(); |
18952 CcTest::heap()->CollectAllAvailableGarbage(); | 18962 CcTest::heap()->CollectAllAvailableGarbage(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19071 #endif | 19081 #endif |
19072 } | 19082 } |
19073 } | 19083 } |
19074 } | 19084 } |
19075 | 19085 |
19076 | 19086 |
19077 static void SpaghettiIncident( | 19087 static void SpaghettiIncident( |
19078 const v8::FunctionCallbackInfo<v8::Value>& args) { | 19088 const v8::FunctionCallbackInfo<v8::Value>& args) { |
19079 v8::HandleScope scope(args.GetIsolate()); | 19089 v8::HandleScope scope(args.GetIsolate()); |
19080 v8::TryCatch tc; | 19090 v8::TryCatch tc; |
19081 v8::Handle<v8::String> str(args[0]->ToString()); | 19091 v8::Handle<v8::String> str(args[0]->ToString(args.GetIsolate())); |
19082 USE(str); | 19092 USE(str); |
19083 if (tc.HasCaught()) | 19093 if (tc.HasCaught()) |
19084 tc.ReThrow(); | 19094 tc.ReThrow(); |
19085 } | 19095 } |
19086 | 19096 |
19087 | 19097 |
19088 // Test that an exception can be propagated down through a spaghetti | 19098 // Test that an exception can be propagated down through a spaghetti |
19089 // stack using ReThrow. | 19099 // stack using ReThrow. |
19090 THREADED_TEST(SpaghettiStackReThrow) { | 19100 THREADED_TEST(SpaghettiStackReThrow) { |
19091 v8::Isolate* isolate = CcTest::isolate(); | 19101 v8::Isolate* isolate = CcTest::isolate(); |
(...skipping 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21006 " this.foo = 11;" | 21016 " this.foo = 11;" |
21007 " this.__defineGetter__('baz', function() { return 1; });" | 21017 " this.__defineGetter__('baz', function() { return 1; });" |
21008 "};" | 21018 "};" |
21009 "function Bar() { " | 21019 "function Bar() { " |
21010 " this.bar = 13;" | 21020 " this.bar = 13;" |
21011 " this.__defineGetter__('bla', function() { return 2; });" | 21021 " this.__defineGetter__('bla', function() { return 2; });" |
21012 "};" | 21022 "};" |
21013 "Bar.prototype = new Foo();" | 21023 "Bar.prototype = new Foo();" |
21014 "new Bar();"); | 21024 "new Bar();"); |
21015 CHECK(value->IsObject()); | 21025 CHECK(value->IsObject()); |
21016 Handle<Object> object = value->ToObject(); | 21026 Handle<Object> object = value->ToObject(isolate); |
21017 CHECK(object->Has(v8_str("foo"))); | 21027 CHECK(object->Has(v8_str("foo"))); |
21018 CHECK(!object->HasOwnProperty(v8_str("foo"))); | 21028 CHECK(!object->HasOwnProperty(v8_str("foo"))); |
21019 CHECK(object->HasOwnProperty(v8_str("bar"))); | 21029 CHECK(object->HasOwnProperty(v8_str("bar"))); |
21020 CHECK(object->Has(v8_str("baz"))); | 21030 CHECK(object->Has(v8_str("baz"))); |
21021 CHECK(!object->HasOwnProperty(v8_str("baz"))); | 21031 CHECK(!object->HasOwnProperty(v8_str("baz"))); |
21022 CHECK(object->HasOwnProperty(v8_str("bla"))); | 21032 CHECK(object->HasOwnProperty(v8_str("bla"))); |
21023 } | 21033 } |
21024 { // Check named getter interceptors. | 21034 { // Check named getter interceptors. |
21025 Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 21035 Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
21026 templ->SetNamedPropertyHandler(HasOwnPropertyNamedPropertyGetter); | 21036 templ->SetNamedPropertyHandler(HasOwnPropertyNamedPropertyGetter); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21256 | 21266 |
21257 CHECK_GT(elements, CountLiveMapsInMapCache(CcTest::i_isolate()->context())); | 21267 CHECK_GT(elements, CountLiveMapsInMapCache(CcTest::i_isolate()->context())); |
21258 } | 21268 } |
21259 | 21269 |
21260 | 21270 |
21261 static bool BlockProtoNamedSecurityTestCallback(Local<v8::Object> global, | 21271 static bool BlockProtoNamedSecurityTestCallback(Local<v8::Object> global, |
21262 Local<Value> name, | 21272 Local<Value> name, |
21263 v8::AccessType type, | 21273 v8::AccessType type, |
21264 Local<Value> data) { | 21274 Local<Value> data) { |
21265 // Only block read access to __proto__. | 21275 // Only block read access to __proto__. |
21266 if (type == v8::ACCESS_GET && | 21276 if (type == v8::ACCESS_GET && name->IsString() && |
21267 name->IsString() && | 21277 name.As<v8::String>()->Length() == 9 && |
21268 name->ToString()->Length() == 9 && | 21278 name.As<v8::String>()->Utf8Length() == 9) { |
21269 name->ToString()->Utf8Length() == 9) { | |
21270 char buffer[10]; | 21279 char buffer[10]; |
21271 CHECK_EQ(10, name->ToString()->WriteUtf8(buffer)); | 21280 CHECK_EQ(10, name.As<v8::String>()->WriteUtf8(buffer)); |
21272 return strncmp(buffer, "__proto__", 9) != 0; | 21281 return strncmp(buffer, "__proto__", 9) != 0; |
21273 } | 21282 } |
21274 | 21283 |
21275 return true; | 21284 return true; |
21276 } | 21285 } |
21277 | 21286 |
21278 | 21287 |
21279 THREADED_TEST(Regress93759) { | 21288 THREADED_TEST(Regress93759) { |
21280 v8::Isolate* isolate = CcTest::isolate(); | 21289 v8::Isolate* isolate = CcTest::isolate(); |
21281 HandleScope scope(isolate); | 21290 HandleScope scope(isolate); |
(...skipping 26 matching lines...) Expand all Loading... |
21308 | 21317 |
21309 // Object with explicit security check. | 21318 // Object with explicit security check. |
21310 Local<Object> protected_object = | 21319 Local<Object> protected_object = |
21311 no_proto_template->NewInstance(); | 21320 no_proto_template->NewInstance(); |
21312 | 21321 |
21313 // JSGlobalProxy object, always have security check. | 21322 // JSGlobalProxy object, always have security check. |
21314 Local<Object> proxy_object = | 21323 Local<Object> proxy_object = |
21315 context->Global(); | 21324 context->Global(); |
21316 | 21325 |
21317 // Global object, the prototype of proxy_object. No security checks. | 21326 // Global object, the prototype of proxy_object. No security checks. |
21318 Local<Object> global_object = | 21327 Local<Object> global_object = proxy_object->GetPrototype()->ToObject(isolate); |
21319 proxy_object->GetPrototype()->ToObject(); | |
21320 | 21328 |
21321 // Hidden prototype without security check. | 21329 // Hidden prototype without security check. |
21322 Local<Object> hidden_prototype = | 21330 Local<Object> hidden_prototype = |
21323 hidden_proto_template->GetFunction()->NewInstance(); | 21331 hidden_proto_template->GetFunction()->NewInstance(); |
21324 Local<Object> object_with_hidden = | 21332 Local<Object> object_with_hidden = |
21325 Object::New(isolate); | 21333 Object::New(isolate); |
21326 object_with_hidden->SetPrototype(hidden_prototype); | 21334 object_with_hidden->SetPrototype(hidden_prototype); |
21327 | 21335 |
21328 // Hidden prototype with security check on the hidden prototype. | 21336 // Hidden prototype with security check on the hidden prototype. |
21329 Local<Object> protected_hidden_prototype = | 21337 Local<Object> protected_hidden_prototype = |
(...skipping 23 matching lines...) Expand all Loading... |
21353 CHECK(result2.IsEmpty()); | 21361 CHECK(result2.IsEmpty()); |
21354 | 21362 |
21355 Local<Value> result3 = CompileRun("Object.getPrototypeOf(global)"); | 21363 Local<Value> result3 = CompileRun("Object.getPrototypeOf(global)"); |
21356 CHECK(result3->Equals(global_object->GetPrototype())); | 21364 CHECK(result3->Equals(global_object->GetPrototype())); |
21357 | 21365 |
21358 Local<Value> result4 = CompileRun("Object.getPrototypeOf(proxy)"); | 21366 Local<Value> result4 = CompileRun("Object.getPrototypeOf(proxy)"); |
21359 CHECK(result4.IsEmpty()); | 21367 CHECK(result4.IsEmpty()); |
21360 | 21368 |
21361 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)"); | 21369 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)"); |
21362 CHECK(result5->Equals( | 21370 CHECK(result5->Equals( |
21363 object_with_hidden->GetPrototype()->ToObject()->GetPrototype())); | 21371 object_with_hidden->GetPrototype()->ToObject(isolate)->GetPrototype())); |
21364 | 21372 |
21365 Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)"); | 21373 Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)"); |
21366 CHECK(result6.IsEmpty()); | 21374 CHECK(result6.IsEmpty()); |
21367 } | 21375 } |
21368 | 21376 |
21369 | 21377 |
21370 THREADED_TEST(Regress125988) { | 21378 THREADED_TEST(Regress125988) { |
21371 v8::HandleScope scope(CcTest::isolate()); | 21379 v8::HandleScope scope(CcTest::isolate()); |
21372 Handle<FunctionTemplate> intercept = FunctionTemplate::New(CcTest::isolate()); | 21380 Handle<FunctionTemplate> intercept = FunctionTemplate::New(CcTest::isolate()); |
21373 AddInterceptor(intercept, EmptyInterceptorGetter, EmptyInterceptorSetter); | 21381 AddInterceptor(intercept, EmptyInterceptorGetter, EmptyInterceptorSetter); |
(...skipping 15 matching lines...) Expand all Loading... |
21389 ExpectBoolean("c.hasOwnProperty('y')", false); | 21397 ExpectBoolean("c.hasOwnProperty('y')", false); |
21390 ExpectInt32("c.y", 42); | 21398 ExpectInt32("c.y", 42); |
21391 } | 21399 } |
21392 | 21400 |
21393 | 21401 |
21394 static void TestReceiver(Local<Value> expected_result, | 21402 static void TestReceiver(Local<Value> expected_result, |
21395 Local<Value> expected_receiver, | 21403 Local<Value> expected_receiver, |
21396 const char* code) { | 21404 const char* code) { |
21397 Local<Value> result = CompileRun(code); | 21405 Local<Value> result = CompileRun(code); |
21398 CHECK(result->IsObject()); | 21406 CHECK(result->IsObject()); |
21399 CHECK(expected_receiver->Equals(result->ToObject()->Get(1))); | 21407 CHECK(expected_receiver->Equals(result.As<v8::Object>()->Get(1))); |
21400 CHECK(expected_result->Equals(result->ToObject()->Get(0))); | 21408 CHECK(expected_result->Equals(result.As<v8::Object>()->Get(0))); |
21401 } | 21409 } |
21402 | 21410 |
21403 | 21411 |
21404 THREADED_TEST(ForeignFunctionReceiver) { | 21412 THREADED_TEST(ForeignFunctionReceiver) { |
21405 v8::Isolate* isolate = CcTest::isolate(); | 21413 v8::Isolate* isolate = CcTest::isolate(); |
21406 HandleScope scope(isolate); | 21414 HandleScope scope(isolate); |
21407 | 21415 |
21408 // Create two contexts with different "id" properties ('i' and 'o'). | 21416 // Create two contexts with different "id" properties ('i' and 'o'). |
21409 // Call a function both from its own context and from a the foreign | 21417 // Call a function both from its own context and from a the foreign |
21410 // context, and see what "this" is bound to (returning both "this" | 21418 // context, and see what "this" is bound to (returning both "this" |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21778 isolate->SetAutorunMicrotasks(true); | 21786 isolate->SetAutorunMicrotasks(true); |
21779 } | 21787 } |
21780 | 21788 |
21781 | 21789 |
21782 static void DebugEventInObserver(const v8::Debug::EventDetails& event_details) { | 21790 static void DebugEventInObserver(const v8::Debug::EventDetails& event_details) { |
21783 v8::DebugEvent event = event_details.GetEvent(); | 21791 v8::DebugEvent event = event_details.GetEvent(); |
21784 if (event != v8::Break) return; | 21792 if (event != v8::Break) return; |
21785 Handle<Object> exec_state = event_details.GetExecutionState(); | 21793 Handle<Object> exec_state = event_details.GetExecutionState(); |
21786 Handle<Value> break_id = exec_state->Get(v8_str("break_id")); | 21794 Handle<Value> break_id = exec_state->Get(v8_str("break_id")); |
21787 CompileRun("function f(id) { new FrameDetails(id, 0); }"); | 21795 CompileRun("function f(id) { new FrameDetails(id, 0); }"); |
21788 Handle<Function> fun = Handle<Function>::Cast( | 21796 Handle<Function> fun = |
21789 CcTest::global()->Get(v8_str("f"))->ToObject()); | 21797 Handle<Function>::Cast(CcTest::global()->Get(v8_str("f"))); |
21790 fun->Call(CcTest::global(), 1, &break_id); | 21798 fun->Call(CcTest::global(), 1, &break_id); |
21791 } | 21799 } |
21792 | 21800 |
21793 | 21801 |
21794 TEST(Regress385349) { | 21802 TEST(Regress385349) { |
21795 i::FLAG_allow_natives_syntax = true; | 21803 i::FLAG_allow_natives_syntax = true; |
21796 v8::Isolate* isolate = CcTest::isolate(); | 21804 v8::Isolate* isolate = CcTest::isolate(); |
21797 HandleScope handle_scope(isolate); | 21805 HandleScope handle_scope(isolate); |
21798 isolate->SetAutorunMicrotasks(false); | 21806 isolate->SetAutorunMicrotasks(false); |
21799 Handle<Context> context = Context::New(isolate); | 21807 Handle<Context> context = Context::New(isolate); |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22590 | 22598 |
22591 void CatcherCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { | 22599 void CatcherCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { |
22592 for (int i = 0; i < args.Length(); i++) { | 22600 for (int i = 0; i < args.Length(); i++) { |
22593 i::PrintF("%s\n", *String::Utf8Value(args[i])); | 22601 i::PrintF("%s\n", *String::Utf8Value(args[i])); |
22594 } | 22602 } |
22595 catch_callback_called = true; | 22603 catch_callback_called = true; |
22596 } | 22604 } |
22597 | 22605 |
22598 | 22606 |
22599 void HasOwnPropertyCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { | 22607 void HasOwnPropertyCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { |
22600 args[0]->ToObject()->HasOwnProperty(args[1]->ToString()); | 22608 args[0]->ToObject(args.GetIsolate())->HasOwnProperty( |
| 22609 args[1]->ToString(args.GetIsolate())); |
22601 } | 22610 } |
22602 | 22611 |
22603 | 22612 |
22604 void CheckCorrectThrow(const char* script) { | 22613 void CheckCorrectThrow(const char* script) { |
22605 // Test that the script, when wrapped into a try-catch, triggers the catch | 22614 // Test that the script, when wrapped into a try-catch, triggers the catch |
22606 // clause due to failed access check throwing an exception. | 22615 // clause due to failed access check throwing an exception. |
22607 // The subsequent try-catch should run without any exception. | 22616 // The subsequent try-catch should run without any exception. |
22608 access_check_fail_thrown = false; | 22617 access_check_fail_thrown = false; |
22609 catch_callback_called = false; | 22618 catch_callback_called = false; |
22610 i::ScopedVector<char> source(1024); | 22619 i::ScopedVector<char> source(1024); |
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24244 v8::HandleScope scope(CcTest::isolate()); | 24253 v8::HandleScope scope(CcTest::isolate()); |
24245 RandomLengthOneByteResource* r = | 24254 RandomLengthOneByteResource* r = |
24246 new RandomLengthOneByteResource(i::String::kMaxLength); | 24255 new RandomLengthOneByteResource(i::String::kMaxLength); |
24247 v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), r); | 24256 v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), r); |
24248 CHECK(!str.IsEmpty()); | 24257 CHECK(!str.IsEmpty()); |
24249 v8::TryCatch try_catch; | 24258 v8::TryCatch try_catch; |
24250 v8::Local<v8::String> result = v8::String::Concat(str, str); | 24259 v8::Local<v8::String> result = v8::String::Concat(str, str); |
24251 CHECK(result.IsEmpty()); | 24260 CHECK(result.IsEmpty()); |
24252 CHECK(!try_catch.HasCaught()); | 24261 CHECK(!try_catch.HasCaught()); |
24253 } | 24262 } |
OLD | NEW |