Bug 587617 - Can't select text in the output of the WebConsole on linux; f=ddahl,rcampbell r=dietrich a=dietrich

This commit is contained in:
Mihai Sucan 2010-09-15 11:27:10 -04:00
Родитель 593f27f8b7
Коммит 27e24b4263
3 изменённых файлов: 105 добавлений и 2 удалений

Просмотреть файл

@ -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 = \

Просмотреть файл

@ -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 <mihai.sucan@gmail.com>
*
* ***** 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;
}

Просмотреть файл

@ -21,7 +21,8 @@
* Contributor(s):
* David Dahl <ddahl@mozilla.com>
* Patrick Walton <pcwalton@mozilla.com>
* Mihai Șucan <mihai.sucan@gmail.com>
*
* 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;