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,minimum-scale=1">
<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>
<style>
#fixed {
max-width: 315px;
width: 300px;
visibility: hidden;
left: -295px;
position: fixed;
}
html {
height: 10000px;
scroll-behavior: auto; /* to make scrolling instant */
}
body {
width: 100%;
background: linear-gradient(yellow, blue);
}
</style>
<body>
<div id="fixed">
<div id="target"></div>
</div>
<script>
const isAndroid = getPlatform() == "android";
async function test() {
is(window.scrollY, 0, "The initial scroll offset should be 0");
is(visualViewport.scale, 1.0, "The document should not get scaled");
is(visualViewport.pageTop, 0, "The initial visual viewport pageTop should be 0");
// Scroll the root scroll container.
const scrollendPromise = promiseScrollend(window);
window.scrollTo(0, 2000);
is(window.scrollY, 2000, "Now the scroll offset should be 2000");
await scrollendPromise;
visualViewport.addEventListener("scroll", () => {
ok(isAndroid, "Any VisualViewport scroll event should not be observed");
});
window.addEventListener("scroll", () => {
ok(isAndroid, "Any scroll event should not be observed");
});
document.querySelector("#target").scrollIntoView();
await promiseApzFlushedRepaints();
// Wait two frames to give a chance to scroll.
await promiseFrame();
await promiseFrame();
if (isAndroid) {
todo_is(window.scrollY, 2000, "The scroll offset should stay at 2000px");
} else {
is(window.scrollY, 2000, "The scroll offset should stay at 2000px");
}
}
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
</script>
</body>
</html>