diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs index 7d2245da67784a..0aa7650c42c2bd 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs @@ -1539,8 +1539,9 @@ protected async Task RuntimeReady(SessionId sessionId, CancellationT ExecutionContext context = GetContext(sessionId); if (Interlocked.CompareExchange(ref context.ready, new TaskCompletionSource(), null) != null) return await context.ready.Task; - - await context.SdbAgent.SendDebuggerAgentCommand(CmdEventRequest.ClearAllBreakpoints, null, token); + var res = await context.SdbAgent.SendDebuggerAgentCommand(CmdEventRequest.ClearAllBreakpoints, null, token, false); + if (res.HasError) //it's not a wasm page then the command returns an error + return null; if (context.PauseOnExceptions != PauseOnExceptionsKind.None && context.PauseOnExceptions != PauseOnExceptionsKind.Unset) await context.SdbAgent.EnableExceptions(context.PauseOnExceptions, token); diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs index cb21ab4e9f2257..7949ebec263fa6 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs @@ -470,8 +470,10 @@ await SendCommandAndCheck(null, "Debugger.resume", }); } - [ConditionalFact(nameof(RunningOnChrome))] - public async Task CreateGoodBreakpointAndHitGoToNonWasmPageComeBackAndHitAgain() + [ConditionalTheory(nameof(RunningOnChrome))] + [InlineData("load_non_wasm_page")] + [InlineData("load_non_wasm_page_forcing_runtime_ready")] //to simulate the same behavior that has when debugging from VS and OnDefaultContextCreated is called + public async Task CreateGoodBreakpointAndHitGoToNonWasmPageComeBackAndHitAgain(string func_name) { var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); var pause_location = await EvaluateAndCheck( @@ -500,7 +502,7 @@ public async Task CreateGoodBreakpointAndHitGoToNonWasmPageComeBackAndHitAgain() var run_method = JObject.FromObject(new { - expression = "window.setTimeout(function() { load_non_wasm_page(); }, 1);" + expression = "window.setTimeout(function() { " + func_name + "(); }, 1);" }); await cli.SendCommand("Runtime.evaluate", run_method, token); await Task.Delay(1000, token); diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html b/src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html index fdbbc640696ac3..b6522cf3cc79a8 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html @@ -92,6 +92,10 @@ console.log("load_wasm_page_without_assets") window.location.replace("http://localhost:9400/wasm-page-without-assets.html"); } + function load_non_wasm_page_forcing_runtime_ready () { + console.log("load_non_wasm_page_forcing_runtime_ready") + window.location.replace("http://localhost:9400/non-wasm-page-forcing-runtime-ready.html"); + } diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj index 0ea4fcc719f4b8..0e457832913513 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj @@ -13,6 +13,7 @@ + diff --git a/src/mono/wasm/debugger/tests/debugger-test/non-wasm-page-forcing-runtime-ready.html b/src/mono/wasm/debugger/tests/debugger-test/non-wasm-page-forcing-runtime-ready.html new file mode 100644 index 00000000000000..22ab25fb23040e --- /dev/null +++ b/src/mono/wasm/debugger/tests/debugger-test/non-wasm-page-forcing-runtime-ready.html @@ -0,0 +1,14 @@ + + + + + + + +