Bug 1532309 - Log points should show multiple values. r=bhackett
authorJason Laster <jlaster@mozilla.com>
Fri, 15 Mar 2019 20:31:37 +0000
changeset 525357 8c6fc5c010f4409df097cf5fa2f34fa03b3de279
parent 525356 744254ed3a22928784786901758382670402a0a2
child 525358 fbfeb6efec16dc63340328ac30946c25d35aead8
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1532309
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1532309 - Log points should show multiple values. r=bhackett Differential Revision: https://phabricator.services.mozilla.com/D23313
devtools/client/debugger/new/test/mochitest/browser.ini
devtools/client/debugger/new/test/mochitest/browser_dbg-console-eval.js
devtools/client/debugger/new/test/mochitest/browser_dbg-console.js
devtools/client/debugger/new/test/mochitest/browser_dbg-log-points.js
devtools/client/debugger/new/test/mochitest/helpers.js
devtools/server/actors/breakpoint.js
--- a/devtools/client/debugger/new/test/mochitest/browser.ini
+++ b/devtools/client/debugger/new/test/mochitest/browser.ini
@@ -709,16 +709,17 @@ skip-if = (os == "win" && ccov) # Bug 14
 [browser_dbg-iframes.js]
 [browser_dbg-inline-cache.js]
 skip-if = ccov && os == 'win' # Bug 1443132
 [browser_dbg-inspector-integration.js]
 [browser_dbg-keyboard-navigation.js]
 [browser_dbg-keyboard-shortcuts.js]
 skip-if = os == "linux" # bug 1351952
 [browser_dbg-layout-changes.js]
+[browser_dbg-log-points.js]
 [browser_dbg-outline.js]
 skip-if = verify
 [browser_dbg-outline-pretty.js]
 [browser_dbg-outline-filter.js]
 [browser_dbg-pause-exceptions.js]
 skip-if = !debug && (os == "win" && os_version == "6.1") # Bug 1456441
 [browser_dbg-pause-on-next.js]
 [browser_dbg-pause-ux.js]
--- a/devtools/client/debugger/new/test/mochitest/browser_dbg-console-eval.js
+++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-console-eval.js
@@ -11,38 +11,24 @@ function waitForConsolePanelChange(dbg) 
   return new Promise(resolve => {
     toolbox.getPanelWhenReady("webconsole").then(() => {
       ok(toolbox.webconsolePanel, "Console is shown.");
       resolve(toolbox.webconsolePanel);
     });
   });
 }
 
-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() {
   const dbg = await initDebugger("doc-scripts.html", "simple2");
 
   await selectSource(dbg, "simple2", 1);
 
   clickElement(dbg, "CodeMirrorLines");
   await waitForElementWithSelector(dbg, ".CodeMirror-code");
 
   getCM(dbg).setSelection({ line: 0, ch: 0 }, { line: 8, ch: 0 });
 
   rightClickElement(dbg, "CodeMirrorLines");
   selectContextMenuItem(dbg, "#node-menu-evaluate-in-console");
 
   await waitForConsolePanelChange(dbg);
-  await hasMessage(dbg, "undefined");
+  await hasConsoleMessage(dbg, "undefined");
 });
--- a/devtools/client/debugger/new/test/mochitest/browser_dbg-console.js
+++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-console.js
@@ -1,8 +1,12 @@
+/* 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-script-switching.html", "switching-01");
 
   await selectSource(dbg, "switching-01");
 
   // open the console
   await getDebuggerSplitConsole(dbg);
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-log-points.js
@@ -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");
+});
--- a/devtools/client/debugger/new/test/mochitest/helpers.js
+++ b/devtools/client/debugger/new/test/mochitest/helpers.js
@@ -1630,8 +1630,31 @@ async function evaluateInTopFrame(target
 }
 
 // Return a promise that resolves when a thread evaluates a string in the
 // topmost frame, ensuring the result matches the expected value.
 async function checkEvaluateInTopFrame(target, text, expected) {
   const rval = await evaluateInTopFrame(target, text);
   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;
+  })
+}
--- a/devtools/server/actors/breakpoint.js
+++ b/devtools/server/actors/breakpoint.js
@@ -207,35 +207,36 @@ BreakpointActor.prototype = {
           reason.message = message;
         }
       } else {
         return undefined;
       }
     }
 
     if (logValue) {
-      const completion = frame.eval(logValue);
+      const completion = frame.eval(`[${logValue}]`);
       let value;
       if (!completion) {
         // 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) {
         value = completion.return;
       } else {
-        value = this.getThrownMessage(completion);
+        value = [this.getThrownMessage(completion)];
       }
+
       if (value && typeof value.unsafeDereference === "function") {
         value = value.unsafeDereference();
       }
 
       const message = {
         filename: url,
         lineNumber: generatedLine,
         columnNumber: generatedColumn,
-        "arguments": [value],
+        "arguments": value,
       };
       this.threadActor._parent._consoleActor.onConsoleAPICall(message);
 
       // Never stop at log points.
       return undefined;
     }
 
     return this.threadActor._pauseAndRespond(frame, reason);