Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: test/cctest/test-api.cc

Issue 306463002: Don't clear exception pending message if we have externally TryCatch and finally on top of stack. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/isolate.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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");
8402 try_catch.Reset();
8403 CompileRun("try {"
8404 " CEvaluate('throw 1;');"
8405 "} finally {"
8406 " throw 2;"
8407 "}");
8408 CHECK(try_catch.HasCaught());
8409 CHECK(!try_catch.Message().IsEmpty());
8410 String::Utf8Value finally_exception_value(try_catch.Exception());
8411 CHECK_EQ(*finally_exception_value, "2");
8412 }
8413
8414
8380 // For use within the TestSecurityHandler() test. 8415 // For use within the TestSecurityHandler() test.
8381 static bool g_security_callback_result = false; 8416 static bool g_security_callback_result = false;
8382 static bool NamedSecurityTestCallback(Local<v8::Object> global, 8417 static bool NamedSecurityTestCallback(Local<v8::Object> global,
8383 Local<Value> name, 8418 Local<Value> name,
8384 v8::AccessType type, 8419 v8::AccessType type,
8385 Local<Value> data) { 8420 Local<Value> data) {
8386 printf("a\n"); 8421 printf("a\n");
8387 // Always allow read access. 8422 // Always allow read access.
8388 if (type == v8::ACCESS_GET) 8423 if (type == v8::ACCESS_GET)
8389 return true; 8424 return true;
(...skipping 14096 matching lines...) Expand 10 before | Expand all | Expand 10 after
22486 v8::internal::FLAG_stack_size = 150; 22521 v8::internal::FLAG_stack_size = 150;
22487 LocalContext current; 22522 LocalContext current;
22488 v8::Isolate* isolate = current->GetIsolate(); 22523 v8::Isolate* isolate = current->GetIsolate();
22489 v8::HandleScope scope(isolate); 22524 v8::HandleScope scope(isolate);
22490 V8::SetCaptureStackTraceForUncaughtExceptions( 22525 V8::SetCaptureStackTraceForUncaughtExceptions(
22491 true, 10, v8::StackTrace::kDetailed); 22526 true, 10, v8::StackTrace::kDetailed);
22492 v8::TryCatch try_catch; 22527 v8::TryCatch try_catch;
22493 CompileRun("(function f(x) { f(x+1); })(0)"); 22528 CompileRun("(function f(x) { f(x+1); })(0)");
22494 CHECK(try_catch.HasCaught()); 22529 CHECK(try_catch.HasCaught());
22495 } 22530 }
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698