Source code

Revision control

Copy as Markdown

Other Tools

<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title>Test that preventDefault() in a static touchmove listener suppresses scrolling on an irregular-area touchpoint</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<script src="apz_test_utils.js"></script>
<script src="apz_test_native_event_utils.js"></script>
<style>
#target {
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 300px;
background: green;
clip-path: polygon(0% 0%, 100% 100%, 0% 100%);
}
</style>
<div id="target"></div>
<div style="height: 500vh;"></div>
<script>
async function test() {
// A non-passive touchmove listener is registered statically. The initial
// hit-test result has both eApzAwareListeners and eIrregularArea. APZ
// must wait for a content response on the first touchmove so
// preventDefault() is honored.
document.addEventListener("touchmove", e => {
e.preventDefault();
}, { passive: false });
await promiseApzFlushedRepaints();
await synthesizeNativeTouch(window, 50, 200,
SpecialPowers.DOMWindowUtils.TOUCH_CONTACT);
await synthesizeNativeTouch(window, 50, 150,
SpecialPowers.DOMWindowUtils.TOUCH_CONTACT);
await synthesizeNativeTouch(window, 50, 100,
SpecialPowers.DOMWindowUtils.TOUCH_CONTACT);
await synthesizeNativeTouch(window, 50, 100,
SpecialPowers.DOMWindowUtils.TOUCH_REMOVE);
await promiseApzFlushedRepaints();
is(window.scrollY, 0, "Should not have scrolled");
}
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
</script>
</html>