michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: const TEST_URI = "data:text/html;charset=utf-8,
test for bug 642615"; michael@0: michael@0: XPCOMUtils.defineLazyServiceGetter(this, "clipboardHelper", michael@0: "@mozilla.org/widget/clipboardhelper;1", michael@0: "nsIClipboardHelper"); michael@0: michael@0: function consoleOpened(HUD) { michael@0: let jsterm = HUD.jsterm; michael@0: let stringToCopy = "foobazbarBug642615"; michael@0: michael@0: jsterm.clearOutput(); michael@0: michael@0: ok(!jsterm.completeNode.value, "no completeNode.value"); michael@0: michael@0: jsterm.setInputValue("doc"); michael@0: michael@0: let completionValue; michael@0: michael@0: // wait for key "u" michael@0: function onCompletionValue() { michael@0: completionValue = jsterm.completeNode.value; michael@0: michael@0: // Arguments: expected, setup, success, failure. michael@0: waitForClipboard( michael@0: stringToCopy, michael@0: function() { michael@0: clipboardHelper.copyString(stringToCopy, document); michael@0: }, michael@0: onClipboardCopy, michael@0: finishTest); michael@0: } michael@0: michael@0: function onClipboardCopy() { michael@0: info("wait for completion update after clipboard paste"); michael@0: jsterm.once("autocomplete-updated", onClipboardPaste); michael@0: michael@0: updateEditUIVisibility(); michael@0: goDoCommand("cmd_paste"); michael@0: } michael@0: michael@0: function onClipboardPaste() { michael@0: ok(!jsterm.completeNode.value, "no completion value after paste"); michael@0: michael@0: info("wait for completion update after undo"); michael@0: jsterm.once("autocomplete-updated", onCompletionValueAfterUndo); michael@0: michael@0: // Get out of the webconsole event loop. michael@0: executeSoon(() => { michael@0: goDoCommand("cmd_undo"); michael@0: }); michael@0: } michael@0: michael@0: function onCompletionValueAfterUndo() { michael@0: is(jsterm.completeNode.value, completionValue, michael@0: "same completeNode.value after undo"); michael@0: michael@0: info("wait for completion update after clipboard paste (ctrl-v)"); michael@0: jsterm.once("autocomplete-updated", () => { michael@0: ok(!jsterm.completeNode.value, "no completion value after paste (ctrl-v)"); michael@0: michael@0: // using executeSoon() to get out of the webconsole event loop. michael@0: executeSoon(finishTest); michael@0: }); michael@0: michael@0: // Get out of the webconsole event loop. michael@0: executeSoon(() => { michael@0: EventUtils.synthesizeKey("v", {accelKey: true}); michael@0: }); michael@0: } michael@0: michael@0: info("wait for completion value after typing 'docu'"); michael@0: jsterm.once("autocomplete-updated", onCompletionValue); michael@0: michael@0: EventUtils.synthesizeKey("u", {}); michael@0: } michael@0: michael@0: function test() { michael@0: addTab(TEST_URI); michael@0: browser.addEventListener("load", function onLoad() { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: openConsole(null, consoleOpened); michael@0: }, true); michael@0: }