haikuwebkit/ManualTests/arrow-key-events.html

94 lines
2.9 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<body>
<p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=3387">bug 3387</a>:
Redundant keydown, keypress, keyup events sent for arrow keys.</p>
<p>Try pressing arrow keys, PgUp/PgDown/Home/End, Esc, or function keys.
The test passes if the box below doesn't turn red.<p>
<div id="result" style="width:100px; height:100px; background-color:blue;"></div>
<script>
var console_messages = document.createElement("ol");
document.body.appendChild(console_messages);
window.onkeydown = registerWindow;
window.onkeypress = registerWindow;
window.onkeyup = registerWindow;
document.onkeydown = registerDocument;
document.onkeypress = registerDocument;
document.onkeyup = registerDocument;
document.body.onkeydown = registerBody;
document.body.onkeypress = registerBody;
document.body.onkeyup = registerBody;
document.documentElement.onkeydown = registerDocumentElement;
document.documentElement.onkeypress = registerDocumentElement;
document.documentElement.onkeyup = registerDocumentElement;
var bodyKeyDownCount = 0;
var documentElementKeyDownCount = 0;
var windowKeyDownCount = 0;
var documentKeyDownCount = 0;
function log(message)
{
var item = document.createElement("li");
item.appendChild(document.createTextNode(message));
item.style.fontSize = '8px';
console_messages.appendChild(item);
}
function registerBody(e)
{
if ((e.type == "keydown" && ++bodyKeyDownCount != 1)
|| (e.type == "keyup" && --bodyKeyDownCount != 0))
document.getElementById("result").style.backgroundColor = "red";
if (!e)
e = window.event;
log("body: " + e.type);
return true;
}
function registerDocumentElement(e)
{
if ((e.type == "keydown" && ++documentElementKeyDownCount != 1)
|| (e.type == "keyup" && --documentElementKeyDownCount != 0))
document.getElementById("result").style.backgroundColor = "red";
if (!e)
e = window.event;
log(" documentElement: " + e.type);
return true;
}
function registerDocument(e)
{
if ((e.type == "keydown" && ++documentKeyDownCount != 1)
|| (e.type == "keyup" && --documentKeyDownCount != 0))
document.getElementById("result").style.backgroundColor = "red";
if (!e)
e = window.event;
log("  document: " + e.type);
return true;
}
function registerWindow(e)
{
if ((e.type == "keydown" && ++windowKeyDownCount != 1)
|| (e.type == "keyup" && --windowKeyDownCount != 0))
document.getElementById("result").style.backgroundColor = "red";
if (!e)
e = window.event;
log("   window: " + e.type);
return true;
}
</script>
</body>