michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Test that multiple messages are copied into the clipboard and that they are michael@0: // separated by new lines. See bug 916997. michael@0: michael@0: function test() michael@0: { michael@0: const TEST_URI = "data:text/html;charset=utf8,

hello world, bug 916997"; michael@0: let clipboardValue = ""; michael@0: michael@0: addTab(TEST_URI); michael@0: browser.addEventListener("load", function onLoad() { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: openConsole(null, consoleOpened); michael@0: }, true); michael@0: michael@0: function consoleOpened(hud) michael@0: { michael@0: hud.jsterm.clearOutput(); michael@0: michael@0: let controller = top.document.commandDispatcher. michael@0: getControllerForCommand("cmd_copy"); michael@0: is(controller.isCommandEnabled("cmd_copy"), false, "cmd_copy is disabled"); michael@0: michael@0: content.console.log("Hello world! bug916997a"); michael@0: content.console.log("Hello world 2! bug916997b"); michael@0: michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [{ michael@0: text: "Hello world! bug916997a", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_LOG, michael@0: }, { michael@0: text: "Hello world 2! bug916997b", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_LOG, michael@0: }], michael@0: }).then(() => { michael@0: hud.ui.output.selectAllMessages(); michael@0: hud.outputNode.focus(); michael@0: michael@0: goUpdateCommand("cmd_copy"); michael@0: controller = top.document.commandDispatcher.getControllerForCommand("cmd_copy"); michael@0: is(controller.isCommandEnabled("cmd_copy"), true, "cmd_copy is enabled"); michael@0: michael@0: let selection = hud.iframeWindow.getSelection() + ""; michael@0: info("selection '" + selection + "'"); michael@0: waitForClipboard((str) => { michael@0: clipboardValue = str; michael@0: return str.indexOf("bug916997a") > -1 && str.indexOf("bug916997b") > -1; michael@0: }, michael@0: () => { goDoCommand("cmd_copy"); }, michael@0: checkClipboard.bind(null, hud), michael@0: () => { michael@0: info("last clipboard value: '" + clipboardValue + "'"); michael@0: finishTest(); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function checkClipboard(hud) michael@0: { michael@0: info("clipboard value '" + clipboardValue + "'"); michael@0: let lines = clipboardValue.trim().split("\n"); michael@0: is(hud.outputNode.children.length, 2, "number of messages"); michael@0: is(lines.length, hud.outputNode.children.length, "number of lines"); michael@0: isnot(lines[0].indexOf("bug916997a"), -1, michael@0: "first message text includes 'bug916997a'"); michael@0: isnot(lines[1].indexOf("bug916997b"), -1, michael@0: "second message text includes 'bug916997b'"); michael@0: is(lines[0].indexOf("bug916997b"), -1, michael@0: "first message text does not include 'bug916997b'"); michael@0: finishTest(); michael@0: } michael@0: }