From 0df77da2522809581ffb2d7b0df53283cdebe08d Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Wed, 23 Mar 2022 18:17:50 +0000 Subject: [PATCH] Bug 1759987 - [devtools] Drop assertPausedLocation in favor of assertPausedAtSourceAndLine. r=bomsy The previous method wasn't really asserting the paused location. In only ensured that reducer state was matching CodeMirror state. Differential Revision: https://phabricator.services.mozilla.com/D141355 --- ...outdebugging_devtoolstoolbox_breakpoint.js | 4 +- ..._application_panel_debug-service-worker.js | 4 +- .../debugger/test/mochitest/browser.ini | 1 - .../mochitest/browser_dbg-async-stepping.js | 8 ++-- .../browser_dbg-breaking-from-console.js | 9 +++- .../test/mochitest/browser_dbg-breaking.js | 15 ++++--- .../browser_dbg-content-script-sources.js | 7 ++- .../mochitest/browser_dbg-debugger-buttons.js | 39 +++++++++++++---- .../mochitest/browser_dbg-editor-select.js | 8 ++-- .../browser_dbg-event-breakpoints-fission.js | 29 +++++++------ .../browser_dbg-event-breakpoints.js | 30 +++++-------- .../browser_dbg-fission-frame-breakpoint.js | 7 ++- ...wser_dbg-fission-frame-pause-exceptions.js | 21 ++++++--- .../mochitest/browser_dbg-html-breakpoints.js | 18 ++++++-- .../test/mochitest/browser_dbg-iframes.js | 14 ++++-- .../browser_dbg-keyboard-shortcuts.js | 10 ++--- .../browser_dbg-navigation-when-paused.js | 13 ++++-- .../mochitest/browser_dbg-pause-exceptions.js | 10 ++--- .../browser_dbg-paused-overlay-iframe.js | 3 +- .../browser_dbg-pretty-print-paused.js | 8 +++- .../mochitest/browser_dbg-pretty-print.js | 4 +- .../browser_dbg-scroll-run-to-completion.js | 6 ++- .../browser_dbg-sourcemapped-stepping.js | 13 +----- .../mochitest/browser_dbg-sourcemaps-bogus.js | 2 +- .../browser_dbg-sourcemaps-indexed.js | 14 +----- .../browser_dbg-sourcemaps-reloading.js | 12 ++---- .../test/mochitest/browser_dbg-sourcemaps.js | 11 ++--- .../test/mochitest/browser_dbg-sourcemaps2.js | 14 +----- .../test/mochitest/browser_dbg-sourcemaps3.js | 2 +- .../browser_dbg-step-in-uninitialized.js | 13 ++++-- .../test/mochitest/browser_dbg-stepping.js | 4 +- .../mochitest/browser_dbg-xhr-breakpoints.js | 8 +++- .../browser_dbg-xhr-run-to-completion.js | 24 +++++++++-- .../debugger/test/mochitest/shared-head.js | 43 ++++++++----------- 34 files changed, 238 insertions(+), 190 deletions(-) diff --git a/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_devtoolstoolbox_breakpoint.js b/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_devtoolstoolbox_breakpoint.js index 7b278892264e..ba863d1866ca 100644 --- a/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_devtoolstoolbox_breakpoint.js +++ b/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_devtoolstoolbox_breakpoint.js @@ -57,7 +57,8 @@ add_task(async function() { info("Wait for the debugger to pause"); await waitForPaused(debuggerContext); - assertPausedLocation(debuggerContext); + const script = findSource(debuggerContext, SCRIPT_FILE); + assertPausedAtSourceAndLine(debuggerContext, script.id, 10); info("Resume"); await resume(debuggerContext); @@ -66,7 +67,6 @@ add_task(async function() { await onContentTaskDone; info("Remove breakpoint"); - const script = findSource(debuggerContext, SCRIPT_FILE); await removeBreakpoint(debuggerContext, script.id, 10); await closeAboutDevtoolsToolbox(document, devtoolsTab, window); diff --git a/devtools/client/application/test/browser/browser_application_panel_debug-service-worker.js b/devtools/client/application/test/browser/browser_application_panel_debug-service-worker.js index e1f06f797d4c..bc5b6c4e8fcc 100644 --- a/devtools/client/application/test/browser/browser_application_panel_debug-service-worker.js +++ b/devtools/client/application/test/browser/browser_application_panel_debug-service-worker.js @@ -47,11 +47,11 @@ add_task(async function() { content.wrappedJSObject.fetchFromWorker(); }); await waitForPaused(debuggerContext); - assertPausedLocation(debuggerContext); + const workerScript = findSource(debuggerContext, "debug-sw.js"); + assertPausedAtSourceAndLine(debuggerContext, workerScript.id, 11); await resume(debuggerContext); // remove breakpoint - const workerScript = findSource(debuggerContext, "debug-sw.js"); await removeBreakpoint(debuggerContext, workerScript.id, 11); await unregisterAllWorkers(commands.client, doc); diff --git a/devtools/client/debugger/test/mochitest/browser.ini b/devtools/client/debugger/test/mochitest/browser.ini index 7715844c7437..2a22ecf0dba5 100644 --- a/devtools/client/debugger/test/mochitest/browser.ini +++ b/devtools/client/debugger/test/mochitest/browser.ini @@ -125,7 +125,6 @@ skip-if = true # bug 1607636 [browser_dbg-keyboard-navigation.js] [browser_dbg-keyboard-shortcuts-modal.js] [browser_dbg-keyboard-shortcuts.js] -skip-if = os == "linux" # bug 1351952 [browser_dbg-layout-changes.js] [browser_dbg-link-reload.js] skip-if = diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-async-stepping.js b/devtools/client/debugger/test/mochitest/browser_dbg-async-stepping.js index 65477eb48c2b..a39d7f3875ca 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-async-stepping.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-async-stepping.js @@ -15,10 +15,10 @@ add_task(async function test() { invokeInTab("main"); await waitForPaused(dbg); - assertPausedLocation(dbg); - assertDebugLine(dbg, 8); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "async.js").id, 8); await stepOver(dbg); - assertPausedLocation(dbg); - assertDebugLine(dbg, 9); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "async.js").id, 9); + + await assertBreakpoint(dbg, 8); }); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-breaking-from-console.js b/devtools/client/debugger/test/mochitest/browser_dbg-breaking-from-console.js index 3ce9461bf4b4..5791524b6bde 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-breaking-from-console.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-breaking-from-console.js @@ -26,6 +26,13 @@ add_task(async function() { // Make sure the thread is paused in the right source and location await waitForPaused(dbg); + const selectedSource = dbg.selectors.getSelectedSource(); + ok( + !selectedSource.url, + "The selected source is the console evaluation and doesn't have a URL" + ); is(getCM(dbg).getValue(), "debugger"); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, selectedSource.id, 1); + + await resume(dbg); }); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-breaking.js b/devtools/client/debugger/test/mochitest/browser_dbg-breaking.js index 079dff14c678..ba50911c1664 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-breaking.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-breaking.js @@ -18,10 +18,8 @@ add_task(async function() { // reload. await addBreakpoint(dbg, "doc-scripts.html", 21); - reload(dbg); + await reload(dbg, "doc-scripts.html"); - await waitForDispatch(dbg.store, "NAVIGATE"); - await waitForSelectedSource(dbg, "doc-scripts.html"); await waitForPaused(dbg); let whyPaused = await waitFor( @@ -29,12 +27,15 @@ add_task(async function() { ); is(whyPaused, "Paused on breakpoint"); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "doc-scripts.html").id, 21); await resume(dbg); info("Create an eval script that pauses itself."); invokeInTab("doEval"); await waitForPaused(dbg); + const source = getSelectedSource(); + ok(!source.url, "It is an eval source"); + assertPausedAtSourceAndLine(dbg, source.id, 2); whyPaused = await waitFor( () => dbg.win.document.querySelector(".why-paused")?.innerText @@ -42,11 +43,11 @@ add_task(async function() { is(whyPaused, "Paused on debugger statement"); await resume(dbg); - const source = getSelectedSource(); - ok(!source.url, "It is an eval source"); await addBreakpoint(dbg, source, 5); invokeInTab("evaledFunc"); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, source.id, 5); + + await resume(dbg); }); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-content-script-sources.js b/devtools/client/debugger/test/mochitest/browser_dbg-content-script-sources.js index 20ca49199b00..930a515d715f 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-content-script-sources.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-content-script-sources.js @@ -38,8 +38,11 @@ add_task(async function() { findElementWithSelector(dbg, ".sources-list .focused"), "Source is focused" ); - assertPausedLocation(dbg); - assertDebugLine(dbg, 2); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "content_script.js").id, + 2 + ); await resume(dbg); } diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-debugger-buttons.js b/devtools/client/debugger/test/mochitest/browser_dbg-debugger-buttons.js index faa15420850f..3e841a0eab79 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-debugger-buttons.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-debugger-buttons.js @@ -16,31 +16,54 @@ add_task(async function() { const dbg = await initDebugger("doc-debugger-statements.html"); - await reload(dbg); + await reload(dbg, "doc-debugger-statements.html"); await waitForPaused(dbg); - await waitForLoadedSource(dbg, "doc-debugger-statements.html"); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-debugger-statements.html").id, + 11 + ); info("resume"); await clickResume(dbg); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-debugger-statements.html").id, + 16 + ); info("step over"); await clickStepOver(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-debugger-statements.html").id, + 17 + ); info("step into"); await clickStepIn(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-debugger-statements.html").id, + 22 + ); info("step over"); await clickStepOver(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-debugger-statements.html").id, + 24 + ); info("step out"); await clickStepOut(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-debugger-statements.html").id, + 18 + ); }); function clickButton(dbg, button) { diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-editor-select.js b/devtools/client/debugger/test/mochitest/browser_dbg-editor-select.js index 40e9a1ff5a51..40f16b409fa2 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-editor-select.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-editor-select.js @@ -23,17 +23,17 @@ add_task(async function() { invokeInTab("main"); await waitForPaused(dbg); await waitForSelectedSource(dbg, "simple1.js"); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "simple1.js").id, 4); info("Step into another file."); await stepOver(dbg); await stepIn(dbg); await waitForSelectedSource(dbg, "simple2.js"); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "simple2.js").id, 3); info("Step out to the initial file."); await stepOut(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "simple1.js").id, 6); await resume(dbg); info("Make sure that the editor scrolls to the paused location."); @@ -45,7 +45,7 @@ add_task(async function() { await waitForPaused(dbg); await waitForSelectedSource(dbg, "long.js"); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "long.js").id, 66); ok( isVisibleInEditor(dbg, findElement(dbg, "breakpoint")), "Breakpoint is visible" diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-event-breakpoints-fission.js b/devtools/client/debugger/test/mochitest/browser_dbg-event-breakpoints-fission.js index 072f966dcda9..90ef79d12d37 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-event-breakpoints-fission.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-event-breakpoints-fission.js @@ -30,7 +30,11 @@ add_task(async function() { const waitForReload = reloadBrowser(); await waitForPaused(dbg); - assertPauseLocation(dbg, 17, "doc-event-breakpoints-fission.html"); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-event-breakpoints-fission.html").id, + 17 + ); await resume(dbg); await waitForReload; @@ -49,26 +53,23 @@ add_task(async function() { async function invokeAndAssertBreakpoints(dbg) { invokeInTabRemoteFrame("clickHandler"); await waitForPaused(dbg); - assertPauseLocation(dbg, 12); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "event-breakpoints.js").id, + 12 + ); await resume(dbg); invokeInTabRemoteFrame("xhrHandler"); await waitForPaused(dbg); - assertPauseLocation(dbg, 20); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "event-breakpoints.js").id, + 20 + ); await resume(dbg); } -function assertPauseLocation(dbg, line, url = "event-breakpoints.js") { - const { location } = dbg.selectors.getVisibleSelectedFrame(); - const selectedSource = dbg.selectors.getSelectedSource(); - - is(location.sourceId, selectedSource.id, `Correct selected sourceId`); - ok(selectedSource.url.includes(url), "Correct url"); - is(location.line, line, "Correct paused line"); - - assertPausedLocation(dbg); -} - async function invokeInTabRemoteFrame(fnc, ...args) { info(`Invoking in tab remote frame: ${fnc}(${args.map(uneval).join(",")})`); await SpecialPowers.spawn(gBrowser.selectedBrowser, [fnc, args], function( diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-event-breakpoints.js b/devtools/client/debugger/test/mochitest/browser_dbg-event-breakpoints.js index ceea56a1f9c8..bfd0c05390a9 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-event-breakpoints.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-event-breakpoints.js @@ -16,13 +16,14 @@ add_task(async function() { ); await selectSource(dbg, "event-breakpoints.js"); await waitForSelectedSource(dbg, "event-breakpoints.js"); + const eventBreakpointsSource = findSource(dbg, "event-breakpoints.js"); // We want to set each breakpoint individually to test adding/removing breakpoints, see Bug 1748589. await toggleEventBreakpoint(dbg, "Mouse", "event.mouse.click"); invokeInTab("clickHandler"); await waitForPaused(dbg); - assertPauseLocation(dbg, 12); + assertPausedAtSourceAndLine(dbg, eventBreakpointsSource.id, 12); const whyPaused = await waitFor( () => dbg.win.document.querySelector(".why-paused")?.innerText @@ -37,42 +38,42 @@ add_task(async function() { await toggleEventBreakpoint(dbg, "XHR", "event.xhr.load"); invokeInTab("xhrHandler"); await waitForPaused(dbg); - assertPauseLocation(dbg, 20); + assertPausedAtSourceAndLine(dbg, eventBreakpointsSource.id, 20); await resume(dbg); await toggleEventBreakpoint(dbg, "Timer", "timer.timeout.set"); await toggleEventBreakpoint(dbg, "Timer", "timer.timeout.fire"); invokeInTab("timerHandler"); await waitForPaused(dbg); - assertPauseLocation(dbg, 27); + assertPausedAtSourceAndLine(dbg, eventBreakpointsSource.id, 27); await resume(dbg); await waitForPaused(dbg); - assertPauseLocation(dbg, 28); + assertPausedAtSourceAndLine(dbg, eventBreakpointsSource.id, 28); await resume(dbg); await toggleEventBreakpoint(dbg, "Script", "script.source.firstStatement"); invokeInTab("evalHandler"); await waitForPaused(dbg); - assertPauseLocation(dbg, 2, "https://example.com/eval-test.js"); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "eval-test.js").id, 2); await resume(dbg); await toggleEventBreakpoint(dbg, "Control", "event.control.focusin"); await toggleEventBreakpoint(dbg, "Control", "event.control.focusout"); invokeOnElement("#focus-text", "focus"); await waitForPaused(dbg); - assertPauseLocation(dbg, 43); + assertPausedAtSourceAndLine(dbg, eventBreakpointsSource.id, 43); await resume(dbg); // wait for focus-out event to fire await waitForPaused(dbg); - assertPauseLocation(dbg, 48); + assertPausedAtSourceAndLine(dbg, eventBreakpointsSource.id, 48); await resume(dbg); info("Check that the click event breakpoint is still enabled"); invokeInTab("clickHandler"); await waitForPaused(dbg); - assertPauseLocation(dbg, 12); + assertPausedAtSourceAndLine(dbg, eventBreakpointsSource.id, 12); await resume(dbg); info("Check that disabling an event breakpoint works"); @@ -86,7 +87,7 @@ add_task(async function() { await toggleEventBreakpoint(dbg, "Mouse", "event.mouse.click"); invokeInTab("clickHandler"); await waitForPaused(dbg); - assertPauseLocation(dbg, 12); + assertPausedAtSourceAndLine(dbg, eventBreakpointsSource.id, 12); await resume(dbg); info( @@ -161,17 +162,6 @@ async function toggleEventBreakpoint( await onEventListenersUpdate; } -function assertPauseLocation(dbg, line, url = "event-breakpoints.js") { - const { location } = dbg.selectors.getVisibleSelectedFrame(); - - const source = findSource(dbg, url); - - is(location.sourceId, source.id, `correct sourceId`); - is(location.line, line, `correct line`); - - assertPausedLocation(dbg); -} - async function invokeOnElement(selector, action) { await SpecialPowers.focus(gBrowser.selectedBrowser); await SpecialPowers.spawn( diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-fission-frame-breakpoint.js b/devtools/client/debugger/test/mochitest/browser_dbg-fission-frame-breakpoint.js index bec8333d0652..12d00a06a842 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-fission-frame-breakpoint.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-fission-frame-breakpoint.js @@ -32,12 +32,11 @@ add_task(async function() { getSelectedSource().url.includes("simple2.js"), "Selected source is simple2.js" ); - assertPausedLocation(dbg); - assertDebugLine(dbg, 7); + await waitForPaused(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "simple2.js").id, 7); await stepIn(dbg); - assertDebugLine(dbg, 7); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "simple2.js").id, 7); // We can't used `stepIn` helper as this last step will resume // and the helper is expecting to pause again diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-fission-frame-pause-exceptions.js b/devtools/client/debugger/test/mochitest/browser_dbg-fission-frame-pause-exceptions.js index 110eb7c5acb9..76477a4e5b59 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-fission-frame-pause-exceptions.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-fission-frame-pause-exceptions.js @@ -17,8 +17,11 @@ add_task(async function() { await reload(dbg); await waitForPaused(dbg); - assertPausedLocation(dbg); - assertDebugLine(dbg, 17); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc_dbg-fission-frame-pause-exceptions.html").id, + 17 + ); await resume(dbg); @@ -28,14 +31,20 @@ add_task(async function() { await reload(dbg); await waitForPaused(dbg); - assertPausedLocation(dbg); - assertDebugLine(dbg, 13); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc_dbg-fission-frame-pause-exceptions.html").id, + 13 + ); await resume(dbg); await waitForPaused(dbg); - assertPausedLocation(dbg); - assertDebugLine(dbg, 17); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc_dbg-fission-frame-pause-exceptions.html").id, + 17 + ); await resume(dbg); }); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-html-breakpoints.js b/devtools/client/debugger/test/mochitest/browser_dbg-html-breakpoints.js index acaa53eb8030..323f38c598cf 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-html-breakpoints.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-html-breakpoints.js @@ -27,18 +27,30 @@ add_task(async function() { invokeInTab("test1"); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-html-breakpoints.html").id, + 8 + ); await resume(dbg); await waitForBreakableLine(dbg, "doc-html-breakpoints.html", 14); invokeInTab("test3"); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-html-breakpoints.html").id, + 14 + ); await resume(dbg); await waitForBreakableLine(dbg, "doc-html-breakpoints.html", 20); invokeInTab("test4"); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-html-breakpoints.html").id, + 20 + ); await resume(dbg); }); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-iframes.js b/devtools/client/debugger/test/mochitest/browser_dbg-iframes.js index b6a8a8340040..fd42386fd7d2 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-iframes.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-iframes.js @@ -21,16 +21,24 @@ add_task(async function() { await reload(dbg); await waitForPaused(dbg); await waitForLoadedSource(dbg, "doc-iframes.html"); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "doc-iframes.html").id, 11); // test pausing in the iframe await resume(dbg); await waitForPaused(dbg); await waitForLoadedSource(dbg, "doc-debugger-statements.html"); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-debugger-statements.html").id, + 11 + ); // test pausing in the iframe await resume(dbg); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-debugger-statements.html").id, + 16 + ); }); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-keyboard-shortcuts.js b/devtools/client/debugger/test/mochitest/browser_dbg-keyboard-shortcuts.js index 9ac2310abc69..f8a08ab76b2c 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-keyboard-shortcuts.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-keyboard-shortcuts.js @@ -18,19 +18,19 @@ add_task(async function() { assertPausedAtSourceAndLine(dbg, source.id, 11); await pressResume(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, source.id, 16); await pressStepOver(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, source.id, 17); await pressStepIn(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, source.id, 22); await pressStepOut(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, source.id, 18); await pressStepOver(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, source.id, 18); }); function pressResume(dbg) { diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-navigation-when-paused.js b/devtools/client/debugger/test/mochitest/browser_dbg-navigation-when-paused.js index 6f6742d03b03..71c0deb83606 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-navigation-when-paused.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-navigation-when-paused.js @@ -13,8 +13,11 @@ add_task(async function() { await waitForPaused(dbg, "doc-navigation-when-paused.html"); - assertPausedLocation(dbg); - assertDebugLine(dbg, 12); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-navigation-when-paused.html").id, + 12 + ); await navigate( dbg, @@ -31,5 +34,9 @@ add_task(async function() { // source itself has loaded, which may not be the case if navigation cleared // the source and nothing has sent it to the devtools client yet, as was // the case in Bug 1581530. - assertDebugLine(dbg, 12); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-navigation-when-paused.html").id, + 12 + ); }); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-pause-exceptions.js b/devtools/client/debugger/test/mochitest/browser_dbg-pause-exceptions.js index 42ad63ba2c87..068d308b3830 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-pause-exceptions.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-pause-exceptions.js @@ -24,7 +24,7 @@ add_task(async function() { await togglePauseOnExceptions(dbg, true, true); uncaughtException(); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, source.id, 2); const whyPaused = await waitFor( () => dbg.win.document.querySelector(".why-paused")?.innerText @@ -37,18 +37,18 @@ add_task(async function() { await togglePauseOnExceptions(dbg, true, true); uncaughtException(); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, source.id, 2); await resume(dbg); info("3. Test pausing on a caught Error"); caughtException(); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, source.id, 7); info("3.b Test pausing in the catch statement"); await resume(dbg); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, source.id, 9); await resume(dbg); info("4. Test skipping a caught error"); @@ -57,7 +57,7 @@ add_task(async function() { info("4.b Test pausing in the catch statement"); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, source.id, 9); await resume(dbg); await togglePauseOnExceptions(dbg, true, true); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-paused-overlay-iframe.js b/devtools/client/debugger/test/mochitest/browser_dbg-paused-overlay-iframe.js index 3fd3e6dbebb7..9f7f54e662f9 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-paused-overlay-iframe.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-paused-overlay-iframe.js @@ -57,8 +57,7 @@ add_task(async function() { getSelectedSource().url.includes("simple2.js"), "Selected source is simple2.js" ); - assertPausedLocation(dbg); - assertDebugLine(dbg, 5); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "simple2.js").id, 5); info("Test clicking the resume button"); await highlighterTestFront.clickPausedDebuggerOverlayButton( diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-pretty-print-paused.js b/devtools/client/debugger/test/mochitest/browser_dbg-pretty-print-paused.js index be301b4ebb0e..33a1385ead53 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-pretty-print-paused.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-pretty-print-paused.js @@ -15,7 +15,7 @@ add_task(async function() { invokeInTab("arithmetic"); await waitForPaused(dbg, "math.min.js"); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "math.min.js").id, 2); clickElement(dbg, "prettyPrintButton"); await waitForSelectedSource(dbg, "math.min.js:formatted"); @@ -23,7 +23,11 @@ add_task(async function() { dbg, state => dbg.selectors.getSelectedFrame(thread).location.line == 18 ); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "math.min.js:formatted").id, + 18 + ); await waitForBreakpoint(dbg, "math.min.js:formatted", 18); await assertBreakpoint(dbg, 18); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-pretty-print.js b/devtools/client/debugger/test/mochitest/browser_dbg-pretty-print.js index 9b9174154bee..fa98895ab6c5 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-pretty-print.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-pretty-print.js @@ -27,11 +27,11 @@ add_task(async function() { invokeInTab("arithmetic"); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, ppSrc.id, 18); await stepOver(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, ppSrc.id, 27); await resume(dbg); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-scroll-run-to-completion.js b/devtools/client/debugger/test/mochitest/browser_dbg-scroll-run-to-completion.js index cba45edaa763..c9e077575353 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-scroll-run-to-completion.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-scroll-run-to-completion.js @@ -8,7 +8,11 @@ add_task(async function() { const dbg = await initDebugger("doc-scroll-run-to-completion.html"); invokeInTab("pauseOnce", "doc-scroll-run-to-completion.html"); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-scroll-run-to-completion.html").id, + 20 + ); await checkEvaluateInTopFrame(dbg, "window.scrollBy(0, 10);", undefined); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemapped-stepping.js b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemapped-stepping.js index 5d5f1bbfc4ea..6e19f3147c3d 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemapped-stepping.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemapped-stepping.js @@ -38,11 +38,8 @@ async function breakpointSteps(dbg, target, fixture, { line, column }, steps) { } async function runSteps(dbg, source, steps) { - const { - selectors: { getVisibleSelectedFrame }, - } = dbg; - for (const [i, [type, position]] of steps.entries()) { + info(`Step ${i}`); switch (type) { case "stepOver": await stepOver(dbg); @@ -54,13 +51,7 @@ async function runSteps(dbg, source, steps) { throw new Error("Unknown stepping type"); } - const { location } = getVisibleSelectedFrame(); - - is(location.sourceId, source.id, `Step ${i} has correct sourceId`); - is(location.line, position.line, `Step ${i} has correct line`); - is(location.column, position.column, `Step ${i} has correct column`); - - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, source.id, position.line, position.column); } } diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps-bogus.js b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps-bogus.js index cbed5706e7a7..6e71c93b0f49 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps-bogus.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps-bogus.js @@ -20,7 +20,7 @@ add_task(async function() { await addBreakpoint(dbg, "bogus-map.js", 4); invokeInTab("runCode"); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "bogus-map.js").id, 4); // Make sure that only the single generated source exists. The // sourcemap failed to download. diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps-indexed.js b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps-indexed.js index f2893c05eb2a..2ac5f74b8cef 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps-indexed.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps-indexed.js @@ -34,11 +34,11 @@ add_task(async function() { "Breakpoint has correct line" ); - assertBpInGutter(dbg, 4); + await assertBreakpoint(dbg, 4); invokeInTab("logMessage"); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, mainSrc.id, 4, 2); // Tests the existence of the sourcemap link in the original source. ok(findElement(dbg, "sourceMapLink"), "Sourcemap link in original source"); @@ -49,13 +49,3 @@ add_task(async function() { "No Sourcemap link exists in generated source" ); }); - -function assertBpInGutter(dbg, lineNumber) { - const el = findElement(dbg, "breakpoint"); - const bpLineNumber = +el.querySelector(".CodeMirror-linenumber").innerText; - is( - bpLineNumber, - lineNumber, - "Breakpoint is on the correct line in the gutter" - ); -} diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps-reloading.js b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps-reloading.js index dc9f9f7014d0..bda9b10e2ebc 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps-reloading.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps-reloading.js @@ -35,15 +35,10 @@ add_task(async function() { await waitForPaused(dbg); await waitForDispatch(dbg.store, "ADD_INLINE_PREVIEW"); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "entry.js").id, 5); await waitForBreakpointCount(dbg, 2); - is(getBreakpointCount(), 2, "Three breakpoints exist"); - - ok( - getBreakpoint({ sourceId: entrySrc.id, line: 15, column: 0 }), - "Breakpoint has correct line" - ); + is(getBreakpointCount(), 2, "Two breakpoints exist"); ok( getBreakpoint({ @@ -52,8 +47,9 @@ add_task(async function() { column: 0, disabled: true, }), - "Breakpoint has correct line" + "Breakpoint is on the correct line and is disabled" ); + await assertBreakpoint(dbg, 15); }); async function waitForBreakpointCount(dbg, count) { diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps.js b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps.js index 91936c90f296..f6f078c6cbbb 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps.js @@ -68,21 +68,18 @@ add_task(async function() { invokeInTab("keepMeAlive"); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, entrySrc.id, 15); await stepIn(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "times2.js").id, 2); await dbg.actions.jumpToMappedSelectedLocation(getContext(dbg)); await stepOver(dbg); - assertPausedLocation(dbg); - assertDebugLine(dbg, 3); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "times2.js").id, 3); await dbg.actions.jumpToMappedSelectedLocation(getContext(dbg)); await stepOut(dbg); - assertPausedLocation(dbg); - - assertDebugLine(dbg, 16); + assertPausedAtSourceAndLine(dbg, entrySrc.id, 16); }); function assertBreakpointExists(dbg, source, line) { diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps2.js b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps2.js index a3574c65ac5a..3c98979d1ad2 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps2.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps2.js @@ -34,11 +34,11 @@ add_task(async function() { "Breakpoint has correct line" ); - assertBpInGutter(dbg, 4); + await assertBreakpoint(dbg, 4); invokeInTab("logMessage"); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, mainSrc.id, 4); // Tests the existence of the sourcemap link in the original source. ok(findElement(dbg, "sourceMapLink"), "Sourcemap link in original source"); @@ -49,13 +49,3 @@ add_task(async function() { "No Sourcemap link exists in generated source" ); }); - -function assertBpInGutter(dbg, lineNumber) { - const el = findElement(dbg, "breakpoint"); - const bpLineNumber = +el.querySelector(".CodeMirror-linenumber").innerText; - is( - bpLineNumber, - lineNumber, - "Breakpoint is on the correct line in the gutter" - ); -} diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps3.js b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps3.js index fd5f71802171..58a209e586e4 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps3.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps3.js @@ -35,7 +35,7 @@ add_task(async function() { invokeInTab("test"); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, sortedSrc.id, 9, 4); is(getScopeLabel(dbg, 1), "Block"); is(getScopeLabel(dbg, 2), "na"); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-step-in-uninitialized.js b/devtools/client/debugger/test/mochitest/browser_dbg-step-in-uninitialized.js index b0df40576431..41065295d902 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-step-in-uninitialized.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-step-in-uninitialized.js @@ -15,8 +15,11 @@ add_task(async function test() { await stepOver(dbg); await stepIn(dbg); - assertDebugLine(dbg, 8); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-step-in-uninitialized.html").id, + 8 + ); // We step past the 'let x' at the start of the function because it is not // a breakpoint position. @@ -25,7 +28,11 @@ add_task(async function test() { await stepOver(dbg); - assertDebugLine(dbg, 9); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-step-in-uninitialized.html").id, + 9 + ); ok(findNodeValue(dbg, "y") == "3", "y initialized"); }); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-stepping.js b/devtools/client/debugger/test/mochitest/browser_dbg-stepping.js index cd13cb073f93..682d834ae720 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-stepping.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-stepping.js @@ -11,6 +11,7 @@ add_task(async function test() { const dbg = await initDebugger("big-sourcemap.html", "bundle.js"); invokeInTab("hitDebugStatement"); await waitForPaused(dbg, "bundle.js"); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "bundle.js").id, 52411); await stepIn(dbg); @@ -33,6 +34,5 @@ add_task(async function test() { await stepIn(dbg); await stepIn(dbg); - assertDebugLine(dbg, 7679); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "step-in-test.js").id, 7679); }); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-xhr-breakpoints.js b/devtools/client/debugger/test/mochitest/browser_dbg-xhr-breakpoints.js index f1d9da99473a..2c9f68016e60 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-xhr-breakpoints.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-xhr-breakpoints.js @@ -22,7 +22,11 @@ add_task(async function() { ); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-early-xhr.html").id, + 10 + ); const whyPaused = await waitFor( () => dbg.win.document.querySelector(".why-paused")?.innerText @@ -59,7 +63,7 @@ add_task(async function() { invokeInTab("main", "doc-xhr.html"); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, "fetch.js").id, 4); await resume(dbg); await dbg.actions.removeXHRBreakpoint(0); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-xhr-run-to-completion.js b/devtools/client/debugger/test/mochitest/browser_dbg-xhr-run-to-completion.js index f2dacc41f12e..ceac2e94b02b 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-xhr-run-to-completion.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-xhr-run-to-completion.js @@ -11,7 +11,11 @@ add_task(async function() { invokeInTab("singleRequest", "doc-xhr-run-to-completion.html"); await waitForPaused(dbg); await waitForSelectedLocation(dbg, 23); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-xhr-run-to-completion.html").id, + 23 + ); const onTestPassed = once(Services.ppmm, "test passed"); await resume(dbg); @@ -25,13 +29,25 @@ add_task(async function() { const dbg = await initDebugger("doc-xhr-run-to-completion.html"); invokeInTab("multipleRequests", "doc-xhr-run-to-completion.html"); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-xhr-run-to-completion.html").id, + 31 + ); await resume(dbg); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-xhr-run-to-completion.html").id, + 33 + ); await resume(dbg); await waitForPaused(dbg); - assertPausedLocation(dbg); + assertPausedAtSourceAndLine( + dbg, + findSource(dbg, "doc-xhr-run-to-completion.html").id, + 34 + ); const onTestPassed = once(Services.ppmm, "test passed"); await resume(dbg); await onTestPassed; diff --git a/devtools/client/debugger/test/mochitest/shared-head.js b/devtools/client/debugger/test/mochitest/shared-head.js index 02b990e7e17c..505653d3ddbd 100644 --- a/devtools/client/debugger/test/mochitest/shared-head.js +++ b/devtools/client/debugger/test/mochitest/shared-head.js @@ -240,24 +240,6 @@ function getVisibleSelectedFrameColumn(dbg) { return frame?.location.column; } -/** - * Assert that the debugger pause location is correctly rendered. - * - * @memberof mochitest/asserts - * @param {Object} dbg - * @static - */ -function assertPausedLocation(dbg) { - ok(isSelectedFrameSelected(dbg), "top frame's source is selected"); - - // Check the pause location - const pauseLine = getVisibleSelectedFrameLine(dbg); - const pauseColumn = getVisibleSelectedFrameColumn(dbg); - assertDebugLine(dbg, pauseLine, pauseColumn); - - ok(isVisibleInEditor(dbg, getCM(dbg).display.gutters), "gutter is visible"); -} - function assertDebugLine(dbg, line, column) { // Check the debug line const lineInfo = getCM(dbg).lineInfo(line - 1); @@ -394,7 +376,14 @@ function assertPausedAtSourceAndLine( assertPaused(dbg); // Check that the paused location is correctly rendered. - assertPausedLocation(dbg); + ok(isSelectedFrameSelected(dbg), "top frame's source is selected"); + + // Check the pause location + const pauseLine = getVisibleSelectedFrameLine(dbg); + const pauseColumn = getVisibleSelectedFrameColumn(dbg); + assertDebugLine(dbg, pauseLine, pauseColumn); + + ok(isVisibleInEditor(dbg, getCM(dbg).display.gutters), "gutter is visible"); const frames = dbg.selectors.getCurrentThreadFrames(); ok(frames.length >= 1, "Got at least one frame"); @@ -404,14 +393,16 @@ function assertPausedAtSourceAndLine( ? frames[0].generatedLocation : frames[0].location; is(sourceId, expectedSourceId, "Frame has correct source"); - ok( - line == expectedLine, + is( + line, + expectedLine, `Frame paused at line ${line}, but expected line ${expectedLine}` ); if (expectedColumn) { - ok( - column == expectedColumn, + is( + column, + expectedColumn, `Frame paused at column ${column}, but expected column ${expectedColumn}` ); } @@ -1007,7 +998,7 @@ async function invokeWithBreakpoint( return; } - assertPausedLocation(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, filename).id, line, column); await removeBreakpoint(dbg, source.id, line, column); @@ -1208,10 +1199,10 @@ const keyMappings = { pauseKey: { code: "VK_F8" }, resumeKey: { code: "VK_F8" }, stepOverKey: { code: "VK_F10" }, - stepInKey: { code: "VK_F11", modifiers: { ctrlKey: isLinux } }, + stepInKey: { code: "VK_F11" }, stepOutKey: { code: "VK_F11", - modifiers: { ctrlKey: isLinux, shiftKey: true }, + modifiers: { shiftKey: true }, }, };