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

89 lines
2.9 KiB
HTML
Raw Normal View History

2010-06-22 23:15:21 -07:00
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=569988
-->
<head>
<title>Test for Bug 569988</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" 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);
var gPromptInput = null;
function runTest()
{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var os = Components.classes["@mozilla.org/observer-service;1"].
getService(Components.interfaces.nsIObserverService);
2010-06-22 23:15:21 -07:00
os.addObserver(onPromptLoad, "common-dialog-loaded", false);
os.addObserver(onPromptLoad, "tabmodal-dialog-loaded", false);
2010-06-22 23:15:21 -07:00
ok(true, "opening prompt...");
2010-06-22 23:15:21 -07:00
prompt("summary", "text");
ok(true, "prompt is closed");
os.removeObserver(onPromptLoad, "tabmodal-dialog-loaded");
os.removeObserver(onPromptLoad, "common-dialog-loaded");
2010-06-22 23:15:21 -07:00
}
function onPromptLoad(subject, topic, data)
2010-06-22 23:15:21 -07:00
{
ok(true, "onPromptLoad is called");
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
gPromptInput = subject.Dialog.ui.loginTextbox;
2010-06-22 23:15:21 -07:00
gPromptInput.addEventListener("focus", onPromptFocus, false);
// shift focus to ensure it fires.
subject.Dialog.ui.button0.focus();
gPromptInput.focus();
2010-06-22 23:15:21 -07:00
}
function onPromptFocus() {
2010-06-22 23:15:21 -07:00
ok(true, "onPromptFocus is called");
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
gPromptInput.removeEventListener("focus", onPromptFocus, false);
2010-06-22 23:15:21 -07:00
var systemGroup =
Components.classes["@mozilla.org/eventlistenerservice;1"].
getService(Components.interfaces.nsIEventListenerService).
systemEventGroup;
gPromptInput.QueryInterface(Components.interfaces.nsIDOM3EventTarget);
var listener = {
handleEvent: function _hv(aEvent)
{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var isPrevented = aEvent.getPreventDefault();
ok(!isPrevented, "ESC key event is prevented by editor");
gPromptInput.removeGroupedEventListener("keypress", listener, false,
systemGroup);
SimpleTest.finish();
2010-06-22 23:15:21 -07:00
}
};
gPromptInput.addGroupedEventListener("keypress", listener, false,
systemGroup);
ok(true, "sending key");
synthesizeKey("VK_ESCAPE", { }, gPromptInput.ownerDocument.defaultView);
2010-06-22 23:15:21 -07:00
}
</script>
</pre>
</body>
</html>