diff --git a/toolkit/components/console/hudservice/tests/browser/Makefile.in b/toolkit/components/console/hudservice/tests/browser/Makefile.in index 2ba7cbf042cd..229f2dbdd2ab 100644 --- a/toolkit/components/console/hudservice/tests/browser/Makefile.in +++ b/toolkit/components/console/hudservice/tests/browser/Makefile.in @@ -56,6 +56,7 @@ _BROWSER_TEST_FILES = \ browser_webconsole_bug_593003_iframe_wrong_hud.js \ browser_webconsole_bug_581231_close_button.js \ browser_webconsole_consoleonpage.js \ + browser_webconsole_bug_587617_output_copy.js \ $(NULL) _BROWSER_TEST_PAGES = \ diff --git a/toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_587617_output_copy.js b/toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_587617_output_copy.js new file mode 100644 index 000000000000..91e2a872821b --- /dev/null +++ b/toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_587617_output_copy.js @@ -0,0 +1,101 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + * + * Contributor(s): + * Mihai Șucan + * + * ***** END LICENSE BLOCK ***** */ + +const Cu = Components.utils; + +Cu.import("resource://gre/modules/HUDService.jsm"); + +const TEST_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-console.html"; + +function tabLoaded() { + gBrowser.selectedBrowser.removeEventListener("load", tabLoaded, true); + + waitForFocus(function () { + HUDService.activateHUDForContext(gBrowser.selectedTab); + + // See bugs 574036, 586386 and 587617. + + let HUD = HUDService.getDisplayByURISpec(content.location.href); + let filterBox = HUD.querySelector(".hud-filter-box"); + let outputNode = HUD.querySelector(".hud-output-node"); + let selection = getSelection(); + let jstermInput = HUD.querySelector(".jsterm-input-node"); + let console = content.wrappedJSObject.console; + let contentSelection = content.getSelection(); + + let make_selection = function () { + let controller = top.document.commandDispatcher. + getControllerForCommand("cmd_copy"); + is(controller.isCommandEnabled("cmd_copy"), false, "cmd_copy is disabled"); + + console.log("Hello world!"); + + let range = document.createRange(); + let selectedNode = outputNode.querySelector(".hud-group > label:last-child"); + range.selectNode(selectedNode); + selection.addRange(range); + + selectedNode.focus(); + + goUpdateCommand("cmd_copy"); + + controller = top.document.commandDispatcher. + getControllerForCommand("cmd_copy"); + is(controller.isCommandEnabled("cmd_copy"), true, "cmd_copy is enabled"); + + waitForClipboard(selectedNode.textContent, clipboard_setup, + clipboard_copy_done, clipboard_copy_done); + }; + + let clipboard_setup = function () { + goDoCommand("cmd_copy"); + }; + + let clipboard_copy_done = function () { + selection.removeAllRanges(); + testEnd(); + }; + + // Check if we first need to clear any existing selections. + if (selection.rangeCount > 0 || contentSelection.rangeCount > 0 || + jstermInput.selectionStart != jstermInput.selectionEnd) { + if (jstermInput.selectionStart != jstermInput.selectionEnd) { + jstermInput.selectionStart = jstermInput.selectionEnd = 0; + } + + if (selection.rangeCount > 0) { + selection.removeAllRanges(); + } + + if (contentSelection.rangeCount > 0) { + contentSelection.removeAllRanges(); + } + + goUpdateCommand("cmd_copy"); + make_selection(); + } + else { + make_selection(); + } + }); +} + +function testEnd() { + HUDService.deactivateHUDForContext(gBrowser.selectedTab); + finish(); +} + +function test() { + waitForExplicitFinish(); + + gBrowser.selectedBrowser.addEventListener("load", tabLoaded, true); + + content.location = TEST_URI; +} + diff --git a/toolkit/themes/gnomestripe/global/webConsole.css b/toolkit/themes/gnomestripe/global/webConsole.css index 419bfb2b53a6..9954a051c1e5 100644 --- a/toolkit/themes/gnomestripe/global/webConsole.css +++ b/toolkit/themes/gnomestripe/global/webConsole.css @@ -21,7 +21,8 @@ * Contributor(s): * David Dahl * Patrick Walton - + * Mihai Șucan + * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), @@ -60,7 +61,7 @@ font-weight: bold; } -.hud-output-node div { +.hud-output-node * { -moz-user-select: text; white-space: pre-wrap; -moz-user-focus: normal;