scroll-behavior-9.html (1479B)
1 <!DOCTYPE HTML> 2 <html class="reftest-wait"> 3 <head> 4 <meta charset="utf-8"> 5 <title>Testcase for bug 1082098, smooth scrolling expected after dynamically setting scroll-behavior on body</title> 6 <style type="text/css"> 7 8 html,body { 9 color: black; 10 background-color: white; 11 font-size: 16px; 12 padding: 0; 13 margin: 0; 14 } 15 16 #a_box { 17 position: relative; 18 left: 10px; 19 top: 10px; 20 width: 20px; 21 height: 20px; 22 background: blue; 23 } 24 25 #another_box { 26 position: relative; 27 left: 2000px; 28 top: 2000px; 29 width: 20px; 30 height: 20px; 31 background: green; 32 } 33 34 </style> 35 </head> 36 <body> 37 <div id="a_box"></div> 38 <div id="another_box"></div> 39 <script> 40 function doTest() { 41 if (document.location.search != '?ref') { 42 // Scroll - expected to be smooth 43 window.scrollTo({left: 500, top: 500}); 44 // Interrupt smooth scrolling 45 window.scrollTo({left: window.scrollX, top: window.scrollY}); 46 // If scroll was not performed smoothly, we would be at 500,500 now 47 } 48 document.documentElement.removeAttribute("class"); 49 } 50 window.scrollTo({left: 0, top: 0, behavior: "instant"}); 51 document.documentElement.style.scrollBehavior = "smooth"; 52 window.addEventListener("MozReftestInvalidate", doTest); 53 </script> 54 </body> 55 </html>