diff --git a/tooling/dynamic/agent/debugger_impl.cpp b/tooling/dynamic/agent/debugger_impl.cpp index dc691ef07729f950a9c115da777a38c54d044836..c0a9be8d0557dbfa49e31c6db28bf848d5ed5637 100755 --- a/tooling/dynamic/agent/debugger_impl.cpp +++ b/tooling/dynamic/agent/debugger_impl.cpp @@ -1003,6 +1003,7 @@ DispatchResponse DebuggerImpl::DispatcherImpl::DropFrame(const DispatchRequest & // inner message, not SendResponse to outer void DebuggerImpl::DispatcherImpl::ClientDisconnect([[maybe_unused]] const DispatchRequest &request) { + debugger_->Disable(); debugger_->ClientDisconnect(); } diff --git a/tooling/dynamic/test/debugger_impl_test.cpp b/tooling/dynamic/test/debugger_impl_test.cpp index b9ca3db279fe508a6088d3bc46e9146393d9e823..946732853976b679410487f30352b323a29a66bb 100644 --- a/tooling/dynamic/test/debugger_impl_test.cpp +++ b/tooling/dynamic/test/debugger_impl_test.cpp @@ -1764,6 +1764,33 @@ HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_ClientDisconnect) } } +HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_ClientDisconnect_02) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + auto dispatcherImpl = std::make_unique(protocolChannel, std::move(debuggerImpl)); + ecmaVm->GetJsDebuggerManager()->SetDebugMode(true); + std::string msg = std::string() + + R"({ + "id":0, + "method":"Debugger.clientDisconnect", + "params":{} + })"; + DispatchRequest request(msg); + + dispatcherImpl->Dispatch(request); + EXPECT_FALSE(ecmaVm->GetJsDebuggerManager()->IsDebugMode()); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_CallFunctionOn__001) { std::string outStrForCallbackCheck = "";