diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index decd9f748a2775..b7c4a39126a776 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -945,6 +945,10 @@ bool Agent::IsActive() { return io_ != nullptr || client_->IsActive(); } +bool Agent::HasInspectorThread() { + return io_ != nullptr; +} + void Agent::SetParentHandle( std::unique_ptr parent_handle) { parent_handle_ = std::move(parent_handle); diff --git a/src/inspector_agent.h b/src/inspector_agent.h index 744e139df8f87a..825dd31080b038 100644 --- a/src/inspector_agent.h +++ b/src/inspector_agent.h @@ -59,6 +59,8 @@ class Agent { // --inspect command line flag) or if inspector JS API had been used. bool IsActive(); + bool HasInspectorThread(); + // Blocks till frontend connects and sends "runIfWaitingForDebugger" void WaitForConnect(); // Blocks till all the sessions with "WaitForDisconnectOnShutdown" disconnect diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc index 3595536c785ed7..99d737599f92f0 100644 --- a/src/inspector_js_api.cc +++ b/src/inspector_js_api.cc @@ -273,7 +273,7 @@ static void RegisterAsyncHookWrapper(const FunctionCallbackInfo& args) { void IsEnabled(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - args.GetReturnValue().Set(InspectorEnabled(env)); + args.GetReturnValue().Set(env->inspector_agent()->HasInspectorThread()); } void Open(const FunctionCallbackInfo& args) { diff --git a/test/sequential/test-inspector-open-with-session.js b/test/sequential/test-inspector-open-with-session.js new file mode 100644 index 00000000000000..83760e3c4e6d13 --- /dev/null +++ b/test/sequential/test-inspector-open-with-session.js @@ -0,0 +1,13 @@ +'use strict'; + +const common = require('../common'); +common.skipIfInspectorDisabled(); + +const { open, url } = require("inspector"); +const { Session } = require('inspector'); +const assert = require('assert'); +const session = new Session(); +session.connect(); + +open(); +assert.ok(url() !== undefined);