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

Unified Diff: test/cctest/test-api.cc

Issue 12901: Reporting uncaught errors at the boundary between C++ and JS instead of tryin... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years 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 side-by-side diff with in-line comments
Download patch
« src/top.cc ('K') | « src/top.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
===================================================================
--- test/cctest/test-api.cc (revision 904)
+++ test/cctest/test-api.cc (working copy)
@@ -2960,6 +2960,7 @@
// Counts uncaught exceptions, but other tests running in parallel
// also have uncaught exceptions.
TEST(ApiUncaughtException) {
+ report_count = 0;
v8::HandleScope scope;
LocalContext env;
v8::V8::AddMessageListener(ApiUncaughtExceptionTestListener);
@@ -2983,9 +2984,43 @@
CHECK(trouble_caller->IsFunction());
Function::Cast(*trouble_caller)->Call(global, 0, NULL);
CHECK_EQ(1, report_count);
+ v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener);
}
+TEST(TryCatchFinallyUsingMessaging) {
Søren Thygesen Gjesse 2008/12/04 07:53:53 I suggest to change this test into one or more mes
olehougaard 2008/12/04 08:44:35 Fixed.
+ report_count = 0;
+ v8::HandleScope scope;
+ LocalContext env;
+ v8::V8::AddMessageListener(ApiUncaughtExceptionTestListener);
+ Script::Compile(v8_str("try { throw ''; } catch (e) {}"))->Run();
+ CHECK_EQ(0, report_count);
+ Script::Compile(v8_str("try { throw ''; } finally {}"))->Run();
+ CHECK_EQ(1, report_count);
+ Script::Compile(v8_str("(function() { try { throw ''; } finally { return; } })()"))->Run();
Mads Ager (chromium) 2008/12/03 15:44:48 These two lines seem too long? Break them by usin
olehougaard 2008/12/04 08:44:35 Fixed
+ CHECK_EQ(1, report_count);
+ Script::Compile(v8_str("(function() { try { throw ''; } finally { throw 0; } })()"))->Run();
+ CHECK_EQ(2, report_count);
+ v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener);
+}
+
+
+TEST(TryCatchFinallyUsingTryCatchHandler) {
+ v8::HandleScope scope;
+ LocalContext env;
+ v8::TryCatch try_catch;
+ Script::Compile(v8_str("try { throw ''; } catch (e) {}"))->Run();
+ CHECK(!try_catch.HasCaught());
+ Script::Compile(v8_str("try { throw ''; } finally {}"))->Run();
+ CHECK(try_catch.HasCaught());
+ try_catch.Reset();
+ Script::Compile(v8_str("(function() { try { throw ''; } finally { return; } })()"))->Run();
+ CHECK(!try_catch.HasCaught());
+ Script::Compile(v8_str("(function() { try { throw ''; } finally { throw 0; } })()"))->Run();
+ CHECK(try_catch.HasCaught());
+}
+
+
// SecurityHandler can't be run twice
TEST(SecurityHandler) {
v8::HandleScope scope0;
« src/top.cc ('K') | « src/top.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698