browser_webconsole_output_copy.js (1182B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test copy to clipboard on the console output. See Bug 587617. 7 const TEST_URI = 8 "data:text/html,<!DOCTYPE html>Test copy to clipboard on the console output"; 9 10 add_task(async function () { 11 const hud = await openNewTabAndConsole(TEST_URI); 12 13 const smokeMessage = "Hello world!"; 14 const onMessage = waitForMessageByType(hud, smokeMessage, ".console-api"); 15 SpecialPowers.spawn(gBrowser.selectedBrowser, [smokeMessage], function (msg) { 16 content.wrappedJSObject.console.log(msg); 17 }); 18 const { node } = await onMessage; 19 ok(true, "Message was logged"); 20 21 const selection = selectNode(hud, node); 22 23 const selectionString = selection.toString().trim(); 24 is( 25 selectionString, 26 smokeMessage, 27 `selection has expected "${smokeMessage}" value` 28 ); 29 30 await waitForClipboardPromise( 31 () => { 32 // The focus is on the JsTerm, so we need to blur it for the copy comand to work. 33 node.ownerDocument.activeElement.blur(); 34 goDoCommand("cmd_copy"); 35 }, 36 data => { 37 return data.trim() === smokeMessage; 38 } 39 ); 40 });