|
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/ */ |
|
4 |
|
5 const TEST_URI = "data:text/html;charset=utf-8,<p>test for bug 642615"; |
|
6 |
|
7 XPCOMUtils.defineLazyServiceGetter(this, "clipboardHelper", |
|
8 "@mozilla.org/widget/clipboardhelper;1", |
|
9 "nsIClipboardHelper"); |
|
10 |
|
11 function consoleOpened(HUD) { |
|
12 let jsterm = HUD.jsterm; |
|
13 let stringToCopy = "foobazbarBug642615"; |
|
14 |
|
15 jsterm.clearOutput(); |
|
16 |
|
17 ok(!jsterm.completeNode.value, "no completeNode.value"); |
|
18 |
|
19 jsterm.setInputValue("doc"); |
|
20 |
|
21 let completionValue; |
|
22 |
|
23 // wait for key "u" |
|
24 function onCompletionValue() { |
|
25 completionValue = jsterm.completeNode.value; |
|
26 |
|
27 // Arguments: expected, setup, success, failure. |
|
28 waitForClipboard( |
|
29 stringToCopy, |
|
30 function() { |
|
31 clipboardHelper.copyString(stringToCopy, document); |
|
32 }, |
|
33 onClipboardCopy, |
|
34 finishTest); |
|
35 } |
|
36 |
|
37 function onClipboardCopy() { |
|
38 info("wait for completion update after clipboard paste"); |
|
39 jsterm.once("autocomplete-updated", onClipboardPaste); |
|
40 |
|
41 updateEditUIVisibility(); |
|
42 goDoCommand("cmd_paste"); |
|
43 } |
|
44 |
|
45 function onClipboardPaste() { |
|
46 ok(!jsterm.completeNode.value, "no completion value after paste"); |
|
47 |
|
48 info("wait for completion update after undo"); |
|
49 jsterm.once("autocomplete-updated", onCompletionValueAfterUndo); |
|
50 |
|
51 // Get out of the webconsole event loop. |
|
52 executeSoon(() => { |
|
53 goDoCommand("cmd_undo"); |
|
54 }); |
|
55 } |
|
56 |
|
57 function onCompletionValueAfterUndo() { |
|
58 is(jsterm.completeNode.value, completionValue, |
|
59 "same completeNode.value after undo"); |
|
60 |
|
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)"); |
|
64 |
|
65 // using executeSoon() to get out of the webconsole event loop. |
|
66 executeSoon(finishTest); |
|
67 }); |
|
68 |
|
69 // Get out of the webconsole event loop. |
|
70 executeSoon(() => { |
|
71 EventUtils.synthesizeKey("v", {accelKey: true}); |
|
72 }); |
|
73 } |
|
74 |
|
75 info("wait for completion value after typing 'docu'"); |
|
76 jsterm.once("autocomplete-updated", onCompletionValue); |
|
77 |
|
78 EventUtils.synthesizeKey("u", {}); |
|
79 } |
|
80 |
|
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 } |