diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs index 7949ebec263fa..69a99a3fb724b 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/BreakpointTests.cs @@ -505,7 +505,7 @@ public async Task CreateGoodBreakpointAndHitGoToNonWasmPageComeBackAndHitAgain(s expression = "window.setTimeout(function() { " + func_name + "(); }, 1);" }); await cli.SendCommand("Runtime.evaluate", run_method, token); - await Task.Delay(1000, token); + await WaitForEventAsync("Runtime.executionContextCreated"); run_method = JObject.FromObject(new { diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs b/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs index 906803936c160..8f7e86d6834f3 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs @@ -1465,17 +1465,17 @@ internal async Task LoadAssemblyAndTestHotReload(string asm_file, strin return await WaitFor(Inspector.PAUSE); } - public async Task WaitForBreakpointResolvedEvent() + public Task WaitForBreakpointResolvedEvent() => WaitForEventAsync("Debugger.breakpointResolved"); + + public async Task WaitForEventAsync(string eventName) { try { - var res = await insp.WaitForEvent("Debugger.breakpointResolved"); - _testOutput.WriteLine ($"breakpoint resolved to {res}"); - return res; + return await insp.WaitForEvent(eventName); } catch (TaskCanceledException) { - throw new XunitException($"Timed out waiting for Debugger.breakpointResolved event"); + throw new XunitException($"Timed out waiting for {eventName} event"); } } diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/ExceptionTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/ExceptionTests.cs index a0270c00b4ef6..b4fe302fb66a6 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/ExceptionTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/ExceptionTests.cs @@ -238,7 +238,7 @@ await SendCommand("Page.reload", JObject.FromObject(new { ignoreCache = true })); - Thread.Sleep(1000); + await insp.WaitFor(Inspector.APP_READY); var eval_expr = "window.setTimeout(function() { invoke_static_method (" + $"'{entry_method_name}'" + @@ -278,10 +278,9 @@ public async Task ExceptionTestAllWithReload(string entry_method_name, string cl var pause_location = await SendCommandAndCheck(JObject.FromObject(new { ignoreCache = true - }), "Page.reload",null, 0, 0, null); - Thread.Sleep(1000); + }), "Page.reload", null, 0, 0, null); - // Hit resume to skip + // Hit resume to skip int count = 0; while(true) {