gecko/editor/libeditor/text/tests/test_bug569988.html

78 lines
2.3 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=569988
-->
<head>
<title>Test for Bug 569988</title>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/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);
var gPromptInput = null;
function runTest()
{
var os = SpecialPowers.Cc["@mozilla.org/observer-service;1"].
getService(SpecialPowers.Ci.nsIObserverService);
os.addObserver(onPromptLoad, "common-dialog-loaded", false);
os.addObserver(onPromptLoad, "tabmodal-dialog-loaded", false);
info("opening prompt...");
prompt("summary", "text");
info("prompt is closed");
os.removeObserver(onPromptLoad, "tabmodal-dialog-loaded");
os.removeObserver(onPromptLoad, "common-dialog-loaded");
SimpleTest.finish();
}
function onPromptLoad(subject, topic, data)
{
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() {
ok(true, "onPromptFocus is called");
gPromptInput.removeEventListener("focus", onPromptFocus, false);
var listener = {
handleEvent: function _hv(aEvent)
{
var isPrevented = aEvent.defaultPrevented;
ok(!isPrevented, "ESC key event is prevented by editor");
SpecialPowers.removeSystemEventListener(gPromptInput, "keypress",
listener, false);
}
};
SpecialPowers.addSystemEventListener(gPromptInput, "keypress", listener,
false);
info("sending key");
synthesizeKey("VK_ESCAPE", { }, gPromptInput.ownerDocument.defaultView);
}
</script>
</pre>
</body>
</html>