diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /editor/libeditor/tests/test_bug569988.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'editor/libeditor/tests/test_bug569988.html')
-rw-r--r-- | editor/libeditor/tests/test_bug569988.html | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/editor/libeditor/tests/test_bug569988.html b/editor/libeditor/tests/test_bug569988.html new file mode 100644 index 000000000..e42bbb985 --- /dev/null +++ b/editor/libeditor/tests/test_bug569988.html @@ -0,0 +1,99 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=569988 +--> +<head> + <title>Test for Bug 569988</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script src="/tests/SimpleTest/EventUtils.js"></script> + <link rel="stylesheet" href="/tests/SimpleTest/test.css"> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=569988">Mozilla Bug 569988</a> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script type="application/javascript"> + +/** Test for Bug 569988 **/ + +SimpleTest.waitForExplicitFinish(); +SimpleTest.waitForFocus(runTest); + + +function runTest() +{ + var script = SpecialPowers.loadChromeScript(function() { + var gPromptInput = null; + var os = Components.classes["@mozilla.org/observer-service;1"] + .getService(Components.interfaces.nsIObserverService); + + os.addObserver(onPromptLoad, "common-dialog-loaded", false); + os.addObserver(onPromptLoad, "tabmodal-dialog-loaded", false); + + function onPromptLoad(subject, topic, data) { + sendAsyncMessage("ok", [true, "onPromptLoad is called"]); + gPromptInput = subject.Dialog.ui.loginTextbox; + gPromptInput.addEventListener("focus", onPromptFocus, false); + // shift focus to ensure it fires. + subject.Dialog.ui.button0.focus(); + gPromptInput.focus(); + } + + function onPromptFocus() { + sendAsyncMessage("ok", [true, "onPromptFocus is called"]); + gPromptInput.removeEventListener("focus", onPromptFocus, false); + + var listenerService = + Components.classes["@mozilla.org/eventlistenerservice;1"] + .getService(Components.interfaces.nsIEventListenerService); + + var listener = { + handleEvent: function _hv(aEvent) { + var isPrevented = aEvent.defaultPrevented; + sendAsyncMessage("ok", [!isPrevented, + "ESC key event is prevented by editor"]); + listenerService.removeSystemEventListener(gPromptInput, "keypress", + listener, false); + } + }; + listenerService.addSystemEventListener(gPromptInput, "keypress", + listener, false); + + sendAsyncMessage("info", "sending key"); + var EventUtils = {}; + EventUtils.window = {}; + EventUtils._EU_Ci = Components.interfaces; + EventUtils._EU_Cc = Components.classes; + Components.classes['@mozilla.org/moz/jssubscript-loader;1'] + .getService(Components.interfaces.mozIJSSubScriptLoader) + .loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", + EventUtils); + EventUtils.synthesizeKey("VK_ESCAPE", {}, + gPromptInput.ownerDocument.defaultView); + } + + addMessageListener("destroy", function() { + os.removeObserver(onPromptLoad, "tabmodal-dialog-loaded"); + os.removeObserver(onPromptLoad, "common-dialog-loaded"); + }); + }); + script.addMessageListener("ok", ([val, msg]) => ok(val, msg)); + script.addMessageListener("info", msg => info(msg)); + + info("opening prompt..."); + prompt("summary", "text"); + info("prompt is closed"); + + script.sendSyncMessage("destroy"); + + SimpleTest.finish(); +} + +</script> +</pre> +</body> +</html> |