| Index: test/cctest/test-debug.cc | 
| diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc | 
| index 2f0674a34d98b94c6183ad10ed7ed4347c4c02ff..adf9ba99b2db880d32d7104c081ca580dbc35abd 100644 | 
| --- a/test/cctest/test-debug.cc | 
| +++ b/test/cctest/test-debug.cc | 
| @@ -7518,3 +7518,75 @@ TEST(DebugBreakOffThreadTerminate) { | 
| CompileRun("while (true);"); | 
| CHECK(try_catch.HasTerminated()); | 
| } | 
| + | 
| + | 
| +static void DebugEventExpectNoException( | 
| +    const v8::Debug::EventDetails& event_details) { | 
| +  v8::DebugEvent event = event_details.GetEvent(); | 
| +  CHECK_NE(v8::Exception, event); | 
| +} | 
| + | 
| + | 
| +static void TryCatchWrappedThrowCallback( | 
| +    const v8::FunctionCallbackInfo<v8::Value>& args) { | 
| +  v8::TryCatch try_catch; | 
| +  CompileRun("throw 'rejection';"); | 
| +  CHECK(try_catch.HasCaught()); | 
| +} | 
| + | 
| + | 
| +TEST(DebugPromiseInterceptedByTryCatch) { | 
| +  DebugLocalContext env; | 
| +  v8::Isolate* isolate = env->GetIsolate(); | 
| +  v8::HandleScope scope(isolate); | 
| +  v8::Debug::SetDebugEventListener(&DebugEventExpectNoException); | 
| +  ChangeBreakOnException(false, true); | 
| + | 
| +  v8::Handle<v8::FunctionTemplate> fun = | 
| +      v8::FunctionTemplate::New(isolate, TryCatchWrappedThrowCallback); | 
| +  env->Global()->Set(v8_str("fun"), fun->GetFunction()); | 
| + | 
| +  CompileRun("var p = new Promise(function(res, rej) { fun(); res(); });"); | 
| +  CompileRun( | 
| +      "var r;" | 
| +      "p.chain(function() { r = 'resolved'; }," | 
| +      "        function() { r = 'rejected'; });"); | 
| +  CHECK(CompileRun("r")->Equals(v8_str("resolved"))); | 
| +} | 
| + | 
| + | 
| +static int exception_event_counter = 0; | 
| + | 
| + | 
| +static void DebugEventCountException( | 
| +    const v8::Debug::EventDetails& event_details) { | 
| +  v8::DebugEvent event = event_details.GetEvent(); | 
| +  if (event == v8::Exception) exception_event_counter++; | 
| +} | 
| + | 
| + | 
| +static void ThrowCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { | 
| +  CompileRun("throw 'rejection';"); | 
| +} | 
| + | 
| + | 
| +TEST(DebugPromiseRejectedByCallback) { | 
| +  DebugLocalContext env; | 
| +  v8::Isolate* isolate = env->GetIsolate(); | 
| +  v8::HandleScope scope(isolate); | 
| +  v8::Debug::SetDebugEventListener(&DebugEventCountException); | 
| +  ChangeBreakOnException(false, true); | 
| +  exception_event_counter = 0; | 
| + | 
| +  v8::Handle<v8::FunctionTemplate> fun = | 
| +      v8::FunctionTemplate::New(isolate, ThrowCallback); | 
| +  env->Global()->Set(v8_str("fun"), fun->GetFunction()); | 
| + | 
| +  CompileRun("var p = new Promise(function(res, rej) { fun(); res(); });"); | 
| +  CompileRun( | 
| +      "var r;" | 
| +      "p.chain(function() { r = 'resolved'; }," | 
| +      "        function(e) { r = 'rejected' + e; });"); | 
| +  CHECK(CompileRun("r")->Equals(v8_str("rejectedrejection"))); | 
| +  CHECK_EQ(1, exception_event_counter); | 
| +} | 
|  |