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

75 lines
2.1 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=527935
-->
<head>
<title>Test for Bug 527935</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/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=527935">Mozilla Bug 527935</a>
<p id="display"></p>
<div id="content">
<iframe id="formTarget" name="formTarget"></iframe>
<form action="data:text/html," target="formTarget">
<input name="test" id="initValue"><input type="submit">
</form>
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 527935 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var formTarget = document.getElementById("formTarget");
var initValue = document.getElementById("initValue");
formTarget.addEventListener("load", function() {
var newInput = document.createElement("input");
newInput.setAttribute("name", "test");
document.body.appendChild(newInput);
setTimeout(function() {
var popupShown = false;
function listener() {
popupShown = true;
}
SpecialPowers.addAutoCompletePopupEventListener(window, listener);
var event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, "f".charCodeAt(0));
newInput.value = "";
newInput.focus();
newInput.dispatchEvent(event);
hitEventLoop(function() {
ok(!popupShown, "Popup must not be opened");
SpecialPowers.removeAutoCompletePopupEventListener(window, listener);
SimpleTest.finish();
}, 100);
}, 0);
}, false);
initValue.focus();
initValue.value = "foo";
synthesizeKey("VK_ENTER", {});
});
function hitEventLoop(func, times) {
if (times > 0) {
setTimeout(hitEventLoop, 0, func, times - 1);
} else {
setTimeout(func, 0);
}
}
</script>
</pre>
</body>
</html>