Index: test/inspector/inspector-test.cc |
diff --git a/test/inspector/inspector-test.cc b/test/inspector/inspector-test.cc |
index 841be28f043fcf6fbc60f04830896c1c332aa215..b3dbcb4f52a9cd05733236a0f83dffa46a742f0f 100644 |
--- a/test/inspector/inspector-test.cc |
+++ b/test/inspector/inspector-test.cc |
@@ -335,7 +335,8 @@ class InspectorExtension : public v8::Extension { |
"native function detachInspector();" |
"native function setMaxAsyncTaskStacks();" |
"native function breakProgram();" |
- "native function createObjectWithStrictCheck();") {} |
+ "native function createObjectWithStrictCheck();" |
+ "native function callWithScheduledBreak();") {} |
virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( |
v8::Isolate* isolate, v8::Local<v8::String> name) { |
@@ -373,6 +374,13 @@ class InspectorExtension : public v8::Extension { |
.FromJust()) { |
return v8::FunctionTemplate::New( |
isolate, InspectorExtension::CreateObjectWithStrictCheck); |
+ } else if (name->Equals(context, v8::String::NewFromUtf8( |
+ isolate, "callWithScheduledBreak", |
+ v8::NewStringType::kNormal) |
+ .ToLocalChecked()) |
+ .FromJust()) { |
+ return v8::FunctionTemplate::New( |
+ isolate, InspectorExtension::CallWithScheduledBreak); |
} |
return v8::Local<v8::FunctionTemplate>(); |
} |
@@ -447,6 +455,30 @@ class InspectorExtension : public v8::Extension { |
templ->NewInstance(args.GetIsolate()->GetCurrentContext()) |
.ToLocalChecked()); |
} |
+ |
+ static void CallWithScheduledBreak( |
+ const v8::FunctionCallbackInfo<v8::Value>& args) { |
+ if (args.Length() != 3 || !args[0]->IsFunction() || !args[1]->IsString() || |
+ !args[2]->IsString()) { |
+ fprintf(stderr, "Internal error: breakProgram('reason', 'details')."); |
+ Exit(); |
+ } |
+ v8_inspector::V8InspectorSession* session = |
+ InspectorClientImpl::SessionFromContext( |
+ args.GetIsolate()->GetCurrentContext()); |
+ CHECK(session); |
+ |
+ v8::internal::Vector<uint16_t> reason = ToVector(args[1].As<v8::String>()); |
+ v8_inspector::StringView reason_view(reason.start(), reason.length()); |
+ v8::internal::Vector<uint16_t> details = ToVector(args[2].As<v8::String>()); |
+ v8_inspector::StringView details_view(details.start(), details.length()); |
+ session->schedulePauseOnNextStatement(reason_view, details_view); |
+ v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); |
+ v8::MaybeLocal<v8::Value> result; |
+ result = args[0].As<v8::Function>()->Call(context, context->Global(), 0, |
+ nullptr); |
+ session->cancelPauseOnNextStatement(); |
+ } |
}; |
v8::Local<v8::String> ToString(v8::Isolate* isolate, |