Bug 1532309 - Log points should show multiple values. r=bhackett

Differential Revision: https://phabricator.services.mozilla.com/D23313

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jason Laster 2019-03-15 20:31:37 +00:00
Родитель dd6a3ef16f
Коммит 1f0f446316
6 изменённых файлов: 63 добавлений и 19 удалений

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

@ -714,6 +714,7 @@ skip-if = ccov && os == 'win' # Bug 1443132
[browser_dbg-keyboard-shortcuts.js] [browser_dbg-keyboard-shortcuts.js]
skip-if = os == "linux" # bug 1351952 skip-if = os == "linux" # bug 1351952
[browser_dbg-layout-changes.js] [browser_dbg-layout-changes.js]
[browser_dbg-log-points.js]
[browser_dbg-outline.js] [browser_dbg-outline.js]
skip-if = verify skip-if = verify
[browser_dbg-outline-pretty.js] [browser_dbg-outline-pretty.js]

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

@ -16,20 +16,6 @@ function waitForConsolePanelChange(dbg) {
}); });
} }
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() { add_task(async function() {
const dbg = await initDebugger("doc-scripts.html", "simple2"); const dbg = await initDebugger("doc-scripts.html", "simple2");
@ -44,5 +30,5 @@ add_task(async function() {
selectContextMenuItem(dbg, "#node-menu-evaluate-in-console"); selectContextMenuItem(dbg, "#node-menu-evaluate-in-console");
await waitForConsolePanelChange(dbg); await waitForConsolePanelChange(dbg);
await hasMessage(dbg, "undefined"); await hasConsoleMessage(dbg, "undefined");
}); });

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

@ -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() { add_task(async function() {
Services.prefs.setBoolPref("devtools.toolbox.splitconsoleEnabled", true); Services.prefs.setBoolPref("devtools.toolbox.splitconsoleEnabled", true);
const dbg = await initDebugger("doc-script-switching.html", "switching-01"); const dbg = await initDebugger("doc-script-switching.html", "switching-01");

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

@ -0,0 +1,29 @@
/* 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 log points are correctly logged to the console
*/
add_task(async function() {
Services.prefs.setBoolPref("devtools.toolbox.splitconsoleEnabled", true);
const dbg = await initDebugger("doc-script-switching.html", "switching-01");
const source = findSource(dbg, "switching-01")
await selectSource(dbg, "switching-01");
await getDebuggerSplitConsole(dbg);
await dbg.actions.addBreakpoint(
{ line: 5, sourceId: source.id },
{ logValue: "'a', 'b', 'c'" }
);
invokeInTab("firstCall");
await waitForPaused(dbg);
await hasConsoleMessage(dbg, "a b c");
const { link, value } = await findConsoleMessage(dbg, "a b c");
is(link, "script-switching-01.js:5:2", "logs should have the relevant link");
is(value, "a b c", "logs should have multiple values");
});

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

@ -1635,3 +1635,26 @@ async function checkEvaluateInTopFrame(target, text, expected) {
const rval = await evaluateInTopFrame(target, text); const rval = await evaluateInTopFrame(target, text);
ok(rval == expected, `Eval returned ${expected}`); ok(rval == expected, `Eval returned ${expected}`);
} }
async function findConsoleMessage(dbg, query) {
const [message,] = await findConsoleMessages(dbg, query);
const value = message.querySelector(".message-body").innerText;
const link = message.querySelector(".frame-link-source-inner").innerText;
return { value, link };
}
async function findConsoleMessages(dbg, query) {
const webConsole = await dbg.toolbox.getPanel("webconsole");
const win = webConsole._frameWindow;
return Array.prototype.filter.call(
win.document.querySelectorAll(".message"),
e => e.innerText.includes(query)
);
}
async function hasConsoleMessage(dbg, msg) {
return waitFor(async () => {
const messages = await findConsoleMessages(dbg, msg);
return messages.length > 0;
})
}

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

@ -212,16 +212,17 @@ BreakpointActor.prototype = {
} }
if (logValue) { if (logValue) {
const completion = frame.eval(logValue); const completion = frame.eval(`[${logValue}]`);
let value; let value;
if (!completion) { if (!completion) {
// The evaluation was killed (possibly by the slow script dialog). // The evaluation was killed (possibly by the slow script dialog).
value = "Log value evaluation incomplete"; value = ["Log value evaluation incomplete"];
} else if ("return" in completion) { } else if ("return" in completion) {
value = completion.return; value = completion.return;
} else { } else {
value = this.getThrownMessage(completion); value = [this.getThrownMessage(completion)];
} }
if (value && typeof value.unsafeDereference === "function") { if (value && typeof value.unsafeDereference === "function") {
value = value.unsafeDereference(); value = value.unsafeDereference();
} }
@ -230,7 +231,7 @@ BreakpointActor.prototype = {
filename: url, filename: url,
lineNumber: generatedLine, lineNumber: generatedLine,
columnNumber: generatedColumn, columnNumber: generatedColumn,
"arguments": [value], "arguments": value,
}; };
this.threadActor._parent._consoleActor.onConsoleAPICall(message); this.threadActor._parent._consoleActor.onConsoleAPICall(message);