Bug 1633624 - Clean up debugger mochitests r=jlast

Differential Revision: https://phabricator.services.mozilla.com/D72785
This commit is contained in:
David Walsh 2020-04-28 15:18:30 +00:00
parent 9b7a256fa0
commit ebafd74216
102 changed files with 1576 additions and 1519 deletions

View File

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
add_task(async function() {
const dbg = await initDebugger("doc-asm.html");
await reload(dbg);

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests async stepping will step over await statements
add_task(async function test() {

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Test the AudioContext are paused and resume appropriately when using the
// debugger.

View File

@ -9,12 +9,12 @@
// - 'Un/Blackbox files in this directory'
// - 'Un/Blackbox files outside this directory'
const sourceFiles = {
const SOURCE_FILES = {
nestedSource: "nested-source.js",
codeReload1: "code_reload_1.js",
};
const nodeSelectors = {
const NODE_SELECTORS = {
nodeBlackBoxAll: "#node-blackbox-all",
nodeBlackBoxAllInside: "#node-blackbox-all-inside",
nodeUnBlackBoxAllInside: "#node-unblackbox-all-inside",
@ -22,20 +22,13 @@ const nodeSelectors = {
nodeUnBlackBoxAllOutside: "#node-unblackbox-all-outside",
};
function waitForBlackboxCount(dbg, count) {
return waitForState(
dbg,
state => dbg.selectors.getBlackBoxList().length === count
);
}
add_task(async function() {
const dbg = await initDebugger("doc-blackbox-all.html");
info("Loads the source file and sets a breakpoint at line 2.");
await waitForSources(dbg, sourceFiles.nestedSource, sourceFiles.codeReload1);
await selectSource(dbg, sourceFiles.nestedSource);
await addBreakpoint(dbg, sourceFiles.nestedSource, 2);
await waitForSources(dbg, SOURCE_FILES.nestedSource, SOURCE_FILES.codeReload1);
await selectSource(dbg, SOURCE_FILES.nestedSource);
await addBreakpoint(dbg, SOURCE_FILES.nestedSource, 2);
info("Expands the whole source tree.");
rightClickElement(dbg, "sourceTreeRootNode");
@ -47,15 +40,15 @@ add_task(async function() {
info("Blackbox files in this directory.");
rightClickEl(dbg, sourceTreeFolderNodeEls[1]);
selectContextMenuItem(dbg, nodeSelectors.nodeBlackBoxAll);
await assertContextMenuLabel(dbg, nodeSelectors.nodeBlackBoxAllInside, "Blackbox files in this directory");
await assertContextMenuLabel(dbg, nodeSelectors.nodeBlackBoxAllOutside, "Blackbox files outside this directory");
selectContextMenuItem(dbg, nodeSelectors.nodeBlackBoxAllInside);
selectContextMenuItem(dbg, NODE_SELECTORS.nodeBlackBoxAll);
await assertContextMenuLabel(dbg, NODE_SELECTORS.nodeBlackBoxAllInside, "Blackbox files in this directory");
await assertContextMenuLabel(dbg, NODE_SELECTORS.nodeBlackBoxAllOutside, "Blackbox files outside this directory");
selectContextMenuItem(dbg, NODE_SELECTORS.nodeBlackBoxAllInside);
await waitForBlackboxCount(dbg, 1);
await waitForRequestsToSettle(dbg);
is(findSource(dbg, sourceFiles.nestedSource).isBlackBoxed, true, "nested-source.js is blackboxed");
is(findSource(dbg, sourceFiles.codeReload1).isBlackBoxed, false, "code_reload_1.js is not blackboxed");
is(findSource(dbg, SOURCE_FILES.nestedSource).isBlackBoxed, true, "nested-source.js is blackboxed");
is(findSource(dbg, SOURCE_FILES.codeReload1).isBlackBoxed, false, "code_reload_1.js is not blackboxed");
info("The invoked function is blackboxed and the debugger does not pause.");
invokeInTab("computeSomething");
@ -63,15 +56,15 @@ add_task(async function() {
info("Unblackbox files outside this directory.");
rightClickEl(dbg, sourceTreeFolderNodeEls[2]);
selectContextMenuItem(dbg, nodeSelectors.nodeBlackBoxAll);
await assertContextMenuLabel(dbg, nodeSelectors.nodeBlackBoxAllInside, "Blackbox files in this directory");
await assertContextMenuLabel(dbg, nodeSelectors.nodeUnBlackBoxAllOutside, "Unblackbox files outside this directory");
selectContextMenuItem(dbg, nodeSelectors.nodeUnBlackBoxAllOutside);
selectContextMenuItem(dbg, NODE_SELECTORS.nodeBlackBoxAll);
await assertContextMenuLabel(dbg, NODE_SELECTORS.nodeBlackBoxAllInside, "Blackbox files in this directory");
await assertContextMenuLabel(dbg, NODE_SELECTORS.nodeUnBlackBoxAllOutside, "Unblackbox files outside this directory");
selectContextMenuItem(dbg, NODE_SELECTORS.nodeUnBlackBoxAllOutside);
await waitForBlackboxCount(dbg, 0);
await waitForRequestsToSettle(dbg);
is(findSource(dbg, sourceFiles.nestedSource).isBlackBoxed, false, "nested-source.js is not blackboxed");
is(findSource(dbg, sourceFiles.codeReload1).isBlackBoxed, false, "code_reload_1.js is not blackboxed");
is(findSource(dbg, SOURCE_FILES.nestedSource).isBlackBoxed, false, "nested-source.js is not blackboxed");
is(findSource(dbg, SOURCE_FILES.codeReload1).isBlackBoxed, false, "code_reload_1.js is not blackboxed");
info("All sources are unblackboxed and the debugger pauses on line 2.");
invokeInTab("computeSomething");
@ -80,21 +73,28 @@ add_task(async function() {
info("Blackbox files in this group.");
rightClickEl(dbg, sourceTreeRootNodeEl);
await assertContextMenuLabel(dbg, nodeSelectors.nodeBlackBoxAllInside, "Blackbox files in this group");
selectContextMenuItem(dbg, nodeSelectors.nodeBlackBoxAllInside);
await assertContextMenuLabel(dbg, NODE_SELECTORS.nodeBlackBoxAllInside, "Blackbox files in this group");
selectContextMenuItem(dbg, NODE_SELECTORS.nodeBlackBoxAllInside);
await waitForBlackboxCount(dbg, 2);
await waitForRequestsToSettle(dbg);
is(findSource(dbg, sourceFiles.nestedSource).isBlackBoxed, true, "nested-source.js is blackboxed");
is(findSource(dbg, sourceFiles.codeReload1).isBlackBoxed, true, "code_reload_1.js is blackboxed");
is(findSource(dbg, SOURCE_FILES.nestedSource).isBlackBoxed, true, "nested-source.js is blackboxed");
is(findSource(dbg, SOURCE_FILES.codeReload1).isBlackBoxed, true, "code_reload_1.js is blackboxed");
info("Unblackbox files in this group.");
rightClickEl(dbg, sourceTreeRootNodeEl);
await assertContextMenuLabel(dbg, nodeSelectors.nodeUnBlackBoxAllInside, "Unblackbox files in this group");
selectContextMenuItem(dbg, nodeSelectors.nodeUnBlackBoxAllInside);
await assertContextMenuLabel(dbg, NODE_SELECTORS.nodeUnBlackBoxAllInside, "Unblackbox files in this group");
selectContextMenuItem(dbg, NODE_SELECTORS.nodeUnBlackBoxAllInside);
await waitForBlackboxCount(dbg, 0);
await waitForRequestsToSettle(dbg);
is(findSource(dbg, sourceFiles.nestedSource).isBlackBoxed, false, "nested-source.js is not blackboxed");
is(findSource(dbg, sourceFiles.codeReload1).isBlackBoxed, false, "code_reload_1.js is not blackboxed");
});
is(findSource(dbg, SOURCE_FILES.nestedSource).isBlackBoxed, false, "nested-source.js is not blackboxed");
is(findSource(dbg, SOURCE_FILES.codeReload1).isBlackBoxed, false, "code_reload_1.js is not blackboxed");
});
function waitForBlackboxCount(dbg, count) {
return waitForState(
dbg,
state => dbg.selectors.getBlackBoxList().length === count
);
}

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// This source map does not have source contents, so it's fetched separately
add_task(async function() {

View File

@ -1,14 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests that `debugger` statements are hit before the debugger even
// initializes and it properly highlights the right location in the
// debugger.
async function waitOnToolbox(toolbox, event) {
return new Promise(resolve => toolbox.on(event, resolve));
}
add_task(async function() {
const url = EXAMPLE_URL + "doc-script-switching.html";
const toolbox = await openNewTabAndToolbox(url, "webconsole");
@ -29,3 +26,7 @@ add_task(async function() {
is(getCM(dbg).getValue(), "debugger");
assertPausedLocation(dbg);
});
async function waitOnToolbox(toolbox, event) {
return new Promise(resolve => toolbox.on(event, resolve));
}

View File

@ -2,24 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
function skipPausing(dbg) {
clickElementWithSelector(dbg, ".command-bar-skip-pausing");
return waitForState(dbg, state => dbg.selectors.getSkipPausing());
}
function toggleBreakpoint(dbg, index) {
const breakpoints = findAllElements(dbg, "breakpointItems");
const bp = breakpoints[index];
const input = bp.querySelector("input");
input.click();
}
async function disableBreakpoint(dbg, index) {
const disabled = waitForDispatch(dbg, "SET_BREAKPOINT");
toggleBreakpoint(dbg, index);
await disabled;
}
/*
* Tests toggling the skip pausing button and
* invoking functions without pausing.
@ -83,3 +65,21 @@ add_task(async function() {
resume(dbg);
ok(true, "Breakpoint is hit after a breakpoint was removed");
});
function skipPausing(dbg) {
clickElementWithSelector(dbg, ".command-bar-skip-pausing");
return waitForState(dbg, state => dbg.selectors.getSkipPausing());
}
function toggleBreakpoint(dbg, index) {
const breakpoints = findAllElements(dbg, "breakpointItems");
const bp = breakpoints[index];
const input = bp.querySelector("input");
input.click();
}
async function disableBreakpoint(dbg, index) {
const disabled = waitForDispatch(dbg, "SET_BREAKPOINT");
toggleBreakpoint(dbg, index);
await disabled;
}

View File

@ -2,10 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
function openFirstBreakpointContextMenu(dbg) {
rightClickElement(dbg, "breakpointItem", 2);
}
// Tests to see if we can trigger a breakpoint action via the context menu
add_task(async function() {
const dbg = await initDebugger("doc-scripts.html", "simple2");
@ -84,3 +80,7 @@ add_task(async function() {
await dispatched;
ok(true, "remaining breakpoint should be on line 4");
});
function openFirstBreakpointContextMenu(dbg) {
rightClickElement(dbg, "breakpointItem", 2);
}

View File

@ -2,6 +2,41 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
add_task(async function() {
const dbg = await initDebugger("doc-scripts.html", "simple1");
await selectSource(dbg, "long");
info("1. Add a column breakpoint on line 32");
await enableFirstBreakpoint(dbg);
info("2. Click on the second breakpoint on line 32");
await enableSecondBreakpoint(dbg);
info("3. Disable second breakpoint using shift-click");
await shiftClickDisable(dbg);
info("4. Re-enable second breakpoint using shift-click");
await shiftClickEnable(dbg);
info("5. Add a condition to the first breakpoint");
await setConditionalBreakpoint(dbg, 0, "foo");
info("6. Add a log to the first breakpoint");
await setLogPoint(dbg, 0, "bar");
info("7. Disable the first breakpoint");
await disableBreakpoint(dbg, 0);
info("8. Remove the first breakpoint");
await removeFirstBreakpoint(dbg);
info("9. Add a condition to the second breakpoint");
await setConditionalBreakpoint(dbg, 1, "foo2");
info("10. Test removing the breakpoints by clicking in the gutter");
await removeAllBreakpoints(dbg, 32, 0);
});
async function enableFirstBreakpoint(dbg) {
getCM(dbg).setCursor({ line: 32, ch: 0 });
await addBreakpoint(dbg, "long", 32);
@ -89,38 +124,3 @@ async function removeAllBreakpoints(dbg, line, count) {
ok(findAllElements(dbg, "columnBreakpoints").length == 0);
}
add_task(async function() {
const dbg = await initDebugger("doc-scripts.html", "simple1");
await selectSource(dbg, "long");
info("1. Add a column breakpoint on line 32");
await enableFirstBreakpoint(dbg);
info("2. Click on the second breakpoint on line 32");
await enableSecondBreakpoint(dbg);
info("3. Disable second breakpoint using shift-click");
await shiftClickDisable(dbg);
info("4. Re-enable second breakpoint using shift-click");
await shiftClickEnable(dbg);
info("5. Add a condition to the first breakpoint");
await setConditionalBreakpoint(dbg, 0, "foo");
info("6. Add a log to the first breakpoint");
await setLogPoint(dbg, 0, "bar");
info("7. Disable the first breakpoint");
await disableBreakpoint(dbg, 0);
info("8. Remove the first breakpoint");
await removeFirstBreakpoint(dbg);
info("9. Add a condition to the second breakpoint");
await setConditionalBreakpoint(dbg, 1, "foo2");
info("10. Test removing the breakpoints by clicking in the gutter");
await removeAllBreakpoints(dbg, 32, 0);
});

View File

@ -5,45 +5,6 @@
// Test opening conditional panel using keyboard shortcut.
// Should access the closest breakpoint to a passed in cursorPosition.
// from test/mochitest/browser_dbg-breakpoints-cond-source-maps.js
function getConditionalPanel(dbg, line) {
return getCM(dbg).doc.getLineHandle(line - 1).widgets[0];
}
// from devtools browser_dbg-breakpoints-cond-source-maps.js
async function waitForConditionalPanelFocus(dbg) {
await waitFor(() => dbg.win.document.activeElement.tagName === "TEXTAREA");
}
// from browser_dbg-breakpoints-columns.js
async function enableFirstBreakpoint(dbg) {
getCM(dbg).setCursor({ line: 32, ch: 0 });
await addBreakpoint(dbg, "long", 32);
const bpMarkers = await waitForAllElements(dbg, "columnBreakpoints");
ok(bpMarkers.length === 2, "2 column breakpoints");
assertClass(bpMarkers[0], "active");
assertClass(bpMarkers[1], "active", false);
}
async function enableSecondBreakpoint(dbg) {
let bpMarkers = await waitForAllElements(dbg, "columnBreakpoints");
bpMarkers[1].click();
await waitForBreakpointCount(dbg, 2);
bpMarkers = findAllElements(dbg, "columnBreakpoints");
assertClass(bpMarkers[1], "active");
await waitForAllElements(dbg, "breakpointItems", 2);
}
// modified method from browser_dbg-breakpoints-columns.js
// use shortcut to open conditional panel.
function setConditionalBreakpoint(dbg, condition) {
pressKey(dbg, "toggleCondPanel");
typeInPanel(dbg, condition);
}
add_task(async function() {
const dbg = await initDebugger("doc-scripts.html", "long");
@ -124,5 +85,43 @@ add_task(async function() {
!! waitForCondition(dbg, "13"),
"breakpoint closest to cursor position has been edited"
);
});
// from test/mochitest/browser_dbg-breakpoints-cond-source-maps.js
function getConditionalPanel(dbg, line) {
return getCM(dbg).doc.getLineHandle(line - 1).widgets[0];
}
// from devtools browser_dbg-breakpoints-cond-source-maps.js
async function waitForConditionalPanelFocus(dbg) {
await waitFor(() => dbg.win.document.activeElement.tagName === "TEXTAREA");
}
// from browser_dbg-breakpoints-columns.js
async function enableFirstBreakpoint(dbg) {
getCM(dbg).setCursor({ line: 32, ch: 0 });
await addBreakpoint(dbg, "long", 32);
const bpMarkers = await waitForAllElements(dbg, "columnBreakpoints");
ok(bpMarkers.length === 2, "2 column breakpoints");
assertClass(bpMarkers[0], "active");
assertClass(bpMarkers[1], "active", false);
}
async function enableSecondBreakpoint(dbg) {
let bpMarkers = await waitForAllElements(dbg, "columnBreakpoints");
bpMarkers[1].click();
await waitForBreakpointCount(dbg, 2);
bpMarkers = findAllElements(dbg, "columnBreakpoints");
assertClass(bpMarkers[1], "active");
await waitForAllElements(dbg, "breakpointItems", 2);
}
// modified method from browser_dbg-breakpoints-columns.js
// use shortcut to open conditional panel.
function setConditionalBreakpoint(dbg, condition) {
pressKey(dbg, "toggleCondPanel");
typeInPanel(dbg, condition);
}

View File

@ -2,23 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
async function setLogPoint(dbg, index) {
const gutterEl = await getEditorLineGutter(dbg, index);
rightClickEl(dbg, gutterEl);
selectContextMenuItem(
dbg,
`${selectors.addLogItem},${selectors.editLogItem}`
);
}
async function waitForConditionalPanelFocus(dbg) {
await waitFor(() => dbg.win.document.activeElement.tagName === "TEXTAREA");
}
function getConditionalPanel(dbg, line) {
return getCM(dbg).doc.getLineHandle(line - 1).widgets[0];
}
// Confirms that a conditional panel is opened at the
// correct location in generated files.
add_task(async function() {
@ -39,3 +22,20 @@ add_task(async function() {
"conditional panel location is line 55"
);
});
async function setLogPoint(dbg, index) {
const gutterEl = await getEditorLineGutter(dbg, index);
rightClickEl(dbg, gutterEl);
selectContextMenuItem(
dbg,
`${selectors.addLogItem},${selectors.editLogItem}`
);
}
async function waitForConditionalPanelFocus(dbg) {
await waitFor(() => dbg.win.document.activeElement.tagName === "TEXTAREA");
}
function getConditionalPanel(dbg, line) {
return getCM(dbg).doc.getLineHandle(line - 1).widgets[0];
}

View File

@ -2,64 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
function getLineEl(dbg, line) {
const lines = dbg.win.document.querySelectorAll(".CodeMirror-code > div");
return lines[line - 1];
}
function assertEditorBreakpoint(
dbg,
line,
{ hasCondition = false, hasLog = false } = {}
) {
const hasConditionClass = getLineEl(dbg, line).classList.contains(
"has-condition"
);
ok(
hasConditionClass === hasCondition,
`Breakpoint condition ${
hasCondition ? "exists" : "does not exist"
} on line ${line}`
);
const hasLogClass = getLineEl(dbg, line).classList.contains("has-log");
ok(
hasLogClass === hasLog,
`Breakpoint log ${hasLog ? "exists" : "does not exist"} on line ${line}`
);
}
function waitForBreakpointWithoutCondition(dbg, url, line) {
return waitForState(dbg, () => {
const bp = findBreakpoint(dbg, url, line);
return bp && !bp.options.condition;
});
}
async function setConditionalBreakpoint(dbg, index, condition) {
// Make this work with either add or edit menu items
const { addConditionItem, editConditionItem } = selectors;
const selector = `${addConditionItem},${editConditionItem}`;
rightClickElement(dbg, "gutter", index);
selectContextMenuItem(dbg, selector);
typeInPanel(dbg, condition);
}
async function setLogPoint(dbg, index, value) {
rightClickElement(dbg, "gutter", index);
selectContextMenuItem(
dbg,
`${selectors.addLogItem},${selectors.editLogItem}`
);
await typeInPanel(dbg, value);
}
async function waitForConditionalPanelFocus(dbg) {
await waitFor(() => dbg.win.document.activeElement.tagName === "TEXTAREA");
}
add_task(async function() {
const dbg = await initDebugger("doc-scripts.html", "simple2");
await pushPref("devtools.debugger.features.column-breakpoints", true);
@ -167,3 +109,61 @@ add_task(async function() {
const logPointPanel = findElement(dbg, "logPointPanel");
is(logPointPanel, null, "The logpoint panel is closed");
});
function getLineEl(dbg, line) {
const lines = dbg.win.document.querySelectorAll(".CodeMirror-code > div");
return lines[line - 1];
}
function assertEditorBreakpoint(
dbg,
line,
{ hasCondition = false, hasLog = false } = {}
) {
const hasConditionClass = getLineEl(dbg, line).classList.contains(
"has-condition"
);
ok(
hasConditionClass === hasCondition,
`Breakpoint condition ${
hasCondition ? "exists" : "does not exist"
} on line ${line}`
);
const hasLogClass = getLineEl(dbg, line).classList.contains("has-log");
ok(
hasLogClass === hasLog,
`Breakpoint log ${hasLog ? "exists" : "does not exist"} on line ${line}`
);
}
function waitForBreakpointWithoutCondition(dbg, url, line) {
return waitForState(dbg, () => {
const bp = findBreakpoint(dbg, url, line);
return bp && !bp.options.condition;
});
}
async function setConditionalBreakpoint(dbg, index, condition) {
// Make this work with either add or edit menu items
const { addConditionItem, editConditionItem } = selectors;
const selector = `${addConditionItem},${editConditionItem}`;
rightClickElement(dbg, "gutter", index);
selectContextMenuItem(dbg, selector);
typeInPanel(dbg, condition);
}
async function setLogPoint(dbg, index, value) {
rightClickElement(dbg, "gutter", index);
selectContextMenuItem(
dbg,
`${selectors.addLogItem},${selectors.editLogItem}`
);
await typeInPanel(dbg, value);
}
async function waitForConditionalPanelFocus(dbg) {
await waitFor(() => dbg.win.document.activeElement.tagName === "TEXTAREA");
}

View File

@ -2,10 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
function firstBreakpoint(dbg) {
return dbg.selectors.getBreakpointsList()[0];
}
// tests to make sure we do not accidentally slide the breakpoint up to the first
// function with the same name in the file.
add_task(async function() {
@ -20,5 +16,7 @@ add_task(async function() {
await reload(dbg, source.url);
await waitForState(dbg, state => dbg.selectors.getBreakpointCount() == 1);
is(firstBreakpoint(dbg).location.line, 19, "Breakpoint is on line 19");
const firstBreakpoint = dbg.selectors.getBreakpointsList()[0];
is(firstBreakpoint.location.line, 19, "Breakpoint is on line 19");
});

View File

@ -5,29 +5,6 @@
// Tests pending breakpoints when reloading
requestLongerTimeout(3);
// Utilities for interacting with the editor
function clickGutter(dbg, line) {
clickElement(dbg, "gutter", line);
}
function getLineEl(dbg, line) {
const lines = dbg.win.document.querySelectorAll(".CodeMirror-code > div");
return lines[line - 1];
}
function addBreakpointViaGutter(dbg, line) {
clickGutter(dbg, line);
return waitForDispatch(dbg, "SET_BREAKPOINT");
}
async function assertEditorBreakpoint(dbg, line) {
await waitUntil(() => {
const lineEl = getLineEl(dbg, line);
return lineEl.classList.contains("new-breakpoint");
});
ok(true, `Breakpoint exists on line ${line}`);
}
add_task(async function() {
const dbg = await initDebugger("doc-scripts.html", "simple1.js");
const source = findSource(dbg, "simple1.js");
@ -70,3 +47,26 @@ add_task(async function() {
assertPausedAtSourceAndLine(dbg, source.id, 27);
await assertEditorBreakpoint(dbg, 27);
});
// Utilities for interacting with the editor
function clickGutter(dbg, line) {
clickElement(dbg, "gutter", line);
}
function getLineEl(dbg, line) {
const lines = dbg.win.document.querySelectorAll(".CodeMirror-code > div");
return lines[line - 1];
}
function addBreakpointViaGutter(dbg, line) {
clickGutter(dbg, line);
return waitForDispatch(dbg, "SET_BREAKPOINT");
}
async function assertEditorBreakpoint(dbg, line) {
await waitUntil(() => {
const lineEl = getLineEl(dbg, line);
return lineEl.classList.contains("new-breakpoint");
});
ok(true, `Breakpoint exists on line ${line}`);
}

View File

@ -2,31 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
function toggleBreakpoint(dbg, index) {
const bp = findAllElements(dbg, "breakpointItems")[index];
const input = bp.querySelector("input");
input.click();
}
async function disableBreakpoint(dbg, index) {
const disabled = waitForDispatch(dbg, "SET_BREAKPOINT");
toggleBreakpoint(dbg, index);
await disabled;
}
async function enableBreakpoint(dbg, index) {
const enabled = waitForDispatch(dbg, "SET_BREAKPOINT");
toggleBreakpoint(dbg, index);
await enabled;
}
async function cleanupBreakpoints(dbg) {
clickElement(dbg, "gutter", 3);
clickElement(dbg, "gutter", 5);
await waitForBreakpointRemoved(dbg, "simple2", 3);
await waitForBreakpointRemoved(dbg, "simple2", 5);
}
// Test enabling and disabling a breakpoint using the check boxes
add_task(async function() {
const dbg = await initDebugger("doc-scripts.html", "simple2");
@ -93,3 +68,28 @@ add_task(async function() {
// Cleanup
await cleanupBreakpoints(dbg);
});
function toggleBreakpoint(dbg, index) {
const bp = findAllElements(dbg, "breakpointItems")[index];
const input = bp.querySelector("input");
input.click();
}
async function disableBreakpoint(dbg, index) {
const disabled = waitForDispatch(dbg, "SET_BREAKPOINT");
toggleBreakpoint(dbg, index);
await disabled;
}
async function enableBreakpoint(dbg, index) {
const enabled = waitForDispatch(dbg, "SET_BREAKPOINT");
toggleBreakpoint(dbg, index);
await enabled;
}
async function cleanupBreakpoints(dbg) {
clickElement(dbg, "gutter", 3);
clickElement(dbg, "gutter", 5);
await waitForBreakpointRemoved(dbg, "simple2", 3);
await waitForBreakpointRemoved(dbg, "simple2", 5);
}

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
"use strict";
@ -11,24 +12,6 @@ const {
gDevToolsBrowser
} = require("devtools/client/framework/devtools-browser");
function toggleBreakpoint(dbg, index) {
const bp = findAllElements(dbg, "breakpointItems")[index];
const input = bp.querySelector("input");
input.click();
}
async function disableBreakpoint(dbg, index) {
const disabled = waitForDispatch(dbg, "SET_BREAKPOINT");
toggleBreakpoint(dbg, index);
await disabled;
}
async function enableBreakpoint(dbg, index) {
const enabled = waitForDispatch(dbg, "SET_BREAKPOINT");
toggleBreakpoint(dbg, index);
await enabled;
}
add_task(async function() {
clearDebuggerPreferences();
@ -65,3 +48,21 @@ add_task(async function() {
info("Toolbox is destroyed");
});
function toggleBreakpoint(dbg, index) {
const bp = findAllElements(dbg, "breakpointItems")[index];
const input = bp.querySelector("input");
input.click();
}
async function disableBreakpoint(dbg, index) {
const disabled = waitForDispatch(dbg, "SET_BREAKPOINT");
toggleBreakpoint(dbg, index);
await disabled;
}
async function enableBreakpoint(dbg, index) {
const enabled = waitForDispatch(dbg, "SET_BREAKPOINT");
toggleBreakpoint(dbg, index);
await enabled;
}

View File

@ -5,66 +5,6 @@
// Ignore strange errors when shutting down.
PromiseTestUtils.whitelistRejectionsGlobally(/No such actor/);
// checks to see if the frame is selected and the title is correct
function isFrameSelected(dbg, index, title) {
const $frame = findElement(dbg, "frame", index);
const {
selectors: { getSelectedFrame, getCurrentThread },
getState,
} = dbg;
const frame = getSelectedFrame(getCurrentThread());
const elSelected = $frame.classList.contains("selected");
const titleSelected = frame.displayName == title;
return elSelected && titleSelected;
}
function toggleButton(dbg) {
const callStackBody = findElement(dbg, "callStackBody");
return callStackBody.querySelector(".show-more");
}
// Create an HTTP server to simulate an angular app with anonymous functions
// and return the URL.
function createMockAngularPage() {
const httpServer = createTestHTTPServer();
httpServer.registerContentType("html", "text/html");
httpServer.registerContentType("js", "application/javascript");
const htmlFilename = "angular-mock.html";
httpServer.registerPathHandler(`/${htmlFilename}`, function(
request,
response
) {
response.setStatusLine(request.httpVersion, 200, "OK");
response.write(`
<html>
<button class="pause">Click me</button>
<script type="text/javascript" src="angular.js"></script>
</html>`);
});
// Register an angular.js file in order to create a Group with anonymous functions in
// the callstack panel.
httpServer.registerPathHandler("/angular.js", function(request, response) {
response.setHeader("Content-Type", "application/javascript");
response.write(`
document.querySelector("button.pause").addEventListener("click", () => {
(function() {
debugger;
})();
})
`);
});
const port = httpServer.identity.primaryPort;
return `http://localhost:${port}/${htmlFilename}`;
}
add_task(async function() {
const dbg = await initDebugger("doc-script-switching.html");
@ -128,3 +68,63 @@ add_task(async function() {
"Group has expected location"
);
});
// checks to see if the frame is selected and the title is correct
function isFrameSelected(dbg, index, title) {
const $frame = findElement(dbg, "frame", index);
const {
selectors: { getSelectedFrame, getCurrentThread },
getState,
} = dbg;
const frame = getSelectedFrame(getCurrentThread());
const elSelected = $frame.classList.contains("selected");
const titleSelected = frame.displayName == title;
return elSelected && titleSelected;
}
function toggleButton(dbg) {
const callStackBody = findElement(dbg, "callStackBody");
return callStackBody.querySelector(".show-more");
}
// Create an HTTP server to simulate an angular app with anonymous functions
// and return the URL.
function createMockAngularPage() {
const httpServer = createTestHTTPServer();
httpServer.registerContentType("html", "text/html");
httpServer.registerContentType("js", "application/javascript");
const htmlFilename = "angular-mock.html";
httpServer.registerPathHandler(`/${htmlFilename}`, function(
request,
response
) {
response.setStatusLine(request.httpVersion, 200, "OK");
response.write(`
<html>
<button class="pause">Click me</button>
<script type="text/javascript" src="angular.js"></script>
</html>`);
});
// Register an angular.js file in order to create a Group with anonymous functions in
// the callstack panel.
httpServer.registerPathHandler("/angular.js", function(request, response) {
response.setHeader("Content-Type", "application/javascript");
response.write(`
document.querySelector("button.pause").addEventListener("click", () => {
(function() {
debugger;
})();
})
`);
});
const port = httpServer.identity.primaryPort;
return `http://localhost:${port}/${htmlFilename}`;
}

View File

@ -1,5 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
/**
* Tests that a chrome debugger can be created in a new process.
@ -15,34 +17,6 @@ requestLongerTimeout(5);
const { BrowserToolboxLauncher } = ChromeUtils.import("resource://devtools/client/framework/browser-toolbox/Launcher.jsm");
let gProcess = undefined;
function initChromeDebugger() {
info("Initializing a chrome debugger process.");
return new Promise(resolve => {
BrowserToolboxLauncher.init(onClose, _process => {
info("Browser toolbox process started successfully.");
resolve(_process);
});
});
}
function onClose() {
is(
gProcess._dbgProcess.exitCode,
Services.appinfo.OS == "WINNT" ? -9 : -15,
"The remote debugger process didn't die cleanly."
);
info("process exit value: " + gProcess._dbgProcess.exitCode);
info("profile path: " + gProcess._dbgProfilePath);
finish();
}
registerCleanupFunction(function() {
gProcess = null;
});
add_task(async function() {
// Windows XP and 8.1 test slaves are terribly slow at this test.
await pushPref("devtools.chrome.enabled", true);
@ -84,3 +58,31 @@ add_task(async function() {
await gProcess.close();
});
function initChromeDebugger() {
info("Initializing a chrome debugger process.");
return new Promise(resolve => {
BrowserToolboxLauncher.init(onClose, _process => {
info("Browser toolbox process started successfully.");
resolve(_process);
});
});
}
function onClose() {
is(
gProcess._dbgProcess.exitCode,
Services.appinfo.OS == "WINNT" ? -9 : -15,
"The remote debugger process didn't die cleanly."
);
info("process exit value: " + gProcess._dbgProcess.exitCode);
info("profile path: " + gProcess._dbgProfilePath);
finish();
}
registerCleanupFunction(function() {
gProcess = null;
});

View File

@ -1,19 +1,48 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
/**
* Tests that chrome debugging works.
*/
var gClient, gThreadFront;
var gNewChromeSource = promise.defer();
let gClient, gThreadFront;
let gNewChromeSource = promise.defer();
var { DevToolsLoader } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
var customLoader = new DevToolsLoader({
let { DevToolsLoader } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
let customLoader = new DevToolsLoader({
invisibleToDebugger: true,
});
var { DevToolsServer } = customLoader.require("devtools/server/devtools-server");
var { DevToolsClient } = require("devtools/client/devtools-client");
let { DevToolsServer } = customLoader.require("devtools/server/devtools-server");
let { DevToolsClient } = require("devtools/client/devtools-client");
add_task(async function() {
gClient = initDevToolsClient();
const [type] = await gClient.connect();
is(type, "browser", "Root actor should identify itself as a browser.");
const descriptorFront = await gClient.mainRoot.getMainProcess();
const front = await descriptorFront.getTarget();
await front.attach();
const threadFront = await front.attachThread();
gThreadFront = threadFront;
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:mozilla");
// listen for a new source and global
gThreadFront.on("newSource", onNewSource);
// Force the creation of a new privileged source
const systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].createInstance(
Ci.nsIPrincipal
);
const sandbox = Cu.Sandbox(systemPrincipal);
Cu.evalInSandbox("function foo() {}", sandbox, null, "http://foo.com");
await gNewChromeSource.promise;
await resumeAndCloseConnection();
});
function initDevToolsClient() {
DevToolsServer.init();
@ -45,31 +74,3 @@ registerCleanupFunction(function() {
customLoader = null;
DevToolsServer = null;
});
add_task(async function() {
gClient = initDevToolsClient();
const [type] = await gClient.connect();
is(type, "browser", "Root actor should identify itself as a browser.");
const descriptorFront = await gClient.mainRoot.getMainProcess();
const front = await descriptorFront.getTarget();
await front.attach();
const threadFront = await front.attachThread();
gThreadFront = threadFront;
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:mozilla");
// listen for a new source and global
gThreadFront.on("newSource", onNewSource);
// Force the creation of a new privileged source
const systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].createInstance(
Ci.nsIPrincipal
);
const sandbox = Cu.Sandbox(systemPrincipal);
Cu.evalInSandbox("function foo() {}", sandbox, null, "http://foo.com");
await gNewChromeSource.promise;
await resumeAndCloseConnection();
});

View File

@ -2,20 +2,6 @@
// console if necessary. This cleans up the split console pref so
// it won't pollute other tests.
function findMessages(win, query) {
return Array.prototype.filter.call(
win.document.querySelectorAll(".message"),
e => e.innerText.includes(query)
);
}
async function hasMessage(dbg, msg) {
const webConsole = await dbg.toolbox.getPanel("webconsole");
return waitFor(
async () => findMessages(webConsole._frameWindow, msg).length > 0
);
}
add_task(async function() {
Services.prefs.setBoolPref("devtools.toolbox.splitconsoleEnabled", true);
Services.prefs.setBoolPref(
@ -45,3 +31,17 @@ add_task(async function() {
wrapper.dispatchEvaluateExpression(`await sleep(200, "DONE")`);
await hasMessage(dbg, "DONE!!!");
});
function findMessages(win, query) {
return Array.prototype.filter.call(
win.document.querySelectorAll(".message"),
e => e.innerText.includes(query)
);
}
async function hasMessage(dbg, msg) {
const webConsole = await dbg.toolbox.getPanel("webconsole");
return waitFor(
async () => findMessages(webConsole._frameWindow, msg).length > 0
);
}

View File

@ -5,17 +5,6 @@
// Tests that clicking the DOM node button in any ObjectInspect
// opens the Inspector panel
function waitForConsolePanelChange(dbg) {
const { toolbox } = dbg;
return new Promise(resolve => {
toolbox.getPanelWhenReady("webconsole").then(() => {
ok(toolbox.webconsolePanel, "Console is shown.");
resolve(toolbox.webconsolePanel);
});
});
}
add_task(async function() {
const dbg = await initDebugger("doc-scripts.html", "simple2");
@ -32,3 +21,14 @@ add_task(async function() {
await waitForConsolePanelChange(dbg);
await hasConsoleMessage(dbg, "undefined");
});
function waitForConsolePanelChange(dbg) {
const { toolbox } = dbg;
return new Promise(resolve => {
toolbox.getPanelWhenReady("webconsole").then(() => {
ok(toolbox.webconsolePanel, "Console is shown.");
resolve(toolbox.webconsolePanel);
});
});
}

View File

@ -1,17 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
"use strict";
// Tests opening the console first, clicking a link
// opens the editor at the correct location.
async function waitForLink(toolbox) {
const { hud } = toolbox.getPanel("webconsole");
return waitFor(() => hud.ui.outputNode.querySelector(".frame-link-source"));
}
add_task(async function() {
const toolbox = await initPane("doc-script-switching.html", "webconsole");
const node = await waitForLink(toolbox);
@ -22,3 +17,9 @@ add_task(async function() {
await waitForElementWithSelector(dbg, ".CodeMirror-code > .highlight-line");
assertHighlightLocation(dbg, "script-switching-02", 14);
});
async function waitForLink(toolbox) {
const { hud } = toolbox.getPanel("webconsole");
return waitFor(() => hud.ui.outputNode.querySelector(".frame-link-source"));
}

View File

@ -1,3 +1,23 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
add_task(async function() {
Services.prefs.setBoolPref("devtools.toolbox.splitconsoleEnabled", true);
const dbg = await initDebugger("doc-strict.html");
await getSplitConsole(dbg);
ok(dbg.toolbox.splitConsole, "Split console is shown.");
invokeInTab("strict", 2);
await waitForPaused(dbg);
await evaluate(dbg, "var c = 3");
const msg2 = await evaluate(dbg, "c");
is(msg2.trim(), "3");
});
// Return a promise with a reference to jsterm, opening the split
// console if necessary. This cleans up the split console pref so
// it won't pollute other tests.
@ -26,20 +46,4 @@ async function evaluate(dbg, expression) {
const { hud } = toolbox.getPanel("webconsole");
const msg = await evaluateExpressionInConsole(hud, expression);
return msg.innerText;
}
add_task(async function() {
Services.prefs.setBoolPref("devtools.toolbox.splitconsoleEnabled", true);
const dbg = await initDebugger("doc-strict.html");
await getSplitConsole(dbg);
ok(dbg.toolbox.splitConsole, "Split console is shown.");
invokeInTab("strict", 2);
await waitForPaused(dbg);
await evaluate(dbg, "var c = 3");
const msg2 = await evaluate(dbg, "c");
is(msg2.trim(), "3");
});
}

View File

@ -1,49 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
"use strict";
// Tests that the content scripts are listed in the source tree.
async function selectContentScriptSources(dbg) {
await waitForSources(dbg, "content_script.js");
// Select a source.
await selectSource(dbg, "content_script.js");
ok(
findElementWithSelector(dbg, ".sources-list .focused"),
"Source is focused"
);
}
async function installAndStartExtension() {
function contentScript() {
console.log("content script loads");
// This listener prevents the source from being garbage collected
// and be missing from the scripts returned by `dbg.findScripts()`
// in `ThreadActor._discoverSources`.
window.onload = () => {};
}
let extension = ExtensionTestUtils.loadExtension({
manifest: {
content_scripts: [
{
js: ["content_script.js"],
matches: ["http://example.com/*"],
run_at: "document_start"
}
]
},
files: {
"content_script.js": contentScript
}
});
await extension.startup();
return extension;
}
add_task(async function() {
await pushPref("devtools.chrome.enabled", true);
const extension = await installAndStartExtension();
@ -86,3 +48,45 @@ add_task(async function() {
await extension.unload();
});
async function selectContentScriptSources(dbg) {
await waitForSources(dbg, "content_script.js");
// Select a source.
await selectSource(dbg, "content_script.js");
ok(
findElementWithSelector(dbg, ".sources-list .focused"),
"Source is focused"
);
}
async function installAndStartExtension() {
function contentScript() {
console.log("content script loads");
// This listener prevents the source from being garbage collected
// and be missing from the scripts returned by `dbg.findScripts()`
// in `ThreadActor._discoverSources`.
window.onload = () => {};
}
let extension = ExtensionTestUtils.loadExtension({
manifest: {
content_scripts: [
{
js: ["content_script.js"],
matches: ["http://example.com/*"],
run_at: "document_start"
}
]
},
files: {
"content_script.js": contentScript
}
});
await extension.startup();
return extension;
}

View File

@ -2,10 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
async function cmdClickLine(dbg, line) {
await cmdClickGutter(dbg, line);
}
add_task(async function() {
const dbg = await initDebugger("doc-pause-points.html", "pause-points.js");
await selectSource(dbg, "pause-points.js");
@ -21,3 +17,7 @@ add_task(async function() {
await resume(dbg);
await waitForRequestsToSettle(dbg);
});
async function cmdClickLine(dbg, line) {
await cmdClickGutter(dbg, line);
}

View File

@ -2,23 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
async function continueToLine(dbg, line) {
rightClickElement(dbg, "gutter", line);
selectContextMenuItem(dbg, selectors.editorContextMenu.continueToHere);
await waitForDispatch(dbg, "RESUME");
await waitForPaused(dbg);
await waitForInlinePreviews(dbg);
}
async function continueToColumn(dbg, pos) {
await rightClickAtPos(dbg, pos);
selectContextMenuItem(dbg, selectors.editorContextMenu.continueToHere);
await waitForDispatch(dbg, "RESUME");
await waitForPaused(dbg);
await waitForInlinePreviews(dbg);
}
add_task(async function() {
const dbg = await initDebugger("doc-pause-points.html", "pause-points.js");
await selectSource(dbg, "pause-points.js");
@ -42,3 +25,20 @@ add_task(async function() {
assertDebugLine(dbg, 31, 4);
await resume(dbg);
});
async function continueToLine(dbg, line) {
rightClickElement(dbg, "gutter", line);
selectContextMenuItem(dbg, selectors.editorContextMenu.continueToHere);
await waitForDispatch(dbg, "RESUME");
await waitForPaused(dbg);
await waitForInlinePreviews(dbg);
}
async function continueToColumn(dbg, pos) {
await rightClickAtPos(dbg, pos);
selectContextMenuItem(dbg, selectors.editorContextMenu.continueToHere);
await waitForDispatch(dbg, "RESUME");
await waitForPaused(dbg);
await waitForInlinePreviews(dbg);
}

View File

@ -2,31 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
function clickButton(dbg, button) {
const resumeFired = waitForDispatch(dbg, "COMMAND");
clickElement(dbg, button);
return resumeFired;
}
async function clickStepOver(dbg) {
await clickButton(dbg, "stepOver");
return waitForPaused(dbg);
}
async function clickStepIn(dbg) {
await clickButton(dbg, "stepIn");
return waitForPaused(dbg);
}
async function clickStepOut(dbg) {
await clickButton(dbg, "stepOut");
return waitForPaused(dbg);
}
async function clickResume(dbg) {
return clickButton(dbg, "resume");
}
/**
* Test debugger buttons
* 1. resume
@ -64,3 +39,28 @@ add_task(async function() {
await clickStepOut(dbg);
assertPausedLocation(dbg);
});
function clickButton(dbg, button) {
const resumeFired = waitForDispatch(dbg, "COMMAND");
clickElement(dbg, button);
return resumeFired;
}
async function clickStepOver(dbg) {
await clickButton(dbg, "stepOver");
return waitForPaused(dbg);
}
async function clickStepIn(dbg) {
await clickButton(dbg, "stepIn");
return waitForPaused(dbg);
}
async function clickStepOut(dbg) {
await clickButton(dbg, "stepOut");
return waitForPaused(dbg);
}
async function clickResume(dbg) {
return clickButton(dbg, "resume");
}

View File

@ -9,11 +9,6 @@
// rejections and make bug 1512742 permafail.
PromiseTestUtils.whitelistRejectionsGlobally(/NS_ERROR_NOT_INITIALIZED/);
// Utilities for interacting with the editor
function clickGutter(dbg, line) {
clickElement(dbg, "gutter", line);
}
add_task(async function() {
const dbg = await initDebugger("doc-scripts.html", "simple1.js");
const { getState } = dbg;
@ -67,3 +62,8 @@ add_task(async function() {
await waitForPaused(dbg);
ok(true, "source is un-blackboxed");
});
// Utilities for interacting with the editor
function clickGutter(dbg, line) {
clickElement(dbg, "gutter", line);
}

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests that the editor sets the correct mode for different file
// types

View File

@ -2,17 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
function assertPauseLocation(dbg, line) {
const { location } = dbg.selectors.getVisibleSelectedFrame();
const source = findSource(dbg, "event-breakpoints.js");
is(location.sourceId, source.id, `correct sourceId`);
is(location.line, line, `correct line`);
assertPausedLocation(dbg);
}
add_task(async function() {
await pushPref(
"devtools.debugger.features.event-listeners-breakpoints",
@ -69,3 +58,14 @@ add_task(async function() {
await clickElement(dbg, "blackbox");
await waitForDispatch(dbg, "BLACKBOX");
});
function assertPauseLocation(dbg, line) {
const { location } = dbg.selectors.getVisibleSelectedFrame();
const source = findSource(dbg, "event-breakpoints.js");
is(location.sourceId, source.id, `correct sourceId`);
is(location.line, line, `correct line`);
assertPausedLocation(dbg);
}

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
/**
* test pausing on an errored watch expression
@ -9,32 +10,11 @@
* 3. expand properties
*/
const expressionSelectors = {
const EXPRESSION_SELECTORS = {
plusIcon: ".watch-expressions-pane button.plus",
input: "input.input-expression"
};
function getLabel(dbg, index) {
return findElement(dbg, "expressionNode", index).innerText;
}
function getValue(dbg, index) {
return findElement(dbg, "expressionValue", index).innerText;
}
async function addExpression(dbg, input) {
const plusIcon = findElementWithSelector(dbg, expressionSelectors.plusIcon);
if (plusIcon) {
plusIcon.click();
}
const evaluation = waitForDispatch(dbg, "EVALUATE_EXPRESSION");
findElementWithSelector(dbg, expressionSelectors.input).focus();
type(dbg, input);
pressKey(dbg, "Enter");
await evaluation;
}
add_task(async function() {
const dbg = await initDebugger("doc-script-switching.html");
@ -54,3 +34,24 @@ add_task(async function() {
await toggleExpressionNode(dbg, 1);
is(findAllElements(dbg, "expressionNodes").length, 37);
});
function getLabel(dbg, index) {
return findElement(dbg, "expressionNode", index).innerText;
}
function getValue(dbg, index) {
return findElement(dbg, "expressionValue", index).innerText;
}
async function addExpression(dbg, input) {
const plusIcon = findElementWithSelector(dbg, EXPRESSION_SELECTORS.plusIcon);
if (plusIcon) {
plusIcon.click();
}
const evaluation = waitForDispatch(dbg, "EVALUATE_EXPRESSION");
findElementWithSelector(dbg, EXPRESSION_SELECTORS.input).focus();
type(dbg, input);
pressKey(dbg, "Enter");
await evaluation;
}

View File

@ -10,18 +10,6 @@
* - disappears when all expressions are removed
*/
function getLabel(dbg, index) {
return findElement(dbg, "expressionNode", index).innerText;
}
function getValue(dbg, index) {
return findElement(dbg, "expressionValue", index).innerText;
}
function getRefreshExpressionsElement(dbg) {
return findElement(dbg, "expressionRefresh", 1);
}
add_task(async function() {
const dbg = await initDebugger("doc-script-switching.html");
@ -71,3 +59,15 @@ add_task(async function() {
"The refresh button is no longer displayed after removing watch expressions"
);
});
function getLabel(dbg, index) {
return findElement(dbg, "expressionNode", index).innerText;
}
function getValue(dbg, index) {
return findElement(dbg, "expressionValue", index).innerText;
}
function getRefreshExpressionsElement(dbg) {
return findElement(dbg, "expressionRefresh", 1);
}

View File

@ -10,24 +10,6 @@
* 4. expanding properties when not paused
*/
function getLabel(dbg, index) {
return findElement(dbg, "expressionNode", index).innerText;
}
function getValue(dbg, index) {
return findElement(dbg, "expressionValue", index).innerText;
}
function assertEmptyValue(dbg, index) {
const value = findElement(dbg, "expressionValue", index);
if (value) {
is(value.innerText, "");
return;
}
is(value, null);
}
add_task(async function() {
const dbg = await initDebugger("doc-script-switching.html");
@ -67,3 +49,21 @@ add_task(async function() {
await deleteExpression(dbg, "location");
is(findAllElements(dbg, "expressionNodes").length, 0);
});
function getLabel(dbg, index) {
return findElement(dbg, "expressionNode", index).innerText;
}
function getValue(dbg, index) {
return findElement(dbg, "expressionValue", index).innerText;
}
function assertEmptyValue(dbg, index) {
const value = findElement(dbg, "expressionValue", index);
if (value) {
is(value.innerText, "");
return;
}
is(value, null);
}

View File

@ -4,26 +4,6 @@
// Test the "go to line" feature correctly responses to keyboard shortcuts.
function assertEnabled(dbg) {
is(dbg.selectors.getQuickOpenEnabled(), true, "quickOpen enabled");
}
function assertDisabled(dbg) {
is(dbg.selectors.getQuickOpenEnabled(), false, "quickOpen disabled");
}
async function waitForGoToLineBoxFocus(dbg) {
await waitFor(() => dbg.win.document.activeElement.tagName === "INPUT");
}
function assertLine(dbg, lineNumber) {
is(
dbg.selectors.getSelectedLocation().line,
lineNumber,
`goto line is ${lineNumber}`
);
}
add_task(async function() {
const dbg = await initDebugger("doc-scripts.html", "long.js");
await selectSource(dbg, "long");
@ -58,3 +38,23 @@ add_task(async function() {
pressKey(dbg, "Enter");
assertLine(dbg, 66);
});
function assertEnabled(dbg) {
is(dbg.selectors.getQuickOpenEnabled(), true, "quickOpen enabled");
}
function assertDisabled(dbg) {
is(dbg.selectors.getQuickOpenEnabled(), false, "quickOpen disabled");
}
async function waitForGoToLineBoxFocus(dbg) {
await waitFor(() => dbg.win.document.activeElement.tagName === "INPUT");
}
function assertLine(dbg, lineNumber) {
is(
dbg.selectors.getSelectedLocation().line,
lineNumber,
`goto line is ${lineNumber}`
);
}

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Test is taking too much time to complete on some hardware since
// release at https://bugzilla.mozilla.org/show_bug.cgi?id=1423158

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
"use strict";
@ -36,27 +37,6 @@ const SOURCE_URL = `http://localhost:${
server.identity.primaryPort
}/inline-cache.html`;
/**
* This is meant to simulate the developer editing the inline source and saving.
* Effectively, we change the source during the test at specific controlled points.
*/
function makeChanges() {
docValue++;
}
function getPageValue(tab) {
return SpecialPowers.spawn(tab.linkedBrowser, [], function() {
return content.document.querySelector("script").textContent.trim();
});
}
async function reloadTabAndDebugger(tab, dbg) {
let navigated = waitForDispatch(dbg, "NAVIGATE");
let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
await reload(dbg, "inline-cache.html");
return Promise.all([navigated, loaded]);
}
add_task(async function() {
info("Load document with inline script");
const tab = await addTab(SOURCE_URL);
@ -147,3 +127,24 @@ add_task(async function() {
await toolbox.destroy();
await removeTab(tab);
});
/**
* This is meant to simulate the developer editing the inline source and saving.
* Effectively, we change the source during the test at specific controlled points.
*/
function makeChanges() {
docValue++;
}
function getPageValue(tab) {
return SpecialPowers.spawn(tab.linkedBrowser, [], function() {
return content.document.querySelector("script").textContent.trim();
});
}
async function reloadTabAndDebugger(tab, dbg) {
let navigated = waitForDispatch(dbg, "NAVIGATE");
let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
await reload(dbg, "inline-cache.html");
return Promise.all([navigated, loaded]);
}

View File

@ -2,6 +2,50 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Test checking inline preview feature
add_task(async function() {
await pushPref("devtools.debugger.features.inline-preview", true);
const dbg = await initDebugger(
"doc-inline-preview.html",
"inline-preview.js"
);
await selectSource(dbg, "inline-preview.js");
await checkInlinePreview(dbg, "checkValues", [
{ identifier: "a:", value: '""' },
{ identifier: "b:", value: "false" },
{ identifier: "c:", value: "undefined" },
{ identifier: "d:", value: "null" },
{ identifier: "e:", value: "Array []" },
{ identifier: "f:", value: "Object { }" },
{ identifier: "obj:", value: "Object { foo: 1 }" },
{
identifier: "bs:",
value: "Array(101) [ {…}, {…}, {…}, … ]",
},
]);
await checkInlinePreview(dbg, "columnWise", [
{ identifier: "c:", value: '"c"' },
{ identifier: "a:", value: '"a"' },
{ identifier: "b:", value: '"b"' },
]);
// Checks that open in inspector button works in inline preview
invokeInTab("btnClick");
await checkInspectorIcon(dbg);
const { toolbox } = dbg;
await toolbox.selectTool("jsdebugger");
await waitForPaused(dbg);
// Check preview of event ( event.target should be clickable )
// onBtnClick function in inline-preview.js
await checkInspectorIcon(dbg);
});
async function checkInlinePreview(dbg, fnName, inlinePreviews) {
invokeInTab(fnName);
@ -49,47 +93,3 @@ async function checkInspectorIcon(dbg) {
await resume(dbg);
}
// Test checking inline preview feature
add_task(async function() {
await pushPref("devtools.debugger.features.inline-preview", true);
const dbg = await initDebugger(
"doc-inline-preview.html",
"inline-preview.js"
);
await selectSource(dbg, "inline-preview.js");
await checkInlinePreview(dbg, "checkValues", [
{ identifier: "a:", value: '""' },
{ identifier: "b:", value: "false" },
{ identifier: "c:", value: "undefined" },
{ identifier: "d:", value: "null" },
{ identifier: "e:", value: "Array []" },
{ identifier: "f:", value: "Object { }" },
{ identifier: "obj:", value: "Object { foo: 1 }" },
{
identifier: "bs:",
value: "Array(101) [ {…}, {…}, {…}, … ]",
},
]);
await checkInlinePreview(dbg, "columnWise", [
{ identifier: "c:", value: '"c"' },
{ identifier: "a:", value: '"a"' },
{ identifier: "b:", value: '"b"' },
]);
// Checks that open in inspector button works in inline preview
invokeInTab("btnClick");
await checkInspectorIcon(dbg);
const { toolbox } = dbg;
await toolbox.selectTool("jsdebugger");
await waitForPaused(dbg);
// Check preview of event ( event.target should be clickable )
// onBtnClick function in inline-preview.js
await checkInspectorIcon(dbg);
});

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests that keyboard navigation into and out of debugger code editor

View File

@ -1,30 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
/**
* Test keyboard shortcuts.
*/
function pressResume(dbg) {
pressKey(dbg, "resumeKey");
return waitForPaused(dbg);
}
function pressStepOver(dbg) {
pressKey(dbg, "stepOverKey");
return waitForPaused(dbg);
}
function pressStepIn(dbg) {
pressKey(dbg, "stepInKey");
return waitForPaused(dbg);
}
function pressStepOut(dbg) {
pressKey(dbg, "stepOutKey");
return waitForPaused(dbg);
}
add_task(async function() {
const dbg = await initDebugger("doc-debugger-statements.html");
@ -48,3 +29,23 @@ add_task(async function() {
await pressStepOver(dbg);
assertPausedLocation(dbg);
});
function pressResume(dbg) {
pressKey(dbg, "resumeKey");
return waitForPaused(dbg);
}
function pressStepOver(dbg) {
pressKey(dbg, "stepOverKey");
return waitForPaused(dbg);
}
function pressStepIn(dbg) {
pressKey(dbg, "stepInKey");
return waitForPaused(dbg);
}
function pressStepOut(dbg) {
pressKey(dbg, "stepOutKey");
return waitForPaused(dbg);
}

View File

@ -8,7 +8,7 @@
*/
requestLongerTimeout(2);
var gDefaultHostType = Services.prefs.getCharPref("devtools.toolbox.host");
let gDefaultHostType = Services.prefs.getCharPref("devtools.toolbox.host");
add_task(async function() {
// test is too slow on some platforms due to the number of test cases

View File

@ -1,15 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function getLabel(dbg, index) {
return findElement(dbg, "scopeNode", index).innerText;
}
function expectLabels(dbg, array) {
for (let i = 0; i < array.length; i++) {
is(getLabel(dbg, i + 1), array[i], `Correct label ${array[i]} for index ${i + 1}`);
}
}
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Test that adjacent scopes are merged together as expected.
add_task(async function() {
@ -36,3 +27,13 @@ add_task(async function() {
await toggleScopeNode(dbg, 4);
expectLabels(dbg, ["Block", "<this>", "z", "third", "arguments", "v", "x", "y"]);
});
function getLabel(dbg, index) {
return findElement(dbg, "scopeNode", index).innerText;
}
function expectLabels(dbg, array) {
for (let i = 0; i < array.length; i++) {
is(getLabel(dbg, i + 1), array[i], `Correct label ${array[i]} for index ${i + 1}`);
}
}

View File

@ -1,16 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests minfied + source maps.
function getScopeNodeLabel(dbg, index) {
return findElement(dbg, "scopeNode", index).innerText;
}
function getScopeNodeValue(dbg, index) {
return findElement(dbg, "scopeValue", index).innerText;
}
add_task(async function() {
const dbg = await initDebugger("doc-minified2.html", "sum.js");
dbg.actions.toggleMapScopes();
@ -28,3 +21,11 @@ add_task(async function() {
is(getScopeNodeValue(dbg, 3), "2", "check scope value");
is(getScopeNodeLabel(dbg, 4), "Window", "check scope label");
});
function getScopeNodeLabel(dbg, index) {
return findElement(dbg, "scopeNode", index).innerText;
}
function getScopeNodeValue(dbg, index) {
return findElement(dbg, "scopeValue", index).innerText;
}

View File

@ -2,11 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
function countSources(dbg) {
return dbg.selectors.getSourceCount();
}
const sources = [
const SOURCES = [
"simple1.js",
"simple2.js",
"simple3.js",
@ -43,7 +39,7 @@ add_task(async function() {
await waitForRequestsToSettle(dbg);
// this test is intermittent without this
let onBreakpoint = waitForDispatch(dbg, "SET_BREAKPOINT");
await navigate(dbg, "doc-scripts.html", ...sources);
await navigate(dbg, "doc-scripts.html", ...SOURCES);
await onBreakpoint
is(countSources(dbg), 5, "5 sources are loaded.");
ok(!getIsPaused(getCurrentThread()), "Is not paused");
@ -51,7 +47,7 @@ add_task(async function() {
await waitForRequestsToSettle(dbg);
// this test is intermittent without this
onBreakpoint = waitForDispatch(dbg, "SET_BREAKPOINT");
await navigate(dbg, "doc-scripts.html", ...sources);
await navigate(dbg, "doc-scripts.html", ...SOURCES);
await onBreakpoint
is(countSources(dbg), 5, "5 sources are loaded.");
@ -68,3 +64,7 @@ add_task(async function() {
await waitForRequestsToSettle(dbg);
ok(getSelectedSource().url.includes("long.js"), "Selected source is long.js");
});
function countSources(dbg) {
return dbg.selectors.getSourceCount();
}

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Test that we show a breakpoint in the UI when there is an old pending
// breakpoint with an invalid original location.

View File

@ -1,13 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function getItems(dbg) {
return findAllElements(dbg, "outlineItems");
}
function getNthItem(dbg, index) {
return findElement(dbg, "outlineItem", index);
}
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests the outline pane fuzzy filtering of outline items
add_task(async function() {
@ -80,3 +73,11 @@ add_task(async function() {
ok(getItems(dbg)[0].textContent.includes("TodoModel(key)"), "item TodoModel");
ok(getItems(dbg)[1].textContent.includes("addTodo(title)"), "item addTodo");
});
function getItems(dbg) {
return findAllElements(dbg, "outlineItems");
}
function getNthItem(dbg, index) {
return findElement(dbg, "outlineItem", index);
}

View File

@ -4,18 +4,6 @@
// Tests that after clicking a function in edtior, outline focuses that function
function getItems(dbg) {
return findAllElements(dbg, "outlineItems");
}
function getFocusedNode(dbg) {
return findElementWithSelector(dbg, ".outline-list__element.focused");
}
function getFocusedFunction(dbg) {
return getFocusedNode(dbg).innerText;
}
add_task(async function() {
const dbg = await initDebugger("doc-sources.html", "long");
@ -35,3 +23,15 @@ add_task(async function() {
await clickAtPos(dbg, { line: 13, ch: 2 });
is(getFocusedNode(dbg), null, "should not exist");
});
function getItems(dbg) {
return findAllElements(dbg, "outlineItems");
}
function getFocusedNode(dbg) {
return findElementWithSelector(dbg, ".outline-list__element.focused");
}
function getFocusedFunction(dbg) {
return getFocusedNode(dbg).innerText;
}

View File

@ -1,13 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function getItems(dbg) {
return findAllElements(dbg, "outlineItems");
}
function getNthItem(dbg, index) {
return findElement(dbg, "outlineItem", index);
}
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests that the length of outline functions for original and pretty printed source matches
add_task(async function () {
@ -28,3 +21,11 @@ add_task(async function () {
is(originalSource.length, prettySource.length, "Length of outline functions for both prettyPrint and originalSource same");
});
function getItems(dbg) {
return findAllElements(dbg, "outlineItems");
}
function getNthItem(dbg, index) {
return findElement(dbg, "outlineItem", index);
}

View File

@ -1,13 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function getItems(dbg) {
return findAllElements(dbg, "outlineItems");
}
function getNthItem(dbg, index) {
return findElement(dbg, "outlineItem", index);
}
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests that clicking a function in outline panel, the editor highlights the correct location.
// Tests that outline panel can sort functions alphabetically.
@ -64,3 +57,11 @@ add_task(async function() {
"Alphabetized first function is correct"
);
});
function getItems(dbg) {
return findAllElements(dbg, "outlineItems");
}
function getNthItem(dbg, index) {
return findElement(dbg, "outlineItem", index);
}

View File

@ -1,13 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function uncaughtException() {
return invokeInTab("uncaughtException").catch(() => {});
}
function caughtException() {
return invokeInTab("caughtException");
}
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
/*
Tests Pausing on exception
@ -107,3 +100,11 @@ add_task(async function() {
assertPausedAtSourceAndLine(dbg, source.id, 77);
await resume(dbg);
});
function uncaughtException() {
return invokeInTab("uncaughtException").catch(() => {});
}
function caughtException() {
return invokeInTab("caughtException");
}

View File

@ -4,17 +4,6 @@
requestLongerTimeout(2);
async function stepOvers(dbg, count, onStep = () => {}) {
for (let i = 0; i < count; i++) {
await dbg.actions.stepOver(getThreadContext(dbg));
await waitForPaused(dbg);
onStep();
}
}
function formatSteps(steps) {
return steps.map(loc => `(${loc.join(",")})`).join(", ");
}
async function testCase(dbg, { name, steps }) {
invokeInTab(name);
const locations = [];
@ -74,3 +63,15 @@ add_task(async function test() {
]
});
});
async function stepOvers(dbg, count, onStep = () => {}) {
for (let i = 0; i < count; i++) {
await dbg.actions.stepOver(getThreadContext(dbg));
await waitForPaused(dbg);
onStep();
}
}
function formatSteps(steps) {
return steps.map(loc => `(${loc.join(",")})`).join(", ");
}

View File

@ -2,21 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
function getScrollTop(dbg) {
return getCM(dbg).doc.scrollTop;
}
async function waitForMatch(dbg, { matchIndex, count }) {
await waitForState(
dbg,
state => {
const result = dbg.selectors.getFileSearchResults();
return result.matchIndex == matchIndex && result.count == count;
},
"wait for match"
);
}
add_task(async function() {
const dbg = await initDebugger("doc-scripts.html");
@ -42,3 +27,18 @@ add_task(async function() {
const matchScrollTop = getScrollTop(dbg);
ok(pauseScrollTop != matchScrollTop, "did not jump to debug line");
});
function getScrollTop(dbg) {
return getCM(dbg).doc.scrollTop;
}
async function waitForMatch(dbg, { matchIndex, count }) {
await waitForState(
dbg,
state => {
const result = dbg.selectors.getFileSearchResults();
return result.matchIndex == matchIndex && result.count == count;
},
"wait for match"
);
}

View File

@ -6,23 +6,6 @@
// might take more than 30s to complete on a slow machine.
requestLongerTimeout(2);
async function waitForConsoleLink(dbg, text) {
const toolbox = dbg.toolbox;
const console = await toolbox.selectTool("webconsole");
const hud = console.hud;
return waitFor(() => {
// Wait until the message updates.
const linkEl = hud.ui.outputNode.querySelector(".frame-link-source");
if (!linkEl) {
return false;
}
const linkText = linkEl.textContent;
return linkText == text ? linkEl : null;
});
}
// Tests that pretty-printing updates console messages.
add_task(async function() {
const dbg = await initDebugger("doc-minified.html");
@ -54,3 +37,20 @@ add_task(async function() {
await selectSource(dbg, "math.min.js:formatted");
await waitForSelectedLocation(dbg, 22);
});
async function waitForConsoleLink(dbg, text) {
const toolbox = dbg.toolbox;
const console = await toolbox.selectTool("webconsole");
const hud = console.hud;
return waitFor(() => {
// Wait until the message updates.
const linkEl = hud.ui.outputNode.querySelector(".frame-link-source");
if (!linkEl) {
return false;
}
const linkText = linkEl.textContent;
return linkText == text ? linkEl : null;
});
}

View File

@ -4,13 +4,6 @@
// Tests that loader and new tab appear when pretty printing,
// and the selected location is mapped afterwards
function waitForTabCounts(dbg, counts) {
return waitForState(dbg, state => {
const tabCounts = countTabs(dbg);
return tabCounts == counts;
});
}
add_task(async function() {
const dbg = await initDebugger("doc-pretty.html", "pretty.js");
@ -22,3 +15,11 @@ add_task(async function() {
await waitForElementWithSelector(dbg, selectors.prettyPrintLoader);
await waitForSelectedLocation(dbg, 5);
});
function waitForTabCounts(dbg, counts) {
return waitForState(dbg, state => {
const tabCounts = countTabs(dbg);
return tabCounts == counts;
});
}

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests basic pretty-printing functionality.

View File

@ -2,24 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
function waitForSelectedFrame(dbg, displayName) {
const { getInScopeLines, getVisibleSelectedFrame } = dbg.selectors;
return waitForState(dbg, state => {
const frame = getVisibleSelectedFrame();
return (
frame &&
frame.displayName == displayName &&
getInScopeLines(frame.location)
);
});
}
async function assertFunctionPreview(dbg, line, column, displayName) {
const previewEl = await tryHovering(dbg, line, column, "tooltip");
is(previewEl.innerText, displayName);
}
// Test hovering in a selected frame
add_task(async function() {
const dbg = await initDebugger("doc-script-switching.html");
@ -46,3 +28,20 @@ add_task(async function() {
"In scope lines"
);
});
function waitForSelectedFrame(dbg, displayName) {
const { getInScopeLines, getVisibleSelectedFrame } = dbg.selectors;
return waitForState(dbg, state => {
const frame = getVisibleSelectedFrame();
return (
frame?.displayName == displayName &&
getInScopeLines(frame.location)
);
});
}
async function assertFunctionPreview(dbg, line, column, displayName) {
const previewEl = await tryHovering(dbg, line, column, "tooltip");
is(previewEl.innerText, displayName);
}

View File

@ -2,37 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
async function assertNoTooltip(dbg) {
await waitForTime(200);
const el = findElement(dbg, "tooltip");
is(el, null, "Tooltip should not exist");
}
function assertPreviewTooltip(dbg, { result, expression }) {
const previewEl = findElement(dbg, "tooltip");
is(previewEl.innerText, result, "Preview text shown to user");
const preview = dbg.selectors.getPreview();
is(`${preview.result}`, result, "Preview.result");
is(preview.updating, false, "Preview.updating");
is(preview.expression, expression, "Preview.expression");
}
function assertPreviewPopup(dbg, { field, value, expression }) {
const previewEl = findElement(dbg, "popup");
is(previewEl.innerText, "", "Preview text shown to user");
const preview = dbg.selectors.getPreview();
is(
`${preview.result.preview.ownProperties[field].value}`,
value,
"Preview.result"
);
is(preview.updating, false, "Preview.updating");
is(preview.expression, expression, "Preview.expression");
}
add_task(async function() {
const dbg = await initDebugger(
"doc-sourcemaps.html",
@ -66,3 +35,34 @@ add_task(async function() {
await hoverAtPos(dbg, { line: 2, ch: 16 });
await assertNoTooltip(dbg);
});
async function assertNoTooltip(dbg) {
await waitForTime(200);
const el = findElement(dbg, "tooltip");
is(el, null, "Tooltip should not exist");
}
function assertPreviewTooltip(dbg, { result, expression }) {
const previewEl = findElement(dbg, "tooltip");
is(previewEl.innerText, result, "Preview text shown to user");
const preview = dbg.selectors.getPreview();
is(`${preview.result}`, result, "Preview.result");
is(preview.updating, false, "Preview.updating");
is(preview.expression, expression, "Preview.expression");
}
function assertPreviewPopup(dbg, { field, value, expression }) {
const previewEl = findElement(dbg, "popup");
is(previewEl.innerText, "", "Preview text shown to user");
const preview = dbg.selectors.getPreview();
is(
`${preview.result.preview.ownProperties[field].value}`,
value,
"Preview.result"
);
is(preview.updating, false, "Preview.updating");
is(preview.expression, expression, "Preview.expression");
}

View File

@ -2,32 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
async function previews(dbg, fnName, previews) {
const invokeResult = invokeInTab(fnName);
await waitForPaused(dbg);
await assertPreviews(dbg, previews);
await resume(dbg);
info(`Ran tests for ${fnName}`);
}
async function testBucketedArray(dbg) {
const invokeResult = invokeInTab("largeArray");
await waitForPaused(dbg);
const preview = await hoverOnToken(dbg, 34, 10, "popup");
is(
preview.properties.map(p => p.name).join(" "),
"[0…99] [100…100] length <prototype>",
"Popup properties are bucketed"
);
is(preview.properties[0].meta.endIndex, 99, "first bucket ends at 99");
is(preview.properties[2].contents.value, 101, "length is 101");
await resume(dbg);
}
// Test hovering on an object, which will show a popup and on a
// simple value, which will show a tooltip.
add_task(async function() {
@ -64,3 +38,29 @@ add_task(async function() {
},
]);
});
async function previews(dbg, fnName, previews) {
const invokeResult = invokeInTab(fnName);
await waitForPaused(dbg);
await assertPreviews(dbg, previews);
await resume(dbg);
info(`Ran tests for ${fnName}`);
}
async function testBucketedArray(dbg) {
const invokeResult = invokeInTab("largeArray");
await waitForPaused(dbg);
const preview = await hoverOnToken(dbg, 34, 10, "popup");
is(
preview.properties.map(p => p.name).join(" "),
"[0…99] [100…100] length <prototype>",
"Popup properties are bucketed"
);
is(preview.properties[0].meta.endIndex, 99, "first bucket ends at 99");
is(preview.properties[2].contents.value, 101, "length is 101");
await resume(dbg);
}

View File

@ -2,67 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
function assertEnabled(dbg) {
is(dbg.selectors.getQuickOpenEnabled(), true, "quickOpen enabled");
}
function assertDisabled(dbg) {
is(dbg.selectors.getQuickOpenEnabled(), false, "quickOpen disabled");
}
function assertLine(dbg, lineNumber) {
is(
dbg.selectors.getSelectedLocation().line,
lineNumber,
`goto line is ${lineNumber}`
);
}
function assertColumn(dbg, columnNumber) {
is(
dbg.selectors.getSelectedLocation().column,
columnNumber,
`goto column is ${columnNumber}`
);
}
function waitForSymbols(dbg, url) {
const source = findSource(dbg, url);
return waitForState(dbg, state => dbg.selectors.getSymbols(state, source.id));
}
function resultCount(dbg) {
return findAllElements(dbg, "resultItems").length;
}
async function quickOpen(dbg, query, shortcut = "quickOpen") {
pressKey(dbg, shortcut);
assertEnabled(dbg);
query !== "" && type(dbg, query);
}
async function waitForResults(dbg, results) {
await waitForAllElements(dbg, "resultItems", results.length, true);
for (let i = 0; i < results.length; ++i) {
if (results[i] !== undefined) {
await waitForElement(dbg, "resultItemName", results[i], i + 1);
}
}
}
function findResultEl(dbg, index = 1) {
return waitForElementWithSelector(dbg, `.result-item:nth-child(${index})`);
}
async function assertResultIsTab(dbg, index) {
const el = await findResultEl(dbg, index);
ok(
el && !!el.querySelector(".tab.result-item-icon"),
"Result should be a tab"
);
}
// Testing quick open
add_task(async function() {
const dbg = await initDebugger("doc-script-switching.html");
@ -136,3 +75,64 @@ add_task(async function() {
await waitForSelectedSource(dbg, "switching-01");
assertLine(dbg, 5);
});
function assertEnabled(dbg) {
is(dbg.selectors.getQuickOpenEnabled(), true, "quickOpen enabled");
}
function assertDisabled(dbg) {
is(dbg.selectors.getQuickOpenEnabled(), false, "quickOpen disabled");
}
function assertLine(dbg, lineNumber) {
is(
dbg.selectors.getSelectedLocation().line,
lineNumber,
`goto line is ${lineNumber}`
);
}
function assertColumn(dbg, columnNumber) {
is(
dbg.selectors.getSelectedLocation().column,
columnNumber,
`goto column is ${columnNumber}`
);
}
function waitForSymbols(dbg, url) {
const source = findSource(dbg, url);
return waitForState(dbg, state => dbg.selectors.getSymbols(state, source.id));
}
function resultCount(dbg) {
return findAllElements(dbg, "resultItems").length;
}
async function quickOpen(dbg, query, shortcut = "quickOpen") {
pressKey(dbg, shortcut);
assertEnabled(dbg);
query !== "" && type(dbg, query);
}
async function waitForResults(dbg, results) {
await waitForAllElements(dbg, "resultItems", results.length, true);
for (let i = 0; i < results.length; ++i) {
if (results[i] !== undefined) {
await waitForElement(dbg, "resultItemName", results[i], i + 1);
}
}
}
function findResultEl(dbg, index = 1) {
return waitForElementWithSelector(dbg, `.result-item:nth-child(${index})`);
}
async function assertResultIsTab(dbg, index) {
const el = await findResultEl(dbg, index);
ok(
el && !!el.querySelector(".tab.result-item-icon"),
"Result should be a tab"
);
}

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Test that dynamically generated <script> elements which contain source maps
// will be shown in the debugger.

View File

@ -8,16 +8,6 @@
* 2. re-sync breakpoints
*/
async function waitForBreakpoint(dbg, location) {
return waitForState(
dbg,
state => {
return dbg.selectors.getBreakpoint(location);
},
"Waiting for breakpoint"
);
}
add_task(async function() {
const dbg = await initDebugger("reload/doc-reload.html");
@ -41,3 +31,13 @@ add_task(async function() {
is(breakpoint.location.line, 6);
await waitForRequestsToSettle(dbg);
});
async function waitForBreakpoint(dbg, location) {
return waitForState(
dbg,
state => {
return dbg.selectors.getBreakpoint(location);
},
"Waiting for breakpoint"
);
}

View File

@ -8,16 +8,6 @@
* 2. re-sync breakpoints
*/
async function waitForBreakpoint(dbg, location) {
return waitForState(
dbg,
state => {
return dbg.selectors.getBreakpoint(location);
},
"Waiting for breakpoint"
);
}
add_task(async function() {
const dbg = await initDebugger(
"ember/quickstart/dist/",
@ -44,3 +34,13 @@ add_task(async function() {
await waitForPaused(dbg);
assertPausedLocation(dbg, "ember-application/index.js", 4);
});
async function waitForBreakpoint(dbg, location) {
return waitForState(
dbg,
state => {
return dbg.selectors.getBreakpoint(location);
},
"Waiting for breakpoint"
);
}

View File

@ -6,22 +6,7 @@
PromiseTestUtils.whitelistRejectionsGlobally(/No such actor/);
PromiseTestUtils.whitelistRejectionsGlobally(/connection just closed/);
const MaxItems = 10;
function findNode(dbg, text) {
for (let index = 0; index < MaxItems; index++) {
var elem = findElement(dbg, "scopeNode", index);
if (elem && elem.innerText == text) {
return elem;
}
}
return null;
}
async function toggleNode(dbg, text) {
const node = await waitUntilPredicate(() => findNode(dbg, text));
return toggleObjectInspectorNode(node);
}
const MAXIMUM_ITEMS = 10;
// Test that expanded scopes stay expanded after resuming and pausing again.
add_task(async function() {
@ -29,8 +14,6 @@ add_task(async function() {
invokeInTab("main", "doc-remember-expanded-scopes.html");
await waitForPaused(dbg);
const MaxItems = 10;
await toggleNode(dbg, "object");
await toggleNode(dbg, "innerObject");
await stepOver(dbg);
@ -39,3 +22,18 @@ add_task(async function() {
await waitUntil(() => findNode(dbg, "innerData"));
ok(true, "Inner object data automatically expanded after stepping");
});
function findNode(dbg, text) {
for (let index = 0; index < MAXIMUM_ITEMS; index++) {
const elem = findElement(dbg, "scopeNode", index);
if (elem?.innerText == text) {
return elem;
}
}
return null;
}
async function toggleNode(dbg, text) {
const node = await waitUntilPredicate(() => findNode(dbg, text));
return toggleObjectInspectorNode(node);
}

View File

@ -1,3 +1,15 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
add_task(async function() {
const dbg = await initDebugger("doc-return-values.html");
await togglePauseOnExceptions(dbg, true, true);
await testReturnValue(dbg, "to sender");
await testThrowValue(dbg, "a fit");
});
function getLabel(dbg, index) {
return findElement(dbg, "scopeNode", index).innerText;
}
@ -51,11 +63,3 @@ async function testThrowValue(dbg, val) {
await resume(dbg);
assertNotPaused(dbg);
}
add_task(async function() {
const dbg = await initDebugger("doc-return-values.html");
await togglePauseOnExceptions(dbg, true, true);
await testReturnValue(dbg, "to sender");
await testThrowValue(dbg, "a fit");
});

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Test that properties with the same value objec be expanded. See Bug 1617210.

View File

@ -1,23 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function getScopeNodeLabel(dbg, index) {
return findElement(dbg, "scopeNode", index).innerText;
}
function getScopeNodeValue(dbg, index) {
return findElement(dbg, "scopeValue", index).innerText;
}
function expandNode(dbg, index) {
const node = findElement(dbg, "scopeNode", index);
const objectInspector = node.closest(".object-inspector");
const properties = objectInspector.querySelectorAll(".node").length;
findElement(dbg, "scopeNode", index).click();
return waitUntil(
() => objectInspector.querySelectorAll(".node").length !== properties
);
}
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
add_task(async function() {
const dbg = await initDebugger("doc-script-mutate.html");
@ -88,3 +71,21 @@ add_task(async function() {
'The fourth element in the scope panel is "phonebook"'
);
});
function getScopeNodeLabel(dbg, index) {
return findElement(dbg, "scopeNode", index).innerText;
}
function getScopeNodeValue(dbg, index) {
return findElement(dbg, "scopeValue", index).innerText;
}
function expandNode(dbg, index) {
const node = findElement(dbg, "scopeNode", index);
const objectInspector = node.closest(".object-inspector");
const properties = objectInspector.querySelectorAll(".node").length;
findElement(dbg, "scopeNode", index).click();
return waitUntil(
() => objectInspector.querySelectorAll(".node").length !== properties
);
}

View File

@ -1,32 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function findNode(dbg, text) {
for (let index = 0;; index++) {
var elem = findElement(dbg, "scopeNode", index);
if (elem && elem.innerText == text) {
return elem;
}
}
}
function toggleNode(dbg, text) {
return toggleObjectInspectorNode(findNode(dbg, text));
}
function findNodeValue(dbg, text) {
for (let index = 0;; index++) {
var elem = findElement(dbg, "scopeNode", index);
if (elem && elem.innerText == text) {
return findElement(dbg, "scopeValue", index).innerText;
}
}
}
async function checkObjectNode(dbg, text, value) {
await toggleNode(dbg, text);
ok(findNodeValue(dbg, "a") == value, "object value");
}
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Test that xrays do not interfere with examining objects in the scopes pane.
add_task(async function() {
@ -61,3 +35,30 @@ add_task(async function() {
await checkObjectNode(dbg, "<value>", "6");
await toggleNode(dbg, "weakmap");
});
function findNode(dbg, text) {
for (let index = 0;; index++) {
const elem = findElement(dbg, "scopeNode", index);
if (elem?.innerText == text) {
return elem;
}
}
}
function toggleNode(dbg, text) {
return toggleObjectInspectorNode(findNode(dbg, text));
}
function findNodeValue(dbg, text) {
for (let index = 0;; index++) {
const elem = findElement(dbg, "scopeNode", index);
if (elem?.innerText == text) {
return findElement(dbg, "scopeValue", index).innerText;
}
}
}
async function checkObjectNode(dbg, text, value) {
await toggleNode(dbg, text);
ok(findNodeValue(dbg, "a") == value, "object value");
}

View File

@ -1,9 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function getLabel(dbg, index) {
return findElement(dbg, "scopeNode", index).innerText;
}
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
add_task(async function() {
const dbg = await initDebugger("doc-script-switching.html");
@ -29,3 +26,7 @@ add_task(async function() {
is(getLabel(dbg, 4), "foo()");
is(getLabel(dbg, 5), "Window");
});
function getLabel(dbg, index) {
return findElement(dbg, "scopeNode", index).innerText;
}

View File

@ -4,19 +4,6 @@
// Tests the search bar correctly responds to queries, enter, shift enter
function waitForSearchState(dbg) {
return waitForState(dbg, () => getCM(dbg).state.search);
}
function getFocusedEl(dbg) {
const doc = dbg.win.document;
return doc.activeElement;
}
function pressMouseDown(dbg, node) {
EventUtils.sendMouseEvent({ type: "mousedown" }, node, dbg.win);
}
add_task(async function() {
const dbg = await initDebugger("doc-scripts.html", "simple1.js", "simple2.js");
const {
@ -69,3 +56,16 @@ add_task(async function() {
pressKey(dbg, "Enter");
is(cm.state.search.posFrom.line, 1);
});
function waitForSearchState(dbg) {
return waitForState(dbg, () => getCM(dbg).state.search);
}
function getFocusedEl(dbg) {
const doc = dbg.win.document;
return doc.activeElement;
}
function pressMouseDown(dbg, node) {
EventUtils.sendMouseEvent({ type: "mousedown" }, node, dbg.win);
}

View File

@ -4,10 +4,6 @@
// Tests the search bar retains previous query on re-opening.
function waitForSearchState(dbg) {
return waitForState(dbg, () => getCM(dbg).state.search);
}
add_task(async function() {
const dbg = await initDebugger("doc-scripts.html", "simple1.js");
const {
@ -43,3 +39,7 @@ add_task(async function() {
await waitForDispatch(dbg, "UPDATE_FILE_SEARCH_QUERY");
is(getFileSearchQuery(), "con");
});
function waitForSearchState(dbg) {
return waitForState(dbg, () => getCM(dbg).state.search);
}

View File

@ -4,16 +4,7 @@
// Tests the search bar correctly responds to queries, enter, shift enter
const isMacOS = AppConstants.platform === "macosx";
function waitForSearchState(dbg) {
return waitForState(dbg, () => getCM(dbg).state.search);
}
function getFocusedEl(dbg) {
const doc = dbg.win.document;
return doc.activeElement;
}
const IS_MAC_OSX = AppConstants.platform === "macosx";
add_task(async function() {
const dbg = await initDebugger("doc-scripts.html", "simple1.js");
@ -52,7 +43,7 @@ add_task(async function() {
pressKey(dbg, "ShiftEnter");
is(state.posFrom.line, 3);
if (isMacOS) {
if (IS_MAC_OSX) {
info('cmd+G and cmdShift+G shortcut for traversing results only work for macOS');
pressKey(dbg, "fileSearchNext");
is(state.posFrom.line, 4);
@ -78,3 +69,12 @@ add_task(async function() {
is(dbg.win.document.activeElement.tagName, "INPUT", "Search field focused");
});
function waitForSearchState(dbg) {
return waitForState(dbg, () => getCM(dbg).state.search);
}
function getFocusedEl(dbg) {
const doc = dbg.win.document;
return doc.activeElement;
}

View File

@ -2,37 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
function openProjectSearch(dbg) {
synthesizeKeyShortcut("CmdOrCtrl+Shift+F");
return waitForState(
dbg,
state => dbg.selectors.getActiveSearch() === "project"
);
}
function closeProjectSearch(dbg) {
pressKey(dbg, "Escape");
return waitForState(dbg, state => !dbg.selectors.getActiveSearch());
}
async function selectResult(dbg) {
const select = waitForState(dbg, () => !dbg.selectors.getActiveSearch());
await clickElement(dbg, "fileMatch");
return select;
}
function getExpandedResultsCount(dbg) {
return findAllElements(dbg, "projectSerchExpandedResults").length;
}
function getResultsFiles(dbg) {
const matches = dbg.selectors
.getTextSearchResults()
.map(file => file.matches);
return [...matches].length;
}
// Testing project search
add_task(async function() {
const dbg = await initDebugger("doc-script-switching.html", "switching-01");
@ -74,3 +43,34 @@ add_task(async function() {
is(getExpandedResultsCount(dbg), 226);
});
function openProjectSearch(dbg) {
synthesizeKeyShortcut("CmdOrCtrl+Shift+F");
return waitForState(
dbg,
state => dbg.selectors.getActiveSearch() === "project"
);
}
function closeProjectSearch(dbg) {
pressKey(dbg, "Escape");
return waitForState(dbg, state => !dbg.selectors.getActiveSearch());
}
async function selectResult(dbg) {
const select = waitForState(dbg, () => !dbg.selectors.getActiveSearch());
await clickElement(dbg, "fileMatch");
return select;
}
function getExpandedResultsCount(dbg) {
return findAllElements(dbg, "projectSerchExpandedResults").length;
}
function getResultsFiles(dbg) {
const matches = dbg.selectors
.getTextSearchResults()
.map(file => file.matches);
return [...matches].length;
}

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Test that breakpoints are hit in eval'ed sources with a sourceURL property.
add_task(async function() {

View File

@ -1,46 +1,10 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// This test can be really slow on debug platforms and should be split.
requestLongerTimeout(3);
async function evalInConsoleAtPoint(
dbg,
target,
fixture,
{ line, column },
statements
) {
const filename = `${target}://./${fixture}/input.`;
const fnName = (target + "-" + fixture).replace(/-([a-z])/g, (s, c) =>
c.toUpperCase()
);
await invokeWithBreakpoint(
dbg,
fnName,
filename,
{ line, column },
async () => {
await assertConsoleEval(dbg, statements);
}
);
ok(true, `Ran tests for ${fixture} at line ${line} column ${column}`);
}
async function assertConsoleEval(dbg, statements) {
const { hud } = await dbg.toolbox.selectTool("webconsole");
for (const [index, statement] of statements.entries()) {
await dbg.client.evaluate(`window.TEST_RESULT = false;`);
await evaluateExpressionInConsole(hud, `TEST_RESULT = ${statement};`);
const result = await dbg.client.evaluate(`window.TEST_RESULT`);
is(result.result, true, `'${statement}' evaluates to true`);
}
}
add_task(async function() {
const dbg = await initDebugger("doc-sourcemapped.html");
dbg.actions.toggleMapScopes();
@ -87,3 +51,40 @@ add_task(async function() {
[`this.hasOwnProperty("bound")`]
);
});
async function evalInConsoleAtPoint(
dbg,
target,
fixture,
{ line, column },
statements
) {
const filename = `${target}://./${fixture}/input.`;
const fnName = (target + "-" + fixture).replace(/-([a-z])/g, (s, c) =>
c.toUpperCase()
);
await invokeWithBreakpoint(
dbg,
fnName,
filename,
{ line, column },
async () => {
await assertConsoleEval(dbg, statements);
}
);
ok(true, `Ran tests for ${fixture} at line ${line} column ${column}`);
}
async function assertConsoleEval(dbg, statements) {
const { hud } = await dbg.toolbox.selectTool("webconsole");
for (const [index, statement] of statements.entries()) {
await dbg.client.evaluate(`window.TEST_RESULT = false;`);
await evaluateExpressionInConsole(hud, `TEST_RESULT = ${statement};`);
const result = await dbg.client.evaluate(`window.TEST_RESULT`);
is(result.result, true, `'${statement}' evaluates to true`);
}
}

View File

@ -1,9 +1,19 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests for preview through Babel's compile output.
requestLongerTimeout(3);
add_task(async function() {
const dbg = await initDebugger("doc-sourcemapped.html");
dbg.actions.toggleMapScopes();
await testForOf(dbg);
await testShadowing(dbg);
await testImportedBindings(dbg);
});
async function breakpointPreviews(
dbg,
target,
@ -195,12 +205,3 @@ function testImportedBindings(dbg) {
]
);
}
add_task(async function() {
const dbg = await initDebugger("doc-sourcemapped.html");
dbg.actions.toggleMapScopes();
await testForOf(dbg);
await testShadowing(dbg);
await testImportedBindings(dbg);
});

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// This test can be really slow on debug platforms and should be split.
requestLongerTimeout(30);

View File

@ -5,6 +5,17 @@
// Tests for stepping through Babel's compile output.
requestLongerTimeout(4);
add_task(async function() {
const dbg = await initDebugger("doc-sourcemapped.html");
await testStepOverForOf(dbg);
await testStepOverForOfArray(dbg);
await testStepOveForOfClosure(dbg);
await testStepOverForOfArrayClosure(dbg);
await testStepOverFunctionParams(dbg);
await testStepOverRegeneratorAwait(dbg);
});
async function breakpointSteps(dbg, target, fixture, { line, column }, steps) {
const filename = `${target}://./${fixture}/input.`;
const fnName = `${target}-${fixture}`.replace(/-([a-z])/g, (s, c) =>
@ -150,14 +161,3 @@ function testStepOverRegeneratorAwait(dbg) {
]
);
}
add_task(async function() {
const dbg = await initDebugger("doc-sourcemapped.html");
await testStepOverForOf(dbg);
await testStepOverForOfArray(dbg);
await testStepOveForOfClosure(dbg);
await testStepOverForOfArrayClosure(dbg);
await testStepOverFunctionParams(dbg);
await testStepOverRegeneratorAwait(dbg);
});

View File

@ -5,18 +5,6 @@
// Tests for preview through Babel's compile output.
requestLongerTimeout(3);
function getOriginalScope(dbg) {
return dbg.selectors.getSelectedOriginalScope(
dbg.selectors.getCurrentThread()
);
}
async function previewToken(dbg, line, column, value) {
const previewEl = await tryHovering(dbg, line, column, "previewPopup");
is(previewEl.innerText, value);
dbg.actions.clearPreview(getContext(dbg));
}
// Test pausing with mapScopes enabled and disabled
add_task(async function() {
const dbg = await initDebugger("doc-sourcemapped.html");
@ -44,3 +32,15 @@ add_task(async function() {
await previewToken(dbg, 20, 16, "undefined");
ok(getOriginalScope(dbg) == null, "Scopes are not mapped");
});
function getOriginalScope(dbg) {
return dbg.selectors.getSelectedOriginalScope(
dbg.selectors.getCurrentThread()
);
}
async function previewToken(dbg, line, column, value) {
const previewEl = await tryHovering(dbg, line, column, "previewPopup");
is(previewEl.innerText, value);
dbg.actions.clearPreview(getContext(dbg));
}

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests loading and pretty printing bundles with sourcemaps disabled
requestLongerTimeout(2);

View File

@ -3,16 +3,6 @@
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
requestLongerTimeout(2);
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"
);
}
// Tests loading sourcemapped sources, setting breakpoints, and
// stepping in them.
@ -57,3 +47,13 @@ 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"
);
}

View File

@ -8,24 +8,6 @@
* 2. re-sync breakpoints
*/
async function waitForBreakpoint(dbg, location) {
return waitForState(
dbg,
state => {
return dbg.selectors.getBreakpoint(location);
},
"Waiting for breakpoint"
);
}
function getBreakpoints(dbg) {
return dbg.selectors.getBreakpointsList();
}
function getBreakpointCount(dbg) {
return dbg.selectors.getBreakpointCount();
}
add_task(async function() {
const dbg = await initDebugger("doc-minified.html");
@ -64,3 +46,21 @@ add_task(async function() {
is(getBreakpointCount(dbg), 0, "No breakpoints");
});
async function waitForBreakpoint(dbg, location) {
return waitForState(
dbg,
state => {
return dbg.selectors.getBreakpoint(location);
},
"Waiting for breakpoint"
);
}
function getBreakpoints(dbg) {
return dbg.selectors.getBreakpointsList();
}
function getBreakpointCount(dbg) {
return dbg.selectors.getBreakpointCount();
}

View File

@ -3,13 +3,6 @@
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
requestLongerTimeout(2);
async function waitForBreakpointCount(dbg, count) {
return waitForState(
dbg,
state => dbg.selectors.getBreakpointCount() === count
);
}
add_task(async function() {
// NOTE: the CORS call makes the test run times inconsistent
const dbg = await initDebugger("doc-sourcemaps.html");
@ -59,3 +52,10 @@ add_task(async function() {
"Breakpoint has correct line"
);
});
async function waitForBreakpointCount(dbg, count) {
return waitForState(
dbg,
state => dbg.selectors.getBreakpointCount() === count
);
}

View File

@ -6,48 +6,6 @@
// stepping in them.
requestLongerTimeout(2);
function assertBreakpointExists(dbg, source, line) {
const {
selectors: { getBreakpoint },
getState
} = dbg;
ok(
getBreakpoint({ sourceId: source.id, line }),
"Breakpoint has correct line"
);
}
async function assertEditorBreakpoint(dbg, line, shouldExist) {
const el = await getLineEl(dbg, line);
const exists = !!el.querySelector(".new-breakpoint");
ok(
exists === shouldExist,
`Breakpoint ${shouldExist ? "exists" : "does not exist"} on line ${line}`
);
}
async function getLineEl(dbg, line) {
let el = await codeMirrorGutterElement(dbg, line);
while (el && !el.matches(".CodeMirror-code > div")) {
el = el.parentElement;
}
return el;
}
async function clickGutter(dbg, line) {
const el = await codeMirrorGutterElement(dbg, line);
clickDOMElement(dbg, el);
}
async function waitForBreakpointCount(dbg, count) {
const {
selectors: { getBreakpointCount },
getState
} = dbg;
await waitForState(dbg, state => getBreakpointCount() == count);
}
add_task(async function() {
// NOTE: the CORS call makes the test run times inconsistent
const dbg = await initDebugger(
@ -111,3 +69,45 @@ add_task(async function() {
assertPausedLocation(dbg);
assertDebugLine(dbg, 16);
});
function assertBreakpointExists(dbg, source, line) {
const {
selectors: { getBreakpoint },
getState
} = dbg;
ok(
getBreakpoint({ sourceId: source.id, line }),
"Breakpoint has correct line"
);
}
async function assertEditorBreakpoint(dbg, line, shouldExist) {
const el = await getLineEl(dbg, line);
const exists = !!el.querySelector(".new-breakpoint");
ok(
exists === shouldExist,
`Breakpoint ${shouldExist ? "exists" : "does not exist"} on line ${line}`
);
}
async function getLineEl(dbg, line) {
let el = await codeMirrorGutterElement(dbg, line);
while (el && !el.matches(".CodeMirror-code > div")) {
el = el.parentElement;
}
return el;
}
async function clickGutter(dbg, line) {
const el = await codeMirrorGutterElement(dbg, line);
clickDOMElement(dbg, el);
}
async function waitForBreakpointCount(dbg, count) {
const {
selectors: { getBreakpointCount },
getState
} = dbg;
await waitForState(dbg, state => getBreakpointCount() == count);
}

View File

@ -3,16 +3,6 @@
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
requestLongerTimeout(2);
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"
);
}
// Tests loading sourcemapped sources, setting breakpoints, and
// stepping in them.
@ -57,3 +47,13 @@ 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"
);
}

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Test keyboard arrow behaviour
add_task(async function() {

View File

@ -1,22 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Make sure named eval sources appear in the list.
async function waitForSourceCount(dbg, i) {
// We are forced to wait until the DOM nodes appear because the
// source tree batches its rendering.
await waitUntil(() => {
return findAllElements(dbg, "sourceNodes").length === i;
}, `waiting for source count ${i}`);
}
function getLabel(dbg, index) {
return findElement(dbg, "sourceNode", index)
.textContent.trim()
.replace(/^[\s\u200b]*/g, "");
}
add_task(async function() {
const dbg = await initDebugger(
"doc-sources.html",
@ -39,3 +26,17 @@ add_task(async function() {
// is(getLabel(dbg, 3), "evaled.js", "evaled exists");
ok(true);
});
async function waitForSourceCount(dbg, i) {
// We are forced to wait until the DOM nodes appear because the
// source tree batches its rendering.
await waitUntil(() => {
return findAllElements(dbg, "sourceNodes").length === i;
}, `waiting for source count ${i}`);
}
function getLabel(dbg, index) {
return findElement(dbg, "sourceNode", index)
.textContent.trim()
.replace(/^[\s\u200b]*/g, "");
}

View File

@ -1,19 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests that the source tree works.
function getLabel(dbg, index) {
return findElement(dbg, "sourceNode", index)
.textContent.trim()
.replace(/^[\s\u200b]*/g, "");
}
function assertBreakpointHeading(dbg, label, index) {
const breakpointHeading = findElement(dbg, "breakpointItem", index).innerText;
is(breakpointHeading, label, `Breakpoint heading is ${label}`);
}
add_task(async function() {
const dbg = await initDebugger("doc-sources-querystring.html", "simple1.js?x=1", "simple1.js?x=2");
const {
@ -58,3 +48,14 @@ add_task(async function() {
type(dbg, "simple1.js?x");
ok(findElement(dbg, "resultItems")[0].innerText.includes("simple.js?x=1"));
});
function getLabel(dbg, index) {
return findElement(dbg, "sourceNode", index)
.textContent.trim()
.replace(/^[\s\u200b]*/g, "");
}
function assertBreakpointHeading(dbg, label, index) {
const breakpointHeading = findElement(dbg, "breakpointItem", index).innerText;
is(breakpointHeading, label, `Breakpoint heading is ${label}`);
}

View File

@ -4,10 +4,6 @@
// Tests that breakpoint panels open when their relevant breakpoint is hit
function getPaneElements(dbg) {
return findElementWithSelector(dbg, '.breakpoints-pane').childNodes;
}
add_task(async function() {
const dbg = await initDebugger("doc-sources.html", "simple1");
@ -31,3 +27,7 @@ add_task(async function() {
info("Confirm the breakpoints pane is closed again");
is(getPaneElements(dbg).length, 1);
});
function getPaneElements(dbg) {
return findElementWithSelector(dbg, '.breakpoints-pane').childNodes;
}

View File

@ -5,15 +5,6 @@
// When stepping into a function, 'let' variables should show as uninitialized
// instead of undefined.
function findNodeValue(dbg, text) {
for (let index = 0;; index++) {
var elem = findElement(dbg, "scopeNode", index);
if (elem && elem.innerText == text) {
return findElement(dbg, "scopeValue", index).innerText;
}
}
}
add_task(async function test() {
const dbg = await initDebugger("doc-step-in-uninitialized.html");
invokeInTab("main");
@ -36,3 +27,12 @@ add_task(async function test() {
ok(findNodeValue(dbg, "y") == "3", "y initialized");
});
function findNodeValue(dbg, text) {
for (let index = 0;; index++) {
const elem = findElement(dbg, "scopeNode", index);
if (elem?.innerText == text) {
return findElement(dbg, "scopeValue", index).innerText;
}
}
}

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests removing tabs with keyboard shortcuts

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests re-opening pretty printed tabs on load

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Test that URL-less sources have tabs and selecting that location does not
// create a new tab for the same URL-less source

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Test that URL-less sources have tabs added to the UI but
// do not persist upon reload

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests adding and removing tabs

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
"use strict";

View File

@ -2,10 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
async function getScopeValue(dbg, index) {
return (await waitForElement(dbg, "scopeValue", index)).innerText;
}
// - Tests adding a watchpoint
// - Tests removing a watchpoint
// - Tests adding a watchpoint, resuming to after the youngest frame has popped,
@ -103,3 +99,8 @@ add_task(async function() {
assertPausedAtSourceAndLine(dbg, sourceId, 25);
await waitForRequestsToSettle(dbg);
});
async function getScopeValue(dbg, index) {
return (await waitForElement(dbg, "scopeValue", index)).innerText;
}

View File

@ -2,19 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
async function checkWorkerThreads(dbg, count) {
await waitUntil(() => dbg.selectors.getThreads().length == count);
ok(true, `Have ${count} threads`);
}
async function checkWorkerStatus(dbg, status) {
await waitUntil(() => {
const threads = dbg.selectors.getThreads();
return threads.some(t => t.serviceWorkerStatus == status);
});
ok(true, `Have thread with status ${status}`);
}
// Test that we can detect a new service worker and hit breakpoints that we've
// set in it.
add_task(async function() {
@ -164,3 +151,16 @@ add_task(async function() {
await waitForRequestsToSettle(dbg);
await removeTab(gBrowser.selectedTab);
});
async function checkWorkerThreads(dbg, count) {
await waitUntil(() => dbg.selectors.getThreads().length == count);
ok(true, `Have ${count} threads`);
}
async function checkWorkerStatus(dbg, status) {
await waitUntil(() => {
const threads = dbg.selectors.getThreads();
return threads.some(t => t.serviceWorkerStatus == status);
});
ok(true, `Have thread with status ${status}`);
}

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Test that breakpoints at worker startup are hit when using windowless workers.
add_task(async function() {

View File

@ -2,29 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
function assertClass(dbg, selector, className, ...args) {
ok(
findElement(dbg, selector, ...args).classList.contains(className),
`${className} class exists`
);
}
function threadIsPaused(dbg, index) {
return ok(findElement(dbg, "threadsPaneItemPause", index));
}
function threadIsSelected(dbg, index) {
return assertClass(dbg, "threadsPaneItem", "selected", index);
}
function getLabel(dbg, index) {
return findElement(dbg, "expressionNode", index).innerText;
}
function getValue(dbg, index) {
return findElement(dbg, "expressionValue", index).innerText;
}
// Test basic windowless worker functionality: the main thread and worker can be
// separately controlled from the same debugger.
add_task(async function() {
@ -117,3 +94,26 @@ add_task(async function() {
await dbg.actions.selectThread(getContext(dbg), thread1);
assertPausedAtSourceAndLine(dbg, workerSource.id, 10);
});
function assertClass(dbg, selector, className, ...args) {
ok(
findElement(dbg, selector, ...args).classList.contains(className),
`${className} class exists`
);
}
function threadIsPaused(dbg, index) {
return ok(findElement(dbg, "threadsPaneItemPause", index));
}
function threadIsSelected(dbg, index) {
return assertClass(dbg, "threadsPaneItem", "selected", index);
}
function getLabel(dbg, index) {
return findElement(dbg, "expressionNode", index).innerText;
}
function getValue(dbg, index) {
return findElement(dbg, "expressionValue", index).innerText;
}

View File

@ -5,28 +5,6 @@
PromiseTestUtils.whitelistRejectionsGlobally(/Current state is running/);
PromiseTestUtils.whitelistRejectionsGlobally(/Connection closed/);
function findNode(dbg, text) {
for (let index = 0; ; index++) {
var elem = findElement(dbg, "scopeNode", index);
if (elem && elem.innerText == text) {
return elem;
}
}
}
function toggleNode(dbg, text) {
return toggleObjectInspectorNode(findNode(dbg, text));
}
function findNodeValue(dbg, text) {
for (let index = 0; ; index++) {
var elem = findElement(dbg, "scopeNode", index);
if (elem && elem.innerText == text) {
return findElement(dbg, "scopeValue", index).innerText;
}
}
}
// Test that unusual objects have their contents shown in worker thread scopes.
add_task(async function() {
const dbg = await initDebugger("doc-worker-scopes.html", "scopes-worker.js");
@ -94,3 +72,25 @@ add_task(async function() {
await toggleScopes(dbg);
await waitForRequestsToSettle(dbg);
});
function findNode(dbg, text) {
for (let index = 0; ; index++) {
const elem = findElement(dbg, "scopeNode", index);
if (elem?.innerText == text) {
return elem;
}
}
}
function toggleNode(dbg, text) {
return toggleObjectInspectorNode(findNode(dbg, text));
}
function findNodeValue(dbg, text) {
for (let index = 0; ; index++) {
const elem = findElement(dbg, "scopeNode", index);
if (elem?.innerText == text) {
return findElement(dbg, "scopeValue", index).innerText;
}
}
}

View File

@ -2,60 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
async function addXHRBreakpoint(dbg, text, method) {
info(`Adding a XHR breakpoint for pattern ${text} and method ${method}`);
const plusIcon = findElementWithSelector(dbg, ".xhr-breakpoints-pane .plus");
if (plusIcon) {
plusIcon.click();
}
findElementWithSelector(dbg, ".xhr-input-url").focus();
type(dbg, text);
if (method) {
findElementWithSelector(dbg, ".xhr-input-method").value = method;
}
pressKey(dbg, "Enter");
await waitForDispatch(dbg, "SET_XHR_BREAKPOINT");
}
async function removeXHRBreakpoint(dbg, index) {
info("Removing a XHR breakpoint");
const closeButtons = dbg.win.document.querySelectorAll(
".xhr-breakpoints-pane .close-btn"
);
if (closeButtons[index]) {
closeButtons[index].click();
}
await waitForDispatch(dbg, "REMOVE_XHR_BREAKPOINT");
}
function getXHRBreakpointsElements(dbg) {
return [
...dbg.win.document.querySelectorAll(".xhr-breakpoints-pane .xhr-container")
];
}
function getXHRBreakpointLabels(elements) {
return elements.map(element => element.title);
}
function getXHRBreakpointCheckbox(dbg) {
return findElementWithSelector(
dbg,
".xhr-breakpoints-pane .breakpoints-exceptions input"
);
}
async function clickPauseOnAny(dbg, expectedEvent) {
getXHRBreakpointCheckbox(dbg).click();
await waitForDispatch(dbg, expectedEvent);
}
add_task(async function() {
const dbg = await initDebugger("doc-xhr.html", "fetch.js");
@ -127,3 +73,57 @@ add_task(async function() {
"Only the desired breakpoint was removed"
);
});
async function addXHRBreakpoint(dbg, text, method) {
info(`Adding a XHR breakpoint for pattern ${text} and method ${method}`);
const plusIcon = findElementWithSelector(dbg, ".xhr-breakpoints-pane .plus");
if (plusIcon) {
plusIcon.click();
}
findElementWithSelector(dbg, ".xhr-input-url").focus();
type(dbg, text);
if (method) {
findElementWithSelector(dbg, ".xhr-input-method").value = method;
}
pressKey(dbg, "Enter");
await waitForDispatch(dbg, "SET_XHR_BREAKPOINT");
}
async function removeXHRBreakpoint(dbg, index) {
info("Removing a XHR breakpoint");
const closeButtons = dbg.win.document.querySelectorAll(
".xhr-breakpoints-pane .close-btn"
);
if (closeButtons[index]) {
closeButtons[index].click();
}
await waitForDispatch(dbg, "REMOVE_XHR_BREAKPOINT");
}
function getXHRBreakpointsElements(dbg) {
return [
...dbg.win.document.querySelectorAll(".xhr-breakpoints-pane .xhr-container")
];
}
function getXHRBreakpointLabels(elements) {
return elements.map(element => element.title);
}
function getXHRBreakpointCheckbox(dbg) {
return findElementWithSelector(
dbg,
".xhr-breakpoints-pane .breakpoints-exceptions input"
);
}
async function clickPauseOnAny(dbg, expectedEvent) {
getXHRBreakpointCheckbox(dbg).click();
await waitForDispatch(dbg, expectedEvent);
}

Some files were not shown because too many files have changed in this diff Show More