helper_position_fixed_scroll_handoff-4.html (2075B)
1 <!DOCTYPE HTML> 2 <head> 3 <title>APZ overscroll handoff for fixed elements</title> 4 <script type="application/javascript" src="apz_test_utils.js"></script> 5 <script type="application/javascript" src="apz_test_native_event_utils.js"></script> 6 <script src="/tests/SimpleTest/paint_listener.js"></script> 7 <meta name="viewport" content="width=device-width"/> 8 <style> 9 html, body { 10 margin: 0; 11 } 12 #scrolled { 13 overflow: auto; 14 background: blue; 15 width: 400px; 16 height: 400px; 17 } 18 .spacer { 19 height: 2000px; 20 } 21 #fixed { 22 position: fixed; 23 background: red; 24 top: 0; 25 left: 0; 26 } 27 #subframe { 28 overflow: auto; 29 width: 200px; 30 height: 200px; 31 } 32 </style> 33 </head> 34 <div id="scrolled"> 35 <div id="fixed"> 36 <div> 37 <div id="subframe"> 38 <div id="firstspacer" class="spacer"></div> 39 </div> 40 </div> 41 </div> 42 <div id="secondspacer" class="spacer"></div> 43 </div> 44 <script type="application/javascript"> 45 46 async function test() { 47 // Scroll to the bottom of the fixed position element that should not 48 // allow overscroll handoff. 49 subframe.scrollTop = subframe.scrollHeight; 50 51 // After scrolling to bottom tick the refresh driver. 52 await promiseFrame(); 53 54 info("Before scroll: subframe=" + subframe.scrollTop + " scrolled=" + 55 scrolled.scrollTop); 56 57 // Async scroll the fixed element by 200 pixels using the mouse-wheel. 58 // This should not handoff the overscroll. 59 await promiseMoveMouseAndScrollWheelOver(subframe, 50, 50, false, 200); 60 61 // Make sure scrolling that has happened is propagated to the main thread. 62 await promiseApzFlushedRepaints(); 63 64 // Try another gesture to ensure the overscroll handoff runs. 65 await promiseMoveMouseAndScrollWheelOver(subframe, 50, 50, false, 200); 66 await promiseApzFlushedRepaints(); 67 68 info("After scroll: subframe=" + subframe.scrollTop + " scrolled=" + 69 scrolled.scrollTop); 70 71 // Ensure that the scrolled element has not scrolled. 72 is(scrolled.scrollTop, 0, "scrolled: The overscroll should not handoff"); 73 } 74 75 waitUntilApzStable() 76 .then(test) 77 .then(subtestDone, subtestFailed); 78 79 </script>