blob: 6ca44850d2e41056569a121f9e0aec3e9654a92c [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<script src="../../resources/js-test.js"></script>
<script src="../../resources/ui-helper.js"></script>
</head>
<body>
<input inputmode="none">
<div id="countdown"></div>
<script>
jsTestIsAsync = true;
description('This tests updating inputmode of an input element from "none" to "text". The software keyboard should be brought up after pointerup.<br>'
+ 'To manually test, tap on the input element below. The software keyboard should be brought up');
const input = document.querySelector("input");
input.focus();
let originalVisualViewportHeight;
let logs = [];
async function runTest() {
if (window.testRunner)
await UIHelper.setHardwareKeyboardAttached(false);
originalVisualViewportHeight = window.visualViewport.height;
let didResize = () => { };
window.visualViewport.addEventListener('resize', () => didResize());
input.addEventListener('pointerdown', (event) => {
input.inputMode = 'text';
logs.push({event, visualViewportHeight: visualViewport.height});
}, {once: true});
input.addEventListener('pointerup', (event) => {
logs.push({event, visualViewportHeight: visualViewport.height});
}, {once: true});
if (window.testRunner) {
await UIHelper.activateFormControl(input);
window.keyboardRect = await UIHelper.inputViewBounds();
shouldBeTrue('textHeight = keyboardRect.height; keyboardRect.height > 0');
} else {
await new Promise((resolve) => { didResize = resolve; });
shouldBeTrue('textHeight = document.documentElement.clientHeight - visualViewport.height; document.documentElement.clientHeight - visualViewport.height < 100');
}
shouldBe('logs.length', '2');
shouldBeEqualToString('logs[0].event.type', 'pointerdown');
shouldBe('logs[0].visualViewportHeight', 'originalVisualViewportHeight');
shouldBeEqualToString('logs[1].event.type', 'pointerup');
shouldBe('logs[1].visualViewportHeight', 'originalVisualViewportHeight');
finishJSTest();
}
window.onload = () => setTimeout(runTest, 0);
</script>
</body>
</html>