scroll-behavior-10.html (1513B)
1 <!DOCTYPE HTML> 2 <html class="reftest-wait"> 3 <head> 4 <meta charset="utf-8"> 5 <title>Testcase for bug 1104356 smooth scrolling expected</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 #parent { 17 overflow: hidden; 18 width: 100px; 19 height: 100px; 20 } 21 22 #a_box { 23 position: relative; 24 left: 10px; 25 top: 10px; 26 width: 20px; 27 height: 20px; 28 background: blue; 29 } 30 31 #another_box { 32 position: relative; 33 left: 2000px; 34 top: 2000px; 35 width: 20px; 36 height: 20px; 37 background: green; 38 } 39 40 </style> 41 </head> 42 <body> 43 <div id="parent"> 44 <div id="a_box"></div> 45 <div id="another_box"></div> 46 </div> 47 <script> 48 function doTest() { 49 if (document.location.search != '?ref') { 50 document.getElementById('parent').scrollTo({left: 10, top: 10, behavior: 'smooth'}); 51 } else { 52 document.getElementById('parent').scrollLeft = 10; 53 document.getElementById('parent').scrollTop = 10; 54 } 55 56 // Allow smooth scrolling to complete before testing result 57 setTimeout(function() { 58 document.documentElement.removeAttribute("class"); 59 }, 500); 60 } 61 window.addEventListener("MozReftestInvalidate", doTest); 62 </script> 63 </body> 64 </html>