helper_scrollbarbuttonclick_checkerboard.html (2329B)
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>Test that repeated scrollbar button clicks do not cause checkerboarding</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 <script type="text/javascript"> 11 12 async function test() { 13 let utils = SpecialPowers.getDOMWindowUtils(window); 14 let scrollId = utils.getViewId(document.documentElement); 15 let w = {}, h = {}; 16 utils.getScrollbarSizes(document.documentElement, w, h); 17 let verticalScrollbarWidth = w.value; 18 if (verticalScrollbarWidth == 0) { 19 ok(true, "No scrollbar, can't do this test"); 20 } 21 let downArrowHeight = verticalScrollbarWidth; // assume square scrollbar buttons 22 var mouseX = document.documentElement.clientWidth + verticalScrollbarWidth / 2; 23 let mouseY = document.documentElement.clientHeight - (downArrowHeight / 2); 24 25 // Hold the mouse down on the scrollbar button and 26 // keep it down to trigger the "button repeat" codepath. 27 await promiseNativeMouseEventWithAPZ({ 28 type: "mousedown", 29 target: window, 30 offsetX: mouseX, 31 offsetY: mouseY, 32 }); 33 34 const repetitions = 20; 35 const repeat_delay = 50; // milliseconds 36 for (i = 0; i < repetitions; i++) { 37 // Wait for the results of the click (or, on subsequent iterations 38 // the repeat) to be painted. 39 await promiseFrame(); 40 41 assertNotCheckerboarded(utils, scrollId, "after scrollbar button click-hold", true); 42 43 // Wait enough time to trigger the repeat timer. 44 await SpecialPowers.promiseTimeout(repeat_delay); 45 } 46 47 // Release mouse button to clean up. 48 await promiseNativeMouseEventWithAPZ({ 49 type: "mouseup", 50 target: window, 51 offsetX: mouseX, 52 offsetY: mouseY, 53 }); 54 55 // Sanity-check: we should have scrolled. 56 ok(window.scrollY > 0, "Should have scrolled by clicking the scrollbar button"); 57 } 58 59 waitUntilApzStable() 60 .then(test) 61 .then(subtestDone, subtestFailed); 62 63 </script> 64 <style> 65 .page-footer { 66 background-color: #212121; 67 color: #fff; 68 height: 3000px; 69 } 70 </style> 71 </head> 72 <body> 73 <footer class="page-footer"></footer> 74 </body> 75 </html>