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
--- a/browser/devtools/webconsole/console-output.js
+++ b/browser/devtools/webconsole/console-output.js
@@ -891,23 +891,26 @@ Messages.Simple.prototype = Heritage.ext
* @private
* @return Element
*/
_renderBody: function()
{
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") {
container.appendChild(this._message(this));
} else if (this._message instanceof Ci.nsIDOMNode) {
container.appendChild(this._message);
} else {
container.textContent = this._message;
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_587617_output_copy.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_587617_output_copy.js
@@ -52,17 +52,19 @@ function consoleOpened(aHud) {
HUD.ui.output.selectMessage(msg);
outputNode.focus();
goUpdateCommand("cmd_copy");
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'");
waitForClipboard((str) => { return selection.trim() == str.trim(); },
() => { goDoCommand("cmd_copy") },
deferred.resolve, deferred.resolve);
});
return deferred.promise;
@@ -75,17 +77,19 @@ function testContextMenuCopy() {
let contextMenuId = outputNode.parentNode.getAttribute("context");
let contextMenu = HUD.ui.document.getElementById(contextMenuId);
ok(contextMenu, "the output node has a context menu");
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();
waitForClipboard((str) => { return selection.trim() == str.trim(); },
() => { goDoCommand("cmd_copy") },
deferred.resolve, deferred.resolve);
HUD = outputNode = null;
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_613280_jsterm_copy.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_613280_jsterm_copy.js
@@ -64,15 +64,17 @@ function performTest(HUD, [result]) {
HUD.outputNode.focus();
goUpdateCommand("cmd_copy");
controller = top.document.commandDispatcher.
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'");
waitForClipboard((str) => { return str.trim() == selectionText.trim(); },
clipboard_setup, clipboard_copy_done, clipboard_copy_done);
}
--- a/browser/themes/shared/devtools/webconsole.inc.css
+++ b/browser/themes/shared/devtools/webconsole.inc.css
@@ -112,17 +112,17 @@ a {
.message-location > .line-number {
flex: none;
}
.message-flex-body {
display: flex;
}
-.message-body {
+.message-body > * {
white-space: pre-wrap;
word-wrap: break-word;
}
.message-flex-body > .message-body {
display: block;
flex: 1 1 auto;
vertical-align: middle;