author | Michael Ratcliffe <mratcliffe@mozilla.com> |
Tue, 13 Feb 2018 12:07:24 +0000 | |
changeset 403578 | 7398b884c9ebb706fdc789a1c36b7d12f743b837 |
parent 403577 | 3fd159786be142ce63c41024a253405d11fbd54e |
child 403579 | c48e46d5edbfb04ae9b54aa37b61aa254420a837 |
child 403585 | 21e0ed25f05a5f7c7b8213016511d0577708efbe |
push id | 33438 |
push user | rgurzau@mozilla.com |
push date | Wed, 14 Feb 2018 10:46:56 +0000 |
treeherder | mozilla-central@c48e46d5edbf [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | nchevobbe |
bugs | 1437802 |
milestone | 60.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_output_copy.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_output_copy.js @@ -1,34 +1,32 @@ /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* vim: set ft=javascript ts=2 et sw=2 tw=80: */ /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ +/* import-globals-from head.js */ + "use strict"; // Test copy to clipboard on the console output. See Bug 587617. const TEST_URI = "data:text/html,Test copy to clipboard on the console output"; add_task(async function () { let hud = await openNewTabAndConsole(TEST_URI); const smokeMessage = "Hello world!"; let onMessage = waitForMessage(hud, smokeMessage); ContentTask.spawn(gBrowser.selectedBrowser, smokeMessage, function (msg) { content.wrappedJSObject.console.log(msg); }); const {node} = await onMessage; ok(true, "Message was logged"); - const selection = node.ownerDocument.getSelection(); - const range = document.createRange(); - range.selectNodeContents(node); - selection.removeAllRanges(); - selection.addRange(range); + let selection = selectNode(hud, node); const selectionString = selection.toString().trim(); is(selectionString, smokeMessage, `selection has expected "${smokeMessage}" value`); await waitForClipboardPromise( () => { // The focus is on the JsTerm, so we need to blur it for the copy comand to work. node.ownerDocument.activeElement.blur();
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_output_copy_newlines.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_output_copy_newlines.js @@ -1,13 +1,15 @@ /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* vim: set ft=javascript ts=2 et sw=2 tw=80: */ /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ +/* import-globals-from head.js */ + "use strict"; // 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"; add_task(async function () { @@ -19,21 +21,17 @@ add_task(async function () { ContentTask.spawn(gBrowser.selectedBrowser, messages, msgs => { msgs.forEach(msg => content.wrappedJSObject.console.log(msg)); }); const {node} = await onMessage; ok(node, "Messages were logged"); // 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); + selectNode(hud, output); 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"); },
--- a/devtools/client/webconsole/new-console-output/test/mochitest/head.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/head.js @@ -545,8 +545,23 @@ async function openMessageInNetmonitor(t await waitUntil(() => { const selected = getSelectedRequest(store.getState()); return selected && selected.url === url; }); ok(true, "The attached url is correct."); } + +function selectNode(hud, node) { + let outputContainer = hud.ui.outputNode.querySelector(".webconsole-output"); + + // We must first blur the input or else we can't select anything. + outputContainer.ownerDocument.activeElement.blur(); + + let selection = outputContainer.ownerDocument.getSelection(); + let range = document.createRange(); + range.selectNodeContents(node); + selection.removeAllRanges(); + selection.addRange(range); + + return selection; +}