Bug 1405641 - Enable browser_webconsole_output_copy_newlines.js in new console frontend; r=jdescottes.

MozReview-Commit-ID: 8KtpDUXpuj7

--HG--
extra : rebase_source : 9726b00fa6c1ca3a27c00d3d8cd10951a8a2131e
This commit is contained in:
Nicolas Chevobbe 2018-02-09 18:09:28 +01:00
parent fd90dab99f
commit 1ba1ee83f9
2 changed files with 26 additions and 58 deletions

View File

@ -324,8 +324,6 @@ skip-if = true # Bug 1403448
subsuite = clipboard
[browser_webconsole_output_copy_newlines.js]
subsuite = clipboard
skip-if = true # Bug 1405641
# old console skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
[browser_webconsole_output_order.js]
[browser_webconsole_persist.js]
[browser_webconsole_prune_scroll.js]

View File

@ -3,70 +3,40 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Test that multiple messages are copied into the clipboard and that they are
// separated by new lines. See bug 916997.
"use strict";
add_task(function* () {
const TEST_URI = "data:text/html;charset=utf8,<p>hello world, bug 916997";
let clipboardValue = "";
// Test that multiple messages are copied into the clipboard and that they are
// separated by new lines. See bug 916997.
const TEST_URI = "data:text/html,<meta charset=utf8>" +
"Test copy multiple messages to clipboard";
yield loadTab(TEST_URI);
let hud = yield openConsole();
hud.jsterm.clearOutput();
add_task(async function () {
let hud = await openNewTabAndConsole(TEST_URI);
let controller = top.document.commandDispatcher
.getControllerForCommand("cmd_copy");
is(controller.isCommandEnabled("cmd_copy"), false, "cmd_copy is disabled");
content.console.log("Hello world! bug916997a");
content.console.log("Hello world 2! bug916997b");
yield waitForMessages({
webconsole: hud,
messages: [{
text: "Hello world! bug916997a",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}, {
text: "Hello world 2! bug916997b",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
const messages = Array.from({length: 10}, (_, i) => `Message number ${i + 1}`);
const lastMessage = [...messages].pop();
let onMessage = waitForMessage(hud, lastMessage);
ContentTask.spawn(gBrowser.selectedBrowser, messages, msgs => {
msgs.forEach(msg => content.wrappedJSObject.console.log(msg));
});
const {node} = await onMessage;
ok(node, "Messages were logged");
hud.ui.output.selectAllMessages();
hud.outputNode.focus();
// Select the whole output.
const output = node.closest(".webconsole-output");
const selection = node.ownerDocument.getSelection();
const range = document.createRange();
range.selectNodeContents(output);
selection.removeAllRanges();
selection.addRange(range);
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() + "";
info("selection '" + selection + "'");
waitForClipboard((str) => {
clipboardValue = str;
return str.indexOf("bug916997a") > -1 && str.indexOf("bug916997b") > -1;
},
info("Wait for the clipboard to contain the text corresponding to all the messages");
await waitForClipboardPromise(
() => {
// The focus is on the JsTerm, so we need to blur it for the copy comand to work.
output.ownerDocument.activeElement.blur();
goDoCommand("cmd_copy");
},
() => {
info("clipboard value '" + clipboardValue + "'");
let lines = clipboardValue.trim().split("\n");
is(hud.outputNode.children.length, 2, "number of messages");
is(lines.length, hud.outputNode.children.length, "number of lines");
isnot(lines[0].indexOf("bug916997a"), -1,
"first message text includes 'bug916997a'");
isnot(lines[1].indexOf("bug916997b"), -1,
"second message text includes 'bug916997b'");
is(lines[0].indexOf("bug916997b"), -1,
"first message text does not include 'bug916997b'");
},
() => {
info("last clipboard value: '" + clipboardValue + "'");
});
data => data.trim() === messages.join("\n")
);
});