test_relative_update.html (3141B)
1 <!DOCTYPE HTML> 2 <!-- 3 https://bugzilla.mozilla.org/show_bug.cgi?id=1453425 4 --> 5 <html> 6 <head> 7 <title>Test for relative scroll offset updates (Bug 1453425)</title> 8 <meta charset="utf-8"> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <script src="/tests/SimpleTest/EventUtils.js"></script> 11 <script src="/tests/SimpleTest/paint_listener.js"></script> 12 <script type="application/javascript" src="apz_test_utils.js"></script> 13 <script type="application/javascript" src="apz_test_native_event_utils.js"></script> 14 <style type="text/css"> 15 #frame { 16 width: 200px; 17 height: 400px; 18 overflow: scroll; 19 border: 1px solid black; 20 } 21 #first { 22 width: 200px; 23 height: 108px; 24 background-color: red; 25 } 26 #second { 27 width: 200px; 28 height: 692px; 29 background-color: green; 30 } 31 </style> 32 </head> 33 <body> 34 <div id="frame"> 35 <div id="first"></div> 36 <div id="second"></div> 37 </div> 38 <script type="application/javascript"> 39 async function test() { 40 var utils = SpecialPowers.DOMWindowUtils; 41 42 var elm = document.querySelector("#frame"); 43 // Set a zero-margin displayport to ensure that the element is async-scrollable 44 utils.setDisplayPortMarginsForElement(0, 0, 0, 0, elm, 0); 45 elm.scrollTop = 0; 46 47 // Take over control of the refresh driver and don't allow a layer 48 // transaction until the main thread and APZ have processed two different 49 // scrolls. 50 await promiseApzFlushedRepaints(); 51 utils.advanceTimeAndRefresh(0); 52 53 // Scroll instantly on the main thread by (0, 100). 54 elm.scrollBy(0, 100); 55 56 // We are not using `scroll-behavior` 57 is(elm.scrollTop, 100, "the main thread scroll should be instant"); 58 59 // Dispatch a wheel event to have APZ scroll by (0, 8). Wait for the wheel 60 // event to ensure that the APZ has processed the scroll. 61 await promiseNativeWheelAndWaitForWheelEvent(elm, 40, 40, 0, -8); 62 63 // APZ should be handling the wheel scroll 64 is(elm.scrollTop, 100, "the wheel scroll should be handled by APZ"); 65 66 // Restore control of the refresh driver, allowing the main thread to send a 67 // layer transaction containing the (0, 100) scroll. 68 utils.restoreNormalRefresh(); 69 70 // Wait for all paints to finish and for the main thread to receive pending 71 // repaint requests with the scroll offset from the wheel event. 72 await promiseApzFlushedRepaints(); 73 74 // The main thread scroll should not have overidden the APZ scroll, and we 75 // should see the effects of both scrolls. 76 ok(elm.scrollTop > 100, `expected element.scrollTop > 100. got element.scrollTop = ${elm.scrollTop}`); 77 } 78 79 if (isApzEnabled()) { 80 SimpleTest.waitForExplicitFinish(); 81 // Receiving a relative scroll offset update can cause scroll animations to 82 // be cancelled. This should be fixed, but for now we can still test this 83 // by disabling smooth scrolling. 84 pushPrefs([["general.smoothScroll", false]]) 85 .then(waitUntilApzStable) 86 .then(test) 87 .then(SimpleTest.finish, SimpleTest.finishWithFailure); 88 } 89 90 </script> 91 </body> 92 </html>