Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksei Koziatinskii <ak239spb@gmail.com>2019-06-26 01:28:56 +0300
committerRich Trott <rtrott@gmail.com>2019-07-21 08:19:06 +0300
commitf02dfdb2b5e266a057eda1e07eafc62b55f468d3 (patch)
treed1fc208e5dc31744f56ba566d0720ad52c6c35fd /src/inspector_js_api.cc
parentb30dca8d9efcff9d7650e633c20c93ace5e52f36 (diff)
inspector: add inspector.waitForDebugger()
This method blocks current node process until a client sends Runtime.runifWaitingForDebugger. It can be useful when we need to report inspector.url() before waiting for connection: ``` inspector.open(0, undefined, false); fs.writeFileSync(someFileName, inspector.url()); inspector.waitForDebugger(); ``` PR-URL: https://github.com/nodejs/node/pull/28453 Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/inspector_js_api.cc')
-rw-r--r--src/inspector_js_api.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc
index 3131c6ad373..8b891a2d611 100644
--- a/src/inspector_js_api.cc
+++ b/src/inspector_js_api.cc
@@ -237,7 +237,6 @@ void IsEnabled(const FunctionCallbackInfo<Value>& args) {
void Open(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Agent* agent = env->inspector_agent();
- bool wait_for_connect = false;
if (args.Length() > 0 && args[0]->IsUint32()) {
uint32_t port = args[0].As<Uint32>()->Value();
@@ -249,12 +248,15 @@ void Open(const FunctionCallbackInfo<Value>& args) {
agent->host_port()->set_host(*host);
}
- if (args.Length() > 2 && args[2]->IsBoolean()) {
- wait_for_connect = args[2]->BooleanValue(args.GetIsolate());
- }
agent->StartIoThread();
- if (wait_for_connect)
+}
+
+void WaitForDebugger(const FunctionCallbackInfo<Value>& args) {
+ Environment* env = Environment::GetCurrent(args);
+ Agent* agent = env->inspector_agent();
+ if (agent->IsActive())
agent->WaitForConnect();
+ args.GetReturnValue().Set(agent->IsActive());
}
void Url(const FunctionCallbackInfo<Value>& args) {
@@ -285,6 +287,7 @@ void Initialize(Local<Object> target, Local<Value> unused,
env->SetMethod(target, "callAndPauseOnStart", CallAndPauseOnStart);
env->SetMethod(target, "open", Open);
env->SetMethodNoSideEffect(target, "url", Url);
+ env->SetMethod(target, "waitForDebugger", WaitForDebugger);
env->SetMethod(target, "asyncTaskScheduled", AsyncTaskScheduledWrapper);
env->SetMethod(target, "asyncTaskCanceled",