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

Side by Side 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: Update according to code review Created 5 years, 2 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
« src/isolate.cc ('K') | « test/cctest/cctest.gyp ('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
(Empty)
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/v8.h"
6
7 #include "test/cctest/cctest.h"
8
9 const char* BOOM_FUNC = "function boom() { throw new Error(\"boom\") }";
10
11 TEST(AbortOnUncaughtExceptionDefault) {
12 v8::Isolate* isolate = CcTest::isolate();
13 v8::HandleScope handle_scope(isolate);
14 v8::Handle<v8::ObjectTemplate> global_template =
15 v8::ObjectTemplate::New(isolate);
16 LocalContext env(NULL, global_template);
17
18 i::FLAG_abort_on_uncaught_exception = true;
19 CompileRun(BOOM_FUNC);
20
21 v8::Local<v8::Object> global_object = env->Global();
22 v8::Local<v8::Function> foo =
23 v8::Local<v8::Function>::Cast(global_object->Get(v8_str("boom")));
24
25 USE(foo);
26 /*
27 Ideally, I'd like to use EXPECT_EXIT like following:
28
29 EXPECT_EXIT(foo->Call(global_object, 0, NULL);,
Michael Starzinger 2015/10/05 16:13:57 There isn't really a way I can think of to model t
julien.gilli 2015/10/05 17:24:25 Done.
30 ::testing::KilledBySignal(SIGKILL),
31 "throwing and using --abort-on-uncaught-exception should cause process "
32 "to abort");
33 */
34 }
35
36
37 bool NoAbortOnUncaughtException(v8::Isolate* isolate) { return false; }
Michael Starzinger 2015/10/05 16:18:39 Also, we could check that this callback was actual
julien.gilli 2015/10/05 17:24:25 Done.
38
39
40 TEST(AbortOnUncaughtExceptionUncaughtExceptionCallbackNoAbort) {
Michael Starzinger 2015/10/05 16:13:57 If we are left with only one test case, then I sug
julien.gilli 2015/10/05 17:24:25 Done.
41 v8::Isolate* isolate = CcTest::isolate();
42 v8::HandleScope handle_scope(isolate);
43 v8::Handle<v8::ObjectTemplate> global_template =
44 v8::ObjectTemplate::New(isolate);
45 LocalContext env(NULL, global_template);
46
47 i::FLAG_abort_on_uncaught_exception = true;
48 isolate->SetAbortOnUncaughtExceptionCallback(NoAbortOnUncaughtException);
49
50 CompileRun(BOOM_FUNC);
51
52 v8::Local<v8::Object> global_object = env->Global();
53 v8::Local<v8::Function> foo =
54 v8::Local<v8::Function>::Cast(global_object->Get(v8_str("boom")));
55
56 foo->Call(global_object, 0, NULL);
57 }
OLDNEW
« src/isolate.cc ('K') | « test/cctest/cctest.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698