test_scroll_subframe_scrollbar.html (2498B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test scrolling subframe scrollbars</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <script src="/tests/SimpleTest/EventUtils.js"></script> 7 <script src="/tests/SimpleTest/paint_listener.js"></script> 8 <script type="application/javascript" src="apz_test_utils.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 10 <style> 11 p { 12 width:200px; 13 height:200px; 14 border:solid 1px black; 15 } 16 </style> 17 </head> 18 <body> 19 <p id="subframe"> 20 1 <br> 21 2 <br> 22 3 <br> 23 4 <br> 24 5 <br> 25 6 <br> 26 7 <br> 27 8 <br> 28 9 <br> 29 10 <br> 30 11 <br> 31 12 <br> 32 13 <br> 33 14 <br> 34 15 <br> 35 16 <br> 36 17 <br> 37 18 <br> 38 19 <br> 39 20 <br> 40 21 <br> 41 22 <br> 42 23 <br> 43 24 <br> 44 25 <br> 45 26 <br> 46 27 <br> 47 28 <br> 48 29 <br> 49 30 <br> 50 31 <br> 51 32 <br> 52 33 <br> 53 34 <br> 54 35 <br> 55 36 <br> 56 37 <br> 57 38 <br> 58 39 <br> 59 40 <br> 60 </p> 61 <script clss="testbody" type="text/javascript"> 62 63 var DefaultEvent = { 64 deltaMode: WheelEvent.DOM_DELTA_LINE, 65 deltaX: 0, deltaY: 1, 66 lineOrPageDeltaX: 0, lineOrPageDeltaY: 1, 67 }; 68 69 var ScrollbarWidth = 0; 70 71 async function test() { 72 var subframe = document.getElementById("subframe"); 73 var oldClientWidth = subframe.clientWidth; 74 75 subframe.style.overflow = "auto"; 76 subframe.getBoundingClientRect(); 77 78 await promiseAllPaintsDone(null, /*flush=*/true); 79 80 ScrollbarWidth = oldClientWidth - subframe.clientWidth; 81 if (!ScrollbarWidth) { 82 // Probably we have overlay scrollbars - abort the test. 83 ok(true, "overlay scrollbars - skipping test"); 84 return; 85 } 86 87 ok(subframe.scrollHeight > subframe.clientHeight, "subframe should have scrollable content"); 88 89 // Send a wheel event roughly to where we think the trackbar is. We pick a 90 // point at the bottom, in the middle of the trackbar, where the slider is 91 // unlikely to be (since it starts at the top). 92 var posX = subframe.clientWidth + (ScrollbarWidth / 2); 93 var posY = subframe.clientHeight - 20; 94 95 var oldScrollTop = subframe.scrollTop; 96 97 await new Promise(resolve => { 98 sendWheelAndPaint(subframe, posX, posY, DefaultEvent, resolve); 99 }); 100 101 ok(subframe.scrollTop > oldScrollTop, "subframe should have scrolled"); 102 } 103 104 SimpleTest.waitForExplicitFinish(); 105 106 pushPrefs([["general.smoothScroll", false], 107 ["mousewheel.transaction.timeout", 0], 108 ["mousewheel.transaction.ignoremovedelay", 0], 109 ["test.events.async.enabled", true]]) 110 .then(waitUntilApzStable) 111 .then(test) 112 .then(SimpleTest.finish, SimpleTest.finishWithFailure); 113 114 </script> 115 </body> 116 </html>