1<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true ] -->
2<html>
3<head>
4<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
5</head>
6<body>
7<style>
8html, body { margin: 0; padding: 0; width: 100%; height: 100%; }
9iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
10</style>
11<script src="../../../resources/ui-helper.js"></script>
12<script>
13
14const frame = document.createElement('iframe');
15document.body.appendChild(frame);
16frame.contentDocument.body.innerHTML = `
17<style>
18html, body { margin: 0; padding: 0; width: 100%; height: 100%; }
19body { background: #6cf; }
20#description { position: absolute; top: 50%; padding: 10px; }
21#container { position: absolute; top: 90%; left: 20%; width: 60%; padding: 10px; font-size: 20px; text-align: center; height: 200px; border: solid 1px #ccc; }
22</style>
23<div id="container" onclick="this.contentEditable = true; this.focus();">click here</div>
24<p id="description">
25 This tests focusing an element inside an iframe at the bottom of the page.<br>
26 To manually test, tap on "click here" below with docked software keyboard.<br>
27 <span id="result"></span>
28</p>
29`;
30
31let keyboardHeight = 250;
32
33function checkScrollTop() {
34 frame.contentWindow.result.textContent = visualViewport.pageTop > keyboardHeight ? 'PASS' : `FAIL - ${visualViewport.offsetTop}px`;
35}
36
37async function runTest() {
38 testRunner.dumpAsText();
39 testRunner.waitUntilDone();
40 testRunner.dumpChildFramesAsText();
41 await UIHelper.setHardwareKeyboardAttached(false);
42 await UIHelper.activateAndWaitForInputSessionAt(frame.offsetWidth / 2, frame.offsetHeight - 5);
43 await UIHelper.ensurePresentationUpdate();
44 const rect = await UIHelper.inputViewBounds();
45 keyboardHeight = rect.height;
46 checkScrollTop();
47 testRunner.notifyDone();
48}
49
50if (window.testRunner)
51 runTest();
52else
53 frame.contentWindow.container.addEventListener('focus', () => setTimeout(checkScrollTop, 500));
54
55</script>
56</body>
57</html>