Source code

Revision control

Copy as Markdown

Other Tools

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Tests that zoomToFocuedInput scrolls visually</title>
<script src="apz_test_native_event_utils.js"></script>
<script src="apz_test_utils.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
</head>
<body>
<div style="position: fixed; bottom: 0;">
<div style="position: absolute; bottom: 0;">
<input type="text" id="name" />
</div>
</div>
<script>
async function test() {
is(window.scrollY, 0, "The initial scroll offset should be 0");
is(visualViewport.scale, 2.0, "The document should get scaled by 2.0");
is(visualViewport.pageTop, 0, "The initial visual viewport pageTop should be 0");
document.querySelector("#name").focus();
const scrollPromise =
new Promise(resolve => visualViewport.addEventListener("scroll", resolve));
SpecialPowers.DOMWindowUtils.zoomToFocusedInput();
await scrollPromise;
await promiseApzFlushedRepaints();
ok(visualViewport.pageTop > 0,
`The visual viewport should have been scrolled: ${visualViewport.pageTop}`);
}
SpecialPowers.getDOMWindowUtils(window).setResolutionAndScaleTo(2.0);
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
</script>
</body>
</html>