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.0">
<title>Test for bug 1827330</title>
<script type="application/javascript" src="apz_test_native_event_utils.js"></script>
<script type="application/javascript" src="apz_test_utils.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<style>
#scrollbox {
overflow: scroll;
width: 300px;
height: 300px;
}
.spacer {
height: 200%;
} </style>
</head>
<body>
<div id="scrollbox">
<iframe src="https://example.com" width="200" height="200"></iframe>
<div class="spacer"></div>
</div>
<script type="text/javascript">
async function test() {
const utils = SpecialPowers.getDOMWindowUtils(window);
// Zoom in.
let resolution = 3.0;
utils.setResolutionAndScaleTo(resolution);
await promiseApzFlushedRepaints();
var subframe = document.getElementById("scrollbox");
let scrollPromise = new Promise(resolve => {
subframe.addEventListener("scroll", resolve, {once: true});
});
// Scroll down a small amount (5px). The bug in this case is that the
// scroll thumb does not start moving until the mouse has already moved
// by some distance, so if the bug occurs, the first 5px of mouse movement
// will cause no scrolling.
var dragFinisher = await promiseVerticalScrollbarDrag(subframe, 5, 5);
if (!dragFinisher) {
ok(true, "No scrollbar, can't do this test");
return;
}
// the events above might be stuck in APZ input queue for a bit until the
// layer is activated, so we wait here until the scroll event listener is
// triggered.
await scrollPromise;
await dragFinisher();
// Flush everything just to be safe
await promiseOnlyApzControllerFlushed();
// Check that we've scrolled at all.
ok(subframe.scrollTop > 0, "Scrollbar drag resulted in a scroll position of " + subframe.scrollTop);
}
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
</script>
</body>
</html>