browser_webconsole_output_copy_newlines.js (1363B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test that multiple messages are copied into the clipboard and that they are 7 // separated by new lines. See bug 916997. 8 const TEST_URI = 9 "data:text/html,<!DOCTYPE html><meta charset=utf8>" + 10 "Test copy multiple messages to clipboard"; 11 12 add_task(async function () { 13 const hud = await openNewTabAndConsole(TEST_URI); 14 15 const messages = Array.from( 16 { length: 10 }, 17 (_, i) => `Message number ${i + 1}` 18 ); 19 const lastMessage = [...messages].pop(); 20 const onMessage = waitForMessageByType(hud, lastMessage, ".console-api"); 21 SpecialPowers.spawn(gBrowser.selectedBrowser, [messages], msgs => { 22 msgs.forEach(msg => content.wrappedJSObject.console.log(msg)); 23 }); 24 const { node } = await onMessage; 25 ok(node, "Messages were logged"); 26 27 // Select the whole output. 28 const output = node.closest(".webconsole-output"); 29 selectNode(hud, output); 30 31 info( 32 "Wait for the clipboard to contain the text corresponding to all the messages" 33 ); 34 await waitForClipboardPromise( 35 () => { 36 // The focus is on the JsTerm, so we need to blur it for the copy comand to work. 37 output.ownerDocument.activeElement.blur(); 38 goDoCommand("cmd_copy"); 39 }, 40 data => data.trim() === messages.join("\n") 41 ); 42 });