Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 } | |
| OLD | NEW |