diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-navigation.js b/devtools/client/debugger/test/mochitest/browser_dbg-navigation.js index b8439669b897..8270c9a7e142 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-navigation.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-navigation.js @@ -28,6 +28,7 @@ add_task(async function() { invokeInTab("firstCall"); await waitForPaused(dbg); + await waitForRequestsToSettle(dbg); await navigate(dbg, "doc-scripts.html", "simple1.js"); await selectSource(dbg, "simple1"); await addBreakpoint(dbg, "simple1.js", 4); @@ -39,18 +40,29 @@ add_task(async function() { assertPausedLocation(dbg); is(countSources(dbg), 5, "5 sources are loaded."); + await waitForRequestsToSettle(dbg); + // this test is intermittent without this + let onBreakpoint = waitForDispatch(dbg, "SET_BREAKPOINT"); await navigate(dbg, "doc-scripts.html", ...sources); + await onBreakpoint is(countSources(dbg), 5, "5 sources are loaded."); ok(!getIsPaused(getCurrentThread()), "Is not paused"); + await waitForRequestsToSettle(dbg); + // this test is intermittent without this + onBreakpoint = waitForDispatch(dbg, "SET_BREAKPOINT"); await navigate(dbg, "doc-scripts.html", ...sources); + await onBreakpoint is(countSources(dbg), 5, "5 sources are loaded."); // Test that the current select source persists across reloads await selectSource(dbg, "long.js"); - await waitForRequestsToSettle(dbg); + await waitForRequestsToSettle(dbg); + // this test is intermittent without this + onBreakpoint = waitForDispatch(dbg, "SET_BREAKPOINT"); await reload(dbg, "long.js"); + await onBreakpoint await waitForSelectedSource(dbg, "long.js"); await waitForRequestsToSettle(dbg); diff --git a/devtools/shared/client/thread-client.js b/devtools/shared/client/thread-client.js index 5c8aca6a75b1..864cd06dec04 100644 --- a/devtools/shared/client/thread-client.js +++ b/devtools/shared/client/thread-client.js @@ -195,8 +195,15 @@ class ThreadClient extends FrontClassWithSpec(threadSpec) { /** * Request the loaded sources for the current thread. */ - getSources() { - return super.sources(); + async getSources() { + let sources = []; + try { + ({sources} = await super.sources()); + } catch (e) { + // we may have closed the connection + console.log(`getSources failed. Connection may have closed: ${e}`); + } + return { sources }; } /**