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

Unified Diff: test/cctest/test-abort-on-uncaught-exception.cc

Issue 1375933003: Add SetAbortOnUncaughtExceptionCallback API (Closed) Base URL: git@github.com:v8/v8.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« test/cctest/cctest.gyp ('K') | « test/cctest/cctest.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-abort-on-uncaught-exception.cc
diff --git a/test/cctest/test-abort-on-uncaught-exception.cc b/test/cctest/test-abort-on-uncaught-exception.cc
new file mode 100644
index 0000000000000000000000000000000000000000..84c0a18f9152e040c551006550ce39f854052e23
--- /dev/null
+++ b/test/cctest/test-abort-on-uncaught-exception.cc
@@ -0,0 +1,57 @@
+// Copyright 2013 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/v8.h"
+
+#include "test/cctest/cctest.h"
+
+const char* BOOM_FUNC = "function boom() { throw new Error(\"boom\") }";
+
+TEST(AbortOnUncaughtExceptionDefault) {
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope handle_scope(isolate);
+ v8::Handle<v8::ObjectTemplate> global_template =
+ v8::ObjectTemplate::New(isolate);
+ LocalContext env(NULL, global_template);
+
+ i::FLAG_abort_on_uncaught_exception = true;
+ CompileRun(BOOM_FUNC);
+
+ v8::Local<v8::Object> global_object = env->Global();
+ v8::Local<v8::Function> foo =
+ v8::Local<v8::Function>::Cast(global_object->Get(v8_str("boom")));
+
+ USE(foo);
+ /*
+ Ideally, I'd like to use EXPECT_EXIT like following:
+
+ EXPECT_EXIT(foo->Call(global_object, 0, NULL);,
+ ::testing::KilledBySignal(SIGKILL),
+ "throwing and using --abort-on-uncaught-exception should cause process "
+ "to abort");
+ */
+}
+
+
+bool NoAbortOnUncaughtException(v8::Isolate* isolate) { return false; }
+
+
+TEST(AbortOnUncaughtExceptionUncaughtExceptionCallbackNoAbort) {
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope handle_scope(isolate);
+ v8::Handle<v8::ObjectTemplate> global_template =
+ v8::ObjectTemplate::New(isolate);
+ LocalContext env(NULL, global_template);
+
+ i::FLAG_abort_on_uncaught_exception = true;
+ isolate->SetAbortOnUncaughtExceptionCallback(NoAbortOnUncaughtException);
+
+ CompileRun(BOOM_FUNC);
+
+ v8::Local<v8::Object> global_object = env->Global();
+ v8::Local<v8::Function> foo =
+ v8::Local<v8::Function>::Cast(global_object->Get(v8_str("boom")));
+
+ foo->Call(global_object, 0, NULL);
+}
« test/cctest/cctest.gyp ('K') | « test/cctest/cctest.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698