scroll-behavior-9.html 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. html,body {
  8. color: black;
  9. background-color: white;
  10. font-size: 16px;
  11. padding: 0;
  12. margin: 0;
  13. }
  14. #a_box {
  15. position: relative;
  16. left: 10px;
  17. top: 10px;
  18. width: 20px;
  19. height: 20px;
  20. background: blue;
  21. }
  22. #another_box {
  23. position: relative;
  24. left: 2000px;
  25. top: 2000px;
  26. width: 20px;
  27. height: 20px;
  28. background: green;
  29. }
  30. </style>
  31. </head>
  32. <body>
  33. <div id="a_box"></div>
  34. <div id="another_box"></div>
  35. <script>
  36. function doTest() {
  37. if (document.location.search != '?ref') {
  38. // Scroll - expected to be smooth
  39. window.scrollTo({left: 500, top: 500});
  40. // Interrupt smooth scrolling
  41. window.scrollTo({left: window.scrollX, top: window.scrollY});
  42. // If scroll was not performed smoothly, we would be at 500,500 now
  43. }
  44. document.documentElement.removeAttribute("class");
  45. }
  46. window.scrollTo({left: 0, top: 0, behavior: "instant"});
  47. document.body.style.scrollBehavior = "smooth";
  48. window.addEventListener("MozReftestInvalidate", doTest, false);
  49. </script>
  50. </body>
  51. </html>