Bug 613280 - Cannot copy result text in console. r=dolske, feedback=rcampbell, a=blocking

This commit is contained in:
Mihai Sucan 2011-01-29 01:30:26 +13:00
Родитель 7635b70585
Коммит a4665516f6
2 изменённых файлов: 75 добавлений и 0 удалений

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

@ -119,6 +119,7 @@ _BROWSER_TEST_FILES = \
browser_webconsole_bug_613642_maintain_scroll.js \
browser_webconsole_bug_613642_prune_scroll.js \
browser_webconsole_bug_618078_network_exceptions.js \
browser_webconsole_bug_613280_jsterm_copy.js \
head.js \
$(NULL)

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

@ -0,0 +1,74 @@
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*
* Contributor(s):
* Mihai Șucan <mihai.sucan@gmail.com>
*/
const TEST_URI = "data:text/html,Web Console test for bug 613280";
function test() {
addTab(TEST_URI);
browser.addEventListener("load", tabLoaded, true);
}
function tabLoaded() {
browser.removeEventListener("load", tabLoaded, true);
openConsole();
let hudId = HUDService.getHudIdByWindow(content);
let HUD = HUDService.hudReferences[hudId];
let input = HUD.jsterm.inputNode;
let selection = getSelection();
let contentSelection = browser.contentWindow.wrappedJSObject.getSelection();
let clipboard_setup = function() {
goDoCommand("cmd_copy");
};
let clipboard_copy_done = function() {
finishTest();
};
// Check if we first need to clear any existing selections.
if (selection.rangeCount > 0 || contentSelection.rangeCount > 0 ||
input.selectionStart != input.selectionEnd) {
if (input.selectionStart != input.selectionEnd) {
input.selectionStart = input.selectionEnd = 0;
}
if (selection.rangeCount > 0) {
selection.removeAllRanges();
}
if (contentSelection.rangeCount > 0) {
contentSelection.removeAllRanges();
}
goUpdateCommand("cmd_copy");
}
let controller = top.document.commandDispatcher.
getControllerForCommand("cmd_copy");
is(controller.isCommandEnabled("cmd_copy"), false, "cmd_copy is disabled");
HUD.jsterm.execute("'bug613280: hello world!'");
HUD.outputNode.selectedIndex = HUD.outputNode.itemCount - 1;
HUD.outputNode.focus();
goUpdateCommand("cmd_copy");
controller = top.document.commandDispatcher.
getControllerForCommand("cmd_copy");
is(controller.isCommandEnabled("cmd_copy"), true, "cmd_copy is enabled");
waitForClipboard(getExpectedClipboardText(HUD.outputNode.selectedItem),
clipboard_setup, clipboard_copy_done, clipboard_copy_done);
}
function getExpectedClipboardText(aItem) {
return "[" + ConsoleUtils.timestampString(aItem.timestamp) + "] " +
aItem.clipboardText;
}