Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* vim:set ts=2 sw=2 sts=2 et: */
2 /* Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/ */
5 const TEST_URI = "data:text/html;charset=utf-8,<p>test for bug 642615";
7 XPCOMUtils.defineLazyServiceGetter(this, "clipboardHelper",
8 "@mozilla.org/widget/clipboardhelper;1",
9 "nsIClipboardHelper");
11 function consoleOpened(HUD) {
12 let jsterm = HUD.jsterm;
13 let stringToCopy = "foobazbarBug642615";
15 jsterm.clearOutput();
17 ok(!jsterm.completeNode.value, "no completeNode.value");
19 jsterm.setInputValue("doc");
21 let completionValue;
23 // wait for key "u"
24 function onCompletionValue() {
25 completionValue = jsterm.completeNode.value;
27 // Arguments: expected, setup, success, failure.
28 waitForClipboard(
29 stringToCopy,
30 function() {
31 clipboardHelper.copyString(stringToCopy, document);
32 },
33 onClipboardCopy,
34 finishTest);
35 }
37 function onClipboardCopy() {
38 info("wait for completion update after clipboard paste");
39 jsterm.once("autocomplete-updated", onClipboardPaste);
41 updateEditUIVisibility();
42 goDoCommand("cmd_paste");
43 }
45 function onClipboardPaste() {
46 ok(!jsterm.completeNode.value, "no completion value after paste");
48 info("wait for completion update after undo");
49 jsterm.once("autocomplete-updated", onCompletionValueAfterUndo);
51 // Get out of the webconsole event loop.
52 executeSoon(() => {
53 goDoCommand("cmd_undo");
54 });
55 }
57 function onCompletionValueAfterUndo() {
58 is(jsterm.completeNode.value, completionValue,
59 "same completeNode.value after undo");
61 info("wait for completion update after clipboard paste (ctrl-v)");
62 jsterm.once("autocomplete-updated", () => {
63 ok(!jsterm.completeNode.value, "no completion value after paste (ctrl-v)");
65 // using executeSoon() to get out of the webconsole event loop.
66 executeSoon(finishTest);
67 });
69 // Get out of the webconsole event loop.
70 executeSoon(() => {
71 EventUtils.synthesizeKey("v", {accelKey: true});
72 });
73 }
75 info("wait for completion value after typing 'docu'");
76 jsterm.once("autocomplete-updated", onCompletionValue);
78 EventUtils.synthesizeKey("u", {});
79 }
81 function test() {
82 addTab(TEST_URI);
83 browser.addEventListener("load", function onLoad() {
84 browser.removeEventListener("load", onLoad, true);
85 openConsole(null, consoleOpened);
86 }, true);
87 }