diff --git a/test/inspector/debugger/session-stop-expected.txt b/test/inspector/debugger/session-stop-expected.txt index 344f214707..9896c36f38 100644 --- a/test/inspector/debugger/session-stop-expected.txt +++ b/test/inspector/debugger/session-stop-expected.txt @@ -13,3 +13,8 @@ Pause error(?): Debugger agent is not enabled Running test: testSessionStopDisallowsReenabling Pause error(?) after stop: Debugger agent is not enabled Pause error(?) after re-enable: Debugger agent is not enabled + +Running test: testSessionStopDoesNotDisableOtherSessions +Session 1 pause error after stop: Debugger agent is not enabled +Session 2 paused: other +Session 2 evaluation: 42 \ No newline at end of file diff --git a/test/inspector/debugger/session-stop.js b/test/inspector/debugger/session-stop.js index 540e85f026..5c667ee93d 100644 --- a/test/inspector/debugger/session-stop.js +++ b/test/inspector/debugger/session-stop.js @@ -13,7 +13,7 @@ InspectorTest.runAsyncTestSuite([ Protocol.Debugger.enable(); await Protocol.Debugger.pause(); const result = Protocol.Runtime.evaluate({expression: '42'}); - contextGroup.stop(); + session.stop(); InspectorTest.log( `Evaluation returned: ${(await result).result.result.value}`); }, @@ -28,7 +28,7 @@ InspectorTest.runAsyncTestSuite([ const paused = Protocol.Debugger.oncePaused(); const result = Protocol.Runtime.evaluate({expression: '42'}); InspectorTest.log(`Paused: ${(await paused).params.reason}`); - contextGroup.stop(); + session.stop(); InspectorTest.log( `Evaluation returned: ${(await result).result.result.value}`); }, @@ -38,7 +38,7 @@ InspectorTest.runAsyncTestSuite([ let Protocol = session.Protocol; await Protocol.Debugger.enable(); - contextGroup.stop(); + session.stop(); const pauseResult = await Protocol.Debugger.pause(); InspectorTest.log(`Pause error(?): ${pauseResult?.error?.message}`); }, @@ -48,7 +48,7 @@ InspectorTest.runAsyncTestSuite([ let Protocol = session.Protocol; await Protocol.Debugger.enable(); - contextGroup.stop(); + session.stop(); const pauseResultAfterStop = await Protocol.Debugger.pause(); InspectorTest.log( `Pause error(?) after stop: ${pauseResultAfterStop?.error?.message}`); @@ -56,5 +56,31 @@ InspectorTest.runAsyncTestSuite([ const pauseResult = await Protocol.Debugger.pause(); InspectorTest.log( `Pause error(?) after re-enable: ${pauseResult?.error?.message}`); - } + }, + async function testSessionStopDoesNotDisableOtherSessions() { + let contextGroup = new InspectorTest.ContextGroup(); + + let session1 = contextGroup.connect(); + let Protocol1 = session1.Protocol; + await Protocol1.Debugger.enable(); + + let session2 = contextGroup.connect(); + let Protocol2 = session2.Protocol; + await Protocol2.Debugger.enable(); + + session1.stop(); + const pauseResult1 = await Protocol1.Debugger.pause(); + InspectorTest.log( + `Session 1 pause error after stop: ${pauseResult1?.error?.message}`); + + await Protocol2.Debugger.pause(); + + const paused = Protocol2.Debugger.oncePaused(); + const result = Protocol2.Runtime.evaluate({expression: '42'}); + InspectorTest.log(`Session 2 paused: ${(await paused).params.reason}`); + await Protocol2.Debugger.resume(); + + InspectorTest.log( + `Session 2 evaluation: ${(await result).result.result.value}`); + }, ]); diff --git a/test/inspector/inspector-test.cc b/test/inspector/inspector-test.cc index 37e1ca6846..dfc50b2522 100644 --- a/test/inspector/inspector-test.cc +++ b/test/inspector/inspector-test.cc @@ -279,13 +279,12 @@ class UtilsExtension : public InspectorIsolateData::SetupGlobalTask { static void Stop(const v8::FunctionCallbackInfo& args) { if (args.Length() != 1 || !args[0]->IsInt32()) { - FATAL("Internal error: stop(context_group_id)."); + FATAL("Internal error: stop(session_id)."); } - int context_group_id = args[0].As()->Value(); - RunSyncTask(backend_runner_, - [&context_group_id](InspectorIsolateData* data) { - data->Stop(context_group_id); - }); + int session_id = args[0].As()->Value(); + RunSyncTask(backend_runner_, [&session_id](InspectorIsolateData* data) { + data->Stop(session_id); + }); } static void SetLogConsoleApiMessageCalls( diff --git a/test/inspector/isolate-data.cc b/test/inspector/isolate-data.cc index 9c09eccac8..d945106318 100644 --- a/test/inspector/isolate-data.cc +++ b/test/inspector/isolate-data.cc @@ -201,12 +201,10 @@ void InspectorIsolateData::BreakProgram( } } -void InspectorIsolateData::Stop(int context_group_id) { +void InspectorIsolateData::Stop(int session_id) { v8::SealHandleScope seal_handle_scope(isolate()); - for (int session_id : GetSessionIds(context_group_id)) { - auto it = sessions_.find(session_id); - if (it != sessions_.end()) it->second->stop(); - } + auto it = sessions_.find(session_id); + if (it != sessions_.end()) it->second->stop(); } void InspectorIsolateData::SchedulePauseOnNextStatement( diff --git a/test/inspector/isolate-data.h b/test/inspector/isolate-data.h index ff87581396..7a953e6b3f 100644 --- a/test/inspector/isolate-data.h +++ b/test/inspector/isolate-data.h @@ -78,7 +78,7 @@ class InspectorIsolateData : public v8_inspector::V8InspectorClient { void BreakProgram(int context_group_id, const v8_inspector::StringView& reason, const v8_inspector::StringView& details); - void Stop(int context_group_id); + void Stop(int session_id); void SchedulePauseOnNextStatement(int context_group_id, const v8_inspector::StringView& reason, const v8_inspector::StringView& details); diff --git a/test/inspector/protocol-test.js b/test/inspector/protocol-test.js index 2f6d52891d..d45ea22baf 100644 --- a/test/inspector/protocol-test.js +++ b/test/inspector/protocol-test.js @@ -160,10 +160,6 @@ InspectorTest.ContextGroup = class { utils.cancelPauseOnNextStatement(this.id); } - stop() { - utils.stop(this.id); - } - addScript(string, lineOffset, columnOffset, url) { utils.compileAndRunWithOrigin(this.id, string, url || '', lineOffset || 0, columnOffset || 0, false); } @@ -268,6 +264,10 @@ InspectorTest.Session = class { utils.sendMessageToBackend(this.id, command); } + stop() { + utils.stop(this.id); + } + setupScriptMap() { if (this._scriptMap) return;