helper_bug1783936.html (2155B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1"> 6 <title>Test that scroll snap happens on pan end without fling</title> 7 <script src="apz_test_utils.js"></script> 8 <script src="apz_test_native_event_utils.js"></script> 9 <script src="/tests/SimpleTest/paint_listener.js"></script> 10 <style> 11 body { 12 margin: 0; 13 padding: 0; 14 } 15 html { 16 overflow-y: scroll; 17 scroll-snap-type: y mandatory; 18 scroll-behavior: auto; 19 } 20 .snap { 21 width: 100%; 22 height: 100vh; 23 background-color: blue; 24 position: absolute; 25 top: 200px; 26 scroll-snap-align: start; 27 } 28 </style> 29 </head> 30 <body> 31 <div class="snap"></div> 32 <div style="width: 100%; height: 500vh;"></div> 33 <script type="application/javascript"> 34 async function test() { 35 is(window.scrollY, 200, "The initial layout should result snapping to 200px"); 36 37 // Start scrolling back by a pan gesture and wait its' scroll end. 38 let transformEndPromise = promiseTransformEnd(); 39 await promiseNativeTouchpadPanEventAndWaitForObserver( 40 window, 41 100, 42 100, 43 0, -100, 44 SpecialPowers.DOMWindowUtils.PHASE_BEGIN); 45 46 // Finish the pan gesture. 47 await promiseNativeTouchpadPanEventAndWaitForObserver( 48 window, 49 100, 50 100, 51 0, 0, 52 SpecialPowers.DOMWindowUtils.PHASE_END); 53 await transformEndPromise; 54 55 // Make sure the new scroll positions have reached to the main-thread. 56 await promiseOnlyApzControllerFlushed(); 57 58 is(window.scrollY, 200, "The pan-end should result snapping to 200px"); 59 } 60 61 // This test is supposed to run on environments where 62 // PanGestureInput.mSimulateMomentum for pan gestures is true, which means 63 // as of now it's only on Linux. 64 if (getPlatform() == "linux") { 65 waitUntilApzStable() 66 .then(test) 67 .then(subtestDone, subtestFailed); 68 } else { 69 ok(true, "Skipping test because this test isn't supposed to work on " + getPlatform()); 70 subtestDone(); 71 } 72 </script> 73 </body> 74 </html>