browser/devtools/webconsole/test/browser_webconsole_bug_642615_autocomplete.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 }

mercurial