browser/devtools/webconsole/test/browser_webconsole_bug_642615_autocomplete.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial