From 2e72906fa9131dad4eb3ff78b097c92b1525c98f Mon Sep 17 00:00:00 2001 From: Brian Grinstead Date: Tue, 27 Jan 2015 13:26:11 -0500 Subject: [PATCH] Bug 1119503 - Part 5: Make children of message-body class be preformatted to fix copied text of line number showing up on new line; r=past --- browser/devtools/webconsole/console-output.js | 7 +++++-- .../test/browser_webconsole_bug_587617_output_copy.js | 8 ++++++-- .../test/browser_webconsole_bug_613280_jsterm_copy.js | 4 +++- browser/themes/shared/devtools/webconsole.inc.css | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/browser/devtools/webconsole/console-output.js b/browser/devtools/webconsole/console-output.js index 0e4fc289056..5971deb8ff9 100644 --- a/browser/devtools/webconsole/console-output.js +++ b/browser/devtools/webconsole/console-output.js @@ -896,13 +896,16 @@ Messages.Simple.prototype = Heritage.extend(Messages.BaseMessage.prototype, let body = this.document.createElementNS(XHTML_NS, "span"); body.className = "message-body-wrapper message-body devtools-monospace"; - let anchor, container = body; + let bodyInner = this.document.createElementNS(XHTML_NS, "span"); + body.appendChild(bodyInner); + + let anchor, container = bodyInner; if (this._link || this._linkCallback) { container = anchor = this.document.createElementNS(XHTML_NS, "a"); anchor.href = this._link || "#"; anchor.draggable = false; this._addLinkCallback(anchor, this._linkCallback); - body.appendChild(anchor); + bodyInner.appendChild(anchor); } if (typeof this._message == "function") { diff --git a/browser/devtools/webconsole/test/browser_webconsole_bug_587617_output_copy.js b/browser/devtools/webconsole/test/browser_webconsole_bug_587617_output_copy.js index e3b0d21d1e5..78a4221c4c2 100644 --- a/browser/devtools/webconsole/test/browser_webconsole_bug_587617_output_copy.js +++ b/browser/devtools/webconsole/test/browser_webconsole_bug_587617_output_copy.js @@ -57,7 +57,9 @@ function consoleOpened(aHud) { controller = top.document.commandDispatcher.getControllerForCommand("cmd_copy"); is(controller.isCommandEnabled("cmd_copy"), true, "cmd_copy is enabled"); - let selection = HUD.iframeWindow.getSelection() + ""; + // Remove new lines since getSelection() includes one between message and line + // number, but the clipboard doesn't (see bug 1119503) + let selection = (HUD.iframeWindow.getSelection() + "").replace(/\r?\n|\r/g, " "); isnot(selection.indexOf("bug587617"), -1, "selection text includes 'bug587617'"); @@ -80,7 +82,9 @@ function testContextMenuCopy() { let copyItem = contextMenu.querySelector("*[command='cmd_copy']"); ok(copyItem, "the context menu on the output node has a \"Copy\" item"); - let selection = HUD.iframeWindow.getSelection() + ""; + // Remove new lines since getSelection() includes one between message and line + // number, but the clipboard doesn't (see bug 1119503) + let selection = (HUD.iframeWindow.getSelection() + "").replace(/\r?\n|\r/g, " "); copyItem.doCommand(); diff --git a/browser/devtools/webconsole/test/browser_webconsole_bug_613280_jsterm_copy.js b/browser/devtools/webconsole/test/browser_webconsole_bug_613280_jsterm_copy.js index e5d77b1e302..d35559ab5c1 100644 --- a/browser/devtools/webconsole/test/browser_webconsole_bug_613280_jsterm_copy.js +++ b/browser/devtools/webconsole/test/browser_webconsole_bug_613280_jsterm_copy.js @@ -69,7 +69,9 @@ function performTest(HUD, [result]) { getControllerForCommand("cmd_copy"); is(controller.isCommandEnabled("cmd_copy"), true, "cmd_copy is enabled"); - let selectionText = HUD.iframeWindow.getSelection() + ""; + // Remove new lines since getSelection() includes one between message and line + // number, but the clipboard doesn't (see bug 1119503) + let selectionText = (HUD.iframeWindow.getSelection() + "").replace(/\r?\n|\r/g, " "); isnot(selectionText.indexOf("foobarBazBug613280"), -1, "selection text includes 'foobarBazBug613280'"); diff --git a/browser/themes/shared/devtools/webconsole.inc.css b/browser/themes/shared/devtools/webconsole.inc.css index f2010450c66..a97e01cc2d8 100644 --- a/browser/themes/shared/devtools/webconsole.inc.css +++ b/browser/themes/shared/devtools/webconsole.inc.css @@ -117,7 +117,7 @@ a { display: flex; } -.message-body { +.message-body > * { white-space: pre-wrap; word-wrap: break-word; }