Source code

Revision control

Copy as Markdown

Other Tools

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,width=device-width">
<script src="apz_test_utils.js"></script>
<script src="apz_test_native_event_utils.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/NativeKeyCodes.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<style>
#scroller {
height: 50vh;
width: 50vw;
overflow: scroll;
overscroll-behavior: none;
}
#spacer {
height: 200vh;
width: 200vw;
}
</style>
</head>
<body>
<div id="scroller">
<div id="spacer">
</div>
</div>
</body>
<script>
const GESTURE_Y = 120;
async function scrollWithPan() {
await NativePanHandler.promiseNativePanEvent(
window,
150,
GESTURE_Y,
0,
-NativePanHandler.delta * 0.5,
NativePanHandler.beginPhase,
);
await NativePanHandler.promiseNativePanEvent(
window,
150,
GESTURE_Y,
0,
-NativePanHandler.delta * 0.5,
NativePanHandler.updatePhase,
);
await promiseFrame();
await NativePanHandler.promiseNativePanEvent(
window,
150,
GESTURE_Y,
0,
-NativePanHandler.delta,
NativePanHandler.endPhase,
);
await promiseFrame();
}
async function test() {
await promiseApzFlushedRepaints();
var scrollendCount = 0;
// Add a scrollend event listener that counts the number of scrollend
// events fired to the scrollable element.
scroller.addEventListener("scrollend", () => {
scrollendCount += 1;
});
await scrollWithPan();
is(scrollendCount, 0,
"A scrollend event should not be triggered for a pan that does not scroll");
is(scroller.scrollTop, 0, "No scroll should have occured");
}
function isOnChaosMode() {
return SpecialPowers.Services.env.get("MOZ_CHAOSMODE");
}
if ((getPlatform() == "mac" || getPlatform() == "windows") &&
!isOnChaosMode()) {
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
} else {
ok(true, "Skipping test, native key events are not supported on " +
getPlatform());
subtestDone();
}
</script>
</html>