CompileRun(source);
}
+ threaded_debugging_barriers.barrier_4.Wait();
isolate_->Dispose();
}
threaded_debugging_barriers.barrier_2.Wait();
v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_1, buffer));
v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_2, buffer));
+ threaded_debugging_barriers.barrier_4.Wait();
}
breakpoints_barriers->barrier_2.Wait();
CompileRun(source_2);
}
+ breakpoints_barriers->barrier_4.Wait();
isolate_->Dispose();
}
CHECK_EQ(116, evaluate_int_result);
// 9: Continue evaluation of source2, reach end.
v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_8, buffer));
+ breakpoints_barriers->barrier_4.Wait();
}
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);
+}