blob: 3b2ceccaf50d6370c6b003ed72b9dcccc13d70e1 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width">
<meta charset="utf8">
<script src="../../../resources/ui-helper.js"></script>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
</script>
</head>
<body onkeydown="handleKeyDown(event)" onkeyup="handleKeyUp(event)" onkeypress="handleKeyPress(event)">
<p>This tests that DOM keydown, keyup, and keypress events are dispatched to a non-editable &lt;body&gt; on iOS using a Chinese keyboard.</p>
<pre id="console"></pre>
<script>
// FIXME: Key down \ causes a timeout.
let remainingKeysToPress = "abcdefghijklmnopqrstuvwxyz0123456789-=[];',./".split("");
async function nextKeyPress()
{
if (!remainingKeysToPress.length) {
if (window.testRunner) {
await UIHelper.setKeyboardInputModeIdentifier("en_US");
testRunner.notifyDone();
}
return;
}
let nextKey = remainingKeysToPress.shift();
UIHelper.keyDown(nextKey);
}
function handleKeyDown(event)
{
logKeyEvent(event);
}
function handleKeyUp(event)
{
logKeyEvent(event);
nextKeyPress();
}
function handleKeyPress(event)
{
logKeyEvent(event);
}
function log(message)
{
document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
}
function logKeyEvent(event)
{
let pieces = [];
for (let propertyName of ["type", "key", "code", "keyIdentifier", "keyCode", "charCode", "keyCode", "which"])
pieces.push(`${propertyName}: ${event[propertyName]}`);
log(pieces.join(", "));
}
async function runTest()
{
if (!window.testRunner)
return;
await UIHelper.setKeyboardInputModeIdentifier("zh_Hans-Pinyin@sw=Pinyin-Simplified;hw=Automatic");
nextKeyPress();
}
runTest();
</script>
</body>
</html>