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 8359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8370 "})()"); | 8370 "})()"); |
8371 CHECK(!try_catch.HasCaught()); | 8371 CHECK(!try_catch.HasCaught()); |
8372 CompileRun( | 8372 CompileRun( |
8373 "(function()" | 8373 "(function()" |
8374 " { try { throw ''; } finally { throw 0; }" | 8374 " { try { throw ''; } finally { throw 0; }" |
8375 "})()"); | 8375 "})()"); |
8376 CHECK(try_catch.HasCaught()); | 8376 CHECK(try_catch.HasCaught()); |
8377 } | 8377 } |
8378 | 8378 |
8379 | 8379 |
8380 void CEvaluate(const v8::FunctionCallbackInfo<v8::Value>& args) { | |
8381 v8::HandleScope scope(args.GetIsolate()); | |
8382 CompileRun(args[0]->ToString()); | |
8383 } | |
8384 | |
8385 | |
8386 TEST(TryCatchFinallyStoresMessageUsingTryCatchHandler) { | |
8387 v8::Isolate* isolate = CcTest::isolate(); | |
8388 v8::HandleScope scope(isolate); | |
8389 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | |
8390 templ->Set(v8_str("CEvaluate"), | |
8391 v8::FunctionTemplate::New(isolate, CEvaluate)); | |
8392 LocalContext context(0, templ); | |
8393 v8::TryCatch try_catch; | |
8394 CompileRun("try {" | |
8395 " CEvaluate('throw 1;');" | |
8396 "} finally {" | |
8397 "}"); | |
8398 CHECK(try_catch.HasCaught()); | |
8399 CHECK(!try_catch.Message().IsEmpty()); | |
8400 String::Utf8Value exception_value(try_catch.Exception()); | |
8401 CHECK_EQ(*exception_value, "1"); | |
Michael Starzinger
2014/06/05 11:02:08
Let's call "try_catch.Reset()" here before running
| |
8402 CompileRun("try {" | |
8403 " CEvaluate('throw 1;');" | |
8404 "} finally {" | |
8405 " throw 2;" | |
8406 "}"); | |
8407 CHECK(try_catch.HasCaught()); | |
8408 CHECK(!try_catch.Message().IsEmpty()); | |
8409 String::Utf8Value finally_exception_value(try_catch.Exception()); | |
8410 CHECK_EQ(*finally_exception_value, "2"); | |
8411 } | |
8412 | |
8413 | |
8380 // For use within the TestSecurityHandler() test. | 8414 // For use within the TestSecurityHandler() test. |
8381 static bool g_security_callback_result = false; | 8415 static bool g_security_callback_result = false; |
8382 static bool NamedSecurityTestCallback(Local<v8::Object> global, | 8416 static bool NamedSecurityTestCallback(Local<v8::Object> global, |
8383 Local<Value> name, | 8417 Local<Value> name, |
8384 v8::AccessType type, | 8418 v8::AccessType type, |
8385 Local<Value> data) { | 8419 Local<Value> data) { |
8386 printf("a\n"); | 8420 printf("a\n"); |
8387 // Always allow read access. | 8421 // Always allow read access. |
8388 if (type == v8::ACCESS_GET) | 8422 if (type == v8::ACCESS_GET) |
8389 return true; | 8423 return true; |
(...skipping 14096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
22486 v8::internal::FLAG_stack_size = 150; | 22520 v8::internal::FLAG_stack_size = 150; |
22487 LocalContext current; | 22521 LocalContext current; |
22488 v8::Isolate* isolate = current->GetIsolate(); | 22522 v8::Isolate* isolate = current->GetIsolate(); |
22489 v8::HandleScope scope(isolate); | 22523 v8::HandleScope scope(isolate); |
22490 V8::SetCaptureStackTraceForUncaughtExceptions( | 22524 V8::SetCaptureStackTraceForUncaughtExceptions( |
22491 true, 10, v8::StackTrace::kDetailed); | 22525 true, 10, v8::StackTrace::kDetailed); |
22492 v8::TryCatch try_catch; | 22526 v8::TryCatch try_catch; |
22493 CompileRun("(function f(x) { f(x+1); })(0)"); | 22527 CompileRun("(function f(x) { f(x+1); })(0)"); |
22494 CHECK(try_catch.HasCaught()); | 22528 CHECK(try_catch.HasCaught()); |
22495 } | 22529 } |
OLD | NEW |