1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/webconsole/test/browser_webconsole_output_copy_newlines.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,77 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Test that multiple messages are copied into the clipboard and that they are 1.8 +// separated by new lines. See bug 916997. 1.9 + 1.10 +function test() 1.11 +{ 1.12 + const TEST_URI = "data:text/html;charset=utf8,<p>hello world, bug 916997"; 1.13 + let clipboardValue = ""; 1.14 + 1.15 + addTab(TEST_URI); 1.16 + browser.addEventListener("load", function onLoad() { 1.17 + browser.removeEventListener("load", onLoad, true); 1.18 + openConsole(null, consoleOpened); 1.19 + }, true); 1.20 + 1.21 + function consoleOpened(hud) 1.22 + { 1.23 + hud.jsterm.clearOutput(); 1.24 + 1.25 + let controller = top.document.commandDispatcher. 1.26 + getControllerForCommand("cmd_copy"); 1.27 + is(controller.isCommandEnabled("cmd_copy"), false, "cmd_copy is disabled"); 1.28 + 1.29 + content.console.log("Hello world! bug916997a"); 1.30 + content.console.log("Hello world 2! bug916997b"); 1.31 + 1.32 + waitForMessages({ 1.33 + webconsole: hud, 1.34 + messages: [{ 1.35 + text: "Hello world! bug916997a", 1.36 + category: CATEGORY_WEBDEV, 1.37 + severity: SEVERITY_LOG, 1.38 + }, { 1.39 + text: "Hello world 2! bug916997b", 1.40 + category: CATEGORY_WEBDEV, 1.41 + severity: SEVERITY_LOG, 1.42 + }], 1.43 + }).then(() => { 1.44 + hud.ui.output.selectAllMessages(); 1.45 + hud.outputNode.focus(); 1.46 + 1.47 + goUpdateCommand("cmd_copy"); 1.48 + controller = top.document.commandDispatcher.getControllerForCommand("cmd_copy"); 1.49 + is(controller.isCommandEnabled("cmd_copy"), true, "cmd_copy is enabled"); 1.50 + 1.51 + let selection = hud.iframeWindow.getSelection() + ""; 1.52 + info("selection '" + selection + "'"); 1.53 + waitForClipboard((str) => { 1.54 + clipboardValue = str; 1.55 + return str.indexOf("bug916997a") > -1 && str.indexOf("bug916997b") > -1; 1.56 + }, 1.57 + () => { goDoCommand("cmd_copy"); }, 1.58 + checkClipboard.bind(null, hud), 1.59 + () => { 1.60 + info("last clipboard value: '" + clipboardValue + "'"); 1.61 + finishTest(); 1.62 + }); 1.63 + }); 1.64 + } 1.65 + 1.66 + function checkClipboard(hud) 1.67 + { 1.68 + info("clipboard value '" + clipboardValue + "'"); 1.69 + let lines = clipboardValue.trim().split("\n"); 1.70 + is(hud.outputNode.children.length, 2, "number of messages"); 1.71 + is(lines.length, hud.outputNode.children.length, "number of lines"); 1.72 + isnot(lines[0].indexOf("bug916997a"), -1, 1.73 + "first message text includes 'bug916997a'"); 1.74 + isnot(lines[1].indexOf("bug916997b"), -1, 1.75 + "second message text includes 'bug916997b'"); 1.76 + is(lines[0].indexOf("bug916997b"), -1, 1.77 + "first message text does not include 'bug916997b'"); 1.78 + finishTest(); 1.79 + } 1.80 +}