helper_scrollbartrack_click_overshoot.html (2897B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=device-width; initial-scale=1.0"> 6 <title>Scrolling with mouse down on the scrollbar</title> 7 <script type="application/javascript" src="apz_test_native_event_utils.js"></script> 8 <script type="application/javascript" src="apz_test_utils.js"></script> 9 <script src="/tests/SimpleTest/paint_listener.js"></script> 10 <style> 11 .content { 12 width: 1000px; 13 height: 20000px; 14 } 15 </style> 16 <script type="text/javascript"> 17 18 async function test() { 19 var targetElement = elementForTarget(window); 20 var w = {}, 21 h = {}; 22 var utils = utilsForTarget(window); 23 utils.getScrollbarSizes(targetElement, w, h); 24 var verticalScrollbarWidth = w.value; 25 var mouseX = targetElement.clientWidth + verticalScrollbarWidth / 2; 26 var mouseY = targetElement.clientHeight - 100; // 100 pixels above the bottom of the scrollbar track 27 28 let scrollEndPromise = promiseScrollend(); 29 30 // Click and hold the mouse. Thumb should start scrolling towards the click location. 31 await promiseNativeMouseEventWithAPZ({ 32 target: window, 33 offsetX: mouseX, 34 offsetY: mouseY, 35 type: "mousemove", 36 }); 37 // mouse down 38 await promiseNativeMouseEventWithAPZ({ 39 target: window, 40 offsetX: mouseX, 41 offsetY: mouseY, 42 type: "mousedown", 43 }); 44 45 // Wait for scrolling to complete 46 await scrollEndPromise; 47 48 // Work around bug 1825879: we may get an extra scrollend 49 // event too early. 50 if (window.scrollY < (window.scrollMaxY / 2)) { 51 scrollEndPromise = promiseScrollend(); 52 await scrollEndPromise; 53 } 54 55 // Flush everything just to be safe 56 await promiseOnlyApzControllerFlushed(); 57 58 // Give WebRender a chance to sample any remaining async scroll offset 59 // that affects the scrollbar position. 60 utils.advanceTimeAndRefresh(16); 61 utils.restoreNormalRefresh(); 62 63 var result = hitTest({x: mouseX, y: mouseY}); 64 65 // Check that the scroll thumb is under the cursor. 66 // If the bug occurs, the thumb will scroll too far and 67 // will not be under the cursor. 68 ok((result.hitInfo & APZHitResultFlags.SCROLLBAR_THUMB) != 0, "Scrollbar thumb hit"); 69 70 await promiseNativeMouseEventWithAPZ({ 71 target: window, 72 offsetX: mouseX, 73 offsetY: mouseY, 74 type: "mouseup", 75 }); 76 } 77 78 if (getPlatform() == "mac") { 79 ok(true, "Skipping test on Mac (bug 1851423)"); 80 subtestDone(); 81 } else { 82 // Note: on Linux, if the gtk-primary-button-warps-slider setting 83 // is enabled, this test will not exercise the codepath it intends 84 // to test (the thumb will jump immediately under the cursor, causing 85 // the test to pass trivially). However, the test should still not fail. 86 waitUntilApzStable() 87 .then(test) 88 .then(subtestDone, subtestFailed); 89 } 90 91 </script> 92 </head> 93 <body> 94 <div class="content">Some content to ensure the root scrollframe is scrollable</div> 95 </body> 96 </html>