scroll-behavior-3.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <!DOCTYPE HTML>
  2. <html class="reftest-wait">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Testcase for bug 1010538, instant scrolling expected</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: 0px;
  17. top: 0px;
  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. .scroll_box {
  31. width: 50px;
  32. height: 50px;
  33. overflow: scroll;
  34. will-change: scroll-position;
  35. }
  36. #scroll_1, #scroll_4, #scroll_6, #scroll_8 {
  37. scroll-behavior: auto;
  38. }
  39. #scroll_3 {
  40. scroll-behavior: smooth;
  41. }
  42. </style>
  43. </head>
  44. <body>
  45. <div id="scroll_1" class="scroll_box">
  46. <div id="box1a" class="a_box"></div>
  47. <div id="box1b" class="another_box"></div>
  48. </div>
  49. <div id="scroll_2" class="scroll_box">
  50. <div id="box2a" class="a_box"></div>
  51. <div id="box2b" class="another_box"></div>
  52. </div>
  53. <div id="scroll_3" class="scroll_box">
  54. <div id="box3a" class="a_box"></div>
  55. <div id="box3b" class="another_box"></div>
  56. </div>
  57. <div id="scroll_4" class="scroll_box">
  58. <div id="box4a" class="a_box"></div>
  59. <div id="box4b" class="another_box"></div>
  60. </div>
  61. <div id="scroll_5" class="scroll_box">
  62. <div id="box5a" class="a_box"></div>
  63. <div id="box5b" class="another_box"></div>
  64. </div>
  65. <div id="scroll_6" class="scroll_box">
  66. <div id="box6a" class="a_box"></div>
  67. <div id="box6b" class="another_box"></div>
  68. </div>
  69. <div id="scroll_7" class="scroll_box">
  70. <div id="box7a" class="a_box"></div>
  71. <div id="box7b" class="another_box"></div>
  72. </div>
  73. <div id="scroll_8" class="scroll_box">
  74. <div id="box8a" class="a_box"></div>
  75. <div id="box8b" class="another_box"></div>
  76. </div>
  77. <div id="scroll_9" class="scroll_box">
  78. <div id="box9a" class="a_box"></div>
  79. <div id="box9b" class="another_box"></div>
  80. </div>
  81. <div id="scroll_10" class="scroll_box">
  82. <div id="box10a" class="a_box"></div>
  83. <div id="box10b" class="another_box"></div>
  84. </div>
  85. <script>
  86. function doTest() {
  87. if (document.location.search != '?ref') {
  88. document.getElementById("box1b").scrollIntoView({block: "end"});
  89. document.getElementById("box2b").scrollIntoView({block: "end"});
  90. document.getElementById("box3b").scrollIntoView({block: "end", behavior: "instant"});
  91. document.getElementById("box4b").scrollIntoView({block: "end", behavior: "instant"});
  92. document.getElementById("box5b").scrollIntoView({block: "end", behavior: "instant"});
  93. document.getElementById("box6b").scrollIntoView({block: "end", behavior: "auto"});
  94. document.getElementById("box7b").scrollIntoView({block: "end", behavior: "auto"});
  95. document.getElementById("box8b").scrollIntoView(false);
  96. document.getElementById("box9b").scrollIntoView(false);
  97. // Scroll_10 is a control, expected to scroll smoothly
  98. document.getElementById("box10b").scrollIntoView({block: "end", behavior: "smooth"});
  99. // Interrupt any smooth scrolling
  100. for (var i=1; i <= 10; i++) {
  101. document.getElementById("scroll_" + i).scrollLeft
  102. = document.getElementById("scroll_" + i).scrollLeft;
  103. document.getElementById("scroll_" + i).scrollTop
  104. = document.getElementById("scroll_" + i).scrollTop;
  105. }
  106. } else {
  107. // Scroll all boxes except box 10
  108. for (var i=1; i <= 9; i++) {
  109. document.getElementById("box" + i + "b").scrollIntoView({block: "end", behavior: "instant"});
  110. }
  111. }
  112. document.documentElement.removeAttribute("class");
  113. }
  114. for (var i=1; i <= 10; i++) {
  115. document.getElementById("box" + i + "a")
  116. .scrollIntoView({block: "start", behavior: "instant"});
  117. }
  118. window.addEventListener("MozReftestInvalidate", doTest, false);
  119. </script>
  120. </body>
  121. </html>