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
This commit is contained in:
Alexandre Poirot 2022-03-23 18:17:50 +00:00
Родитель f7d3c4295c
Коммит 0df77da252
34 изменённых файлов: 238 добавлений и 190 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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 =

Просмотреть файл

@ -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);
});

Просмотреть файл

@ -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);
});

Просмотреть файл

@ -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);
});

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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"

Просмотреть файл

@ -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(

Просмотреть файл

@ -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(

Просмотреть файл

@ -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

Просмотреть файл

@ -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);
});

Просмотреть файл

@ -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);
});

Просмотреть файл

@ -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
);
});

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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
);
});

Просмотреть файл

@ -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);

Просмотреть файл

@ -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(

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);
}
}

Просмотреть файл

@ -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.

Просмотреть файл

@ -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"
);
}

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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"
);
}

Просмотреть файл

@ -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");

Просмотреть файл

@ -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");
});

Просмотреть файл

@ -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);
});

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;

Просмотреть файл

@ -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 },
},
};