blob: 9d5d90aec96fb6bdb907673bd081d65bfcf6ec8b [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width">
<script src="../../../resources/js-test.js"></script>
<script src="../../../resources/ui-helper.js"></script>
</head>
<body>
<iframe id="frame" srcdoc="<style>body { margin: 0; padding: 0 }</style><input placeholder='Tap here'><script>window.parent.runTest()</script>"></iframe>
<script>
window.jsTestIsAsync = true;
description("This test focuses the text field in the iframe, taps outside the iframe and then presses the Done button. The keyboard should hide.")
async function runTest()
{
let frame = document.getElementById("frame");
let inputElementInFrame = frame.contentDocument.querySelector("input");
// 1. Add listeners
window.addEventListener("focus", () => debug("dispatched focus to main frame"), { once: true });
window.addEventListener("blur", () => debug("dispatched blur to main frame"), { once: true });
inputElementInFrame.addEventListener("focus", () => debug("dispatched focus to &lt;input&gt;"), { once: true });
inputElementInFrame.addEventListener("blur", () => debug("dispatched blur to &lt;input&gt;"), { once: true });
if (!window.testRunner)
return;
// 2. Focus the <input> in the <iframe>.
let x = frame.offsetLeft + inputElementInFrame.offsetLeft + Math.floor(inputElementInFrame.offsetWidth / 2);
let y = frame.offsetTop + inputElementInFrame.offsetTop + Math.floor(inputElementInFrame.offsetHeight / 2);
await UIHelper.activateAndWaitForInputSessionAt(x, y);
// 3. Tap somewhere in the main frame, then press the Done button.
await UIHelper.activateAt(0, 0);
await UIHelper.dismissFormAccessoryView(); // Press the Done button; ends the input session.
await UIHelper.waitForKeyboardToHide();
testPassed("dismissed form accessory");
document.body.removeChild(document.getElementById("frame"));
finishJSTest();
}
</script>
</body>
</html>