|
Line 0
a/LayoutTests/fast/events/ios/should-be-able-to-dismiss-form-accessory-after-tapping-outside-iframe-with-focused-field.html_sec1
|
|
|
1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta name="viewport" content="width=device-width"> |
| 5 |
<script src="../../../resources/js-test.js"></script> |
| 6 |
<script src="../../../resources/ui-helper.js"></script> |
| 7 |
</head> |
| 8 |
<body> |
| 9 |
<iframe id="frame" srcdoc="<style>body { margin: 0; padding: 0 }</style><input placeholder='Tap here'><script>window.parent.runTest()</script>"></iframe> |
| 10 |
<script> |
| 11 |
window.jsTestIsAsync = true; |
| 12 |
|
| 13 |
description("This test focuses the text field in the iframe, taps outside the iframe and then presses the Done button. The keyboard should hide.") |
| 14 |
|
| 15 |
async function runTest() |
| 16 |
{ |
| 17 |
let frame = document.getElementById("frame"); |
| 18 |
let inputElementInFrame = frame.contentDocument.querySelector("input"); |
| 19 |
|
| 20 |
// 1. Add listeners |
| 21 |
window.addEventListener("focus", () => debug("dispatched focus to main frame"), { once: true }); |
| 22 |
window.addEventListener("blur", () => debug("dispatched blur to main frame"), { once: true }); |
| 23 |
inputElementInFrame.addEventListener("focus", () => debug("dispatched focus to <input>"), { once: true }); |
| 24 |
inputElementInFrame.addEventListener("blur", () => debug("dispatched blur to <input>"), { once: true }); |
| 25 |
|
| 26 |
if (!window.testRunner) |
| 27 |
return; |
| 28 |
|
| 29 |
// 2. Focus the <input> in the <iframe>. |
| 30 |
let x = frame.offsetLeft + inputElementInFrame.offsetLeft + Math.floor(inputElementInFrame.offsetWidth / 2); |
| 31 |
let y = frame.offsetTop + inputElementInFrame.offsetTop + Math.floor(inputElementInFrame.offsetHeight / 2); |
| 32 |
await UIHelper.activateAndWaitForInputSessionAt(x, y); |
| 33 |
|
| 34 |
// 3. Tap somewhere in the main frame, then press the Done button. |
| 35 |
await UIHelper.activateAt(0, 0); |
| 36 |
await UIHelper.dismissFormAccessoryView(); // Press the Done button; ends the input session. |
| 37 |
await UIHelper.waitForKeyboardToHide(); |
| 38 |
|
| 39 |
testPassed("dismissed form accessory"); |
| 40 |
document.body.removeChild(document.getElementById("frame")); |
| 41 |
finishJSTest(); |
| 42 |
} |
| 43 |
</script> |
| 44 |
</body> |
| 45 |
</html> |