<!DOCTYPEhtml>
<html>
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title>Test that preventDefault() in a dynamically-added touchmove listener prevents scrolling</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>
<divstyle="height: 500vh;"></div>
<script>
async function test() {
// A passive touchstart listener dynamically adds an active touchmove
// listener that calls preventDefault(). APZ must re-hit-test on the first
// touchmove to discover the new listener and wait for a content response,
// so that the preventDefault() is respected and scrolling is suppressed.
const touchstartPromise = new Promise(resolve => {
window.addEventListener("touchstart", () => {
document.addEventListener("touchmove", e => {
e.preventDefault();
}, { passive: false, once: true });
resolve();
}, { passive: true, once: true });
});
// Though as of now fast-path notifiction explicitly schedules a paint,
// it will not in future, so wait two requestAnimationFrames rather than
// waiting for a paint.
await promiseFrame();
await promiseFrame();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.