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 4482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4493 v8::V8::Initialize(); | 4493 v8::V8::Initialize(); |
4494 LocalContext context; | 4494 LocalContext context; |
4495 v8::HandleScope scope(context->GetIsolate()); | 4495 v8::HandleScope scope(context->GetIsolate()); |
4496 v8::TryCatch try_catch; | 4496 v8::TryCatch try_catch; |
4497 TryCatchNestedHelper(5); | 4497 TryCatchNestedHelper(5); |
4498 CHECK(try_catch.HasCaught()); | 4498 CHECK(try_catch.HasCaught()); |
4499 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(try_catch.Exception()), "back")); | 4499 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(try_catch.Exception()), "back")); |
4500 } | 4500 } |
4501 | 4501 |
4502 | 4502 |
| 4503 void TryCatchMixedNestingCheck(v8::TryCatch* try_catch) { |
| 4504 CHECK(try_catch->HasCaught()); |
| 4505 Handle<Message> message = try_catch->Message(); |
| 4506 Handle<Value> resource = message->GetScriptResourceName(); |
| 4507 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(resource), "inner")); |
| 4508 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(message->Get()), |
| 4509 "Uncaught Error: a")); |
| 4510 CHECK_EQ(1, message->GetLineNumber()); |
| 4511 CHECK_EQ(6, message->GetStartColumn()); |
| 4512 } |
| 4513 |
| 4514 |
| 4515 void TryCatchMixedNestingHelper( |
| 4516 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4517 ApiTestFuzzer::Fuzz(); |
| 4518 v8::TryCatch try_catch; |
| 4519 CompileRunWithOrigin("throw new Error('a');\n", "inner", 0, 0); |
| 4520 CHECK(try_catch.HasCaught()); |
| 4521 TryCatchMixedNestingCheck(&try_catch); |
| 4522 try_catch.ReThrow(); |
| 4523 } |
| 4524 |
| 4525 |
| 4526 // This test ensures that an outer TryCatch in the following situation: |
| 4527 // C++/TryCatch -> JS -> C++/TryCatch -> JS w/ SyntaxError |
| 4528 // does not clobber the Message object generated for the inner TryCatch. |
| 4529 // This exercises the ability of TryCatch.ReThrow() to restore the |
| 4530 // inner pending Message before throwing the exception again. |
| 4531 TEST(TryCatchMixedNesting) { |
| 4532 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 4533 v8::V8::Initialize(); |
| 4534 v8::TryCatch try_catch; |
| 4535 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4536 templ->Set(v8_str("TryCatchMixedNestingHelper"), |
| 4537 v8::FunctionTemplate::New(TryCatchMixedNestingHelper)); |
| 4538 LocalContext context(0, templ); |
| 4539 CompileRunWithOrigin("TryCatchMixedNestingHelper();\n", "outer", 1, 1); |
| 4540 TryCatchMixedNestingCheck(&try_catch); |
| 4541 } |
| 4542 |
| 4543 |
4503 THREADED_TEST(Equality) { | 4544 THREADED_TEST(Equality) { |
4504 LocalContext context; | 4545 LocalContext context; |
4505 v8::Isolate* isolate = context->GetIsolate(); | 4546 v8::Isolate* isolate = context->GetIsolate(); |
4506 v8::HandleScope scope(context->GetIsolate()); | 4547 v8::HandleScope scope(context->GetIsolate()); |
4507 // Check that equality works at all before relying on CHECK_EQ | 4548 // Check that equality works at all before relying on CHECK_EQ |
4508 CHECK(v8_str("a")->Equals(v8_str("a"))); | 4549 CHECK(v8_str("a")->Equals(v8_str("a"))); |
4509 CHECK(!v8_str("a")->Equals(v8_str("b"))); | 4550 CHECK(!v8_str("a")->Equals(v8_str("b"))); |
4510 | 4551 |
4511 CHECK_EQ(v8_str("a"), v8_str("a")); | 4552 CHECK_EQ(v8_str("a"), v8_str("a")); |
4512 CHECK_NE(v8_str("a"), v8_str("b")); | 4553 CHECK_NE(v8_str("a"), v8_str("b")); |
(...skipping 14835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19348 i::Semaphore* sem_; | 19389 i::Semaphore* sem_; |
19349 volatile int sem_value_; | 19390 volatile int sem_value_; |
19350 }; | 19391 }; |
19351 | 19392 |
19352 | 19393 |
19353 THREADED_TEST(SemaphoreInterruption) { | 19394 THREADED_TEST(SemaphoreInterruption) { |
19354 ThreadInterruptTest().RunTest(); | 19395 ThreadInterruptTest().RunTest(); |
19355 } | 19396 } |
19356 | 19397 |
19357 #endif // WIN32 | 19398 #endif // WIN32 |
OLD | NEW |