test_bug1013412.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=1013412
  5. -->
  6. <head>
  7. <title>Test for Bug 1013412</title>
  8. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  10. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  11. <style>
  12. #content {
  13. height: 800px;
  14. overflow: scroll;
  15. }
  16. #scroller {
  17. height: 2000px;
  18. background: repeating-linear-gradient(#EEE, #EEE 100px, #DDD 100px, #DDD 200px);
  19. }
  20. #scrollbox {
  21. margin-top: 200px;
  22. width: 500px;
  23. height: 500px;
  24. border-radius: 250px;
  25. box-shadow: inset 0 0 0 60px #555;
  26. background: #777;
  27. }
  28. #circle {
  29. position: relative;
  30. left: 240px;
  31. top: 20px;
  32. border: 10px solid white;
  33. border-radius: 10px;
  34. width: 0px;
  35. height: 0px;
  36. transform-origin: 10px 230px;
  37. will-change: transform;
  38. }
  39. </style>
  40. </head>
  41. <body>
  42. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1013412">Mozilla Bug 1013412</a>
  43. <p id="display"></p>
  44. <div id="content">
  45. <p>Scrolling the page should be async, but scrolling over the dark circle should not scroll the page and instead rotate the white ball.</p>
  46. <div id="scroller">
  47. <div id="scrollbox">
  48. <div id="circle"></div>
  49. </div>
  50. </div>
  51. </div>
  52. <pre id="test">
  53. <script type="application/javascript;version=1.7">
  54. /** Test for Bug 1013412 **/
  55. var rotation = 0;
  56. var rotationAdjusted = false;
  57. var incrementForMode = function (mode) {
  58. switch (mode) {
  59. case WheelEvent.DOM_DELTA_PIXEL: return 1;
  60. case WheelEvent.DOM_DELTA_LINE: return 15;
  61. case WheelEvent.DOM_DELTA_PAGE: return 400;
  62. }
  63. return 0;
  64. };
  65. document.getElementById("scrollbox").addEventListener("wheel", function (e) {
  66. rotation += e.deltaY * incrementForMode(e.deltaMode) * 0.2;
  67. document.getElementById("circle").style.transform = "rotate(" + rotation + "deg)";
  68. rotationAdjusted = true;
  69. e.preventDefault();
  70. });
  71. var iteration = 0;
  72. function runTest() {
  73. var content = document.getElementById('content');
  74. if (iteration < 300) { // enough iterations that we would scroll to the bottom of 'content'
  75. iteration++;
  76. synthesizeWheel(content, 100, 10,
  77. { deltaMode: WheelEvent.DOM_DELTA_LINE,
  78. deltaY: 1.0, lineOrPageDeltaY: 1 });
  79. setTimeout(runTest, 0);
  80. return;
  81. }
  82. var scrollbox = document.getElementById('scrollbox');
  83. is(content.scrollTop < content.scrollTopMax, true, "We should not have scrolled to the bottom of the scrollframe");
  84. is(rotationAdjusted, true, "The rotation should have been adjusted");
  85. SimpleTest.finish();
  86. }
  87. function startTest() {
  88. // If we allow smooth scrolling the "smooth" scrolling may cause the page to
  89. // glide past the scrollbox (which is supposed to stop the scrolling) and so
  90. // we might end up at the bottom of the page.
  91. SpecialPowers.pushPrefEnv({"set": [["general.smoothScroll", false]]}, runTest);
  92. }
  93. SimpleTest.waitForExplicitFinish();
  94. SimpleTest.waitForFocus(startTest, window);
  95. </script>
  96. </pre>
  97. </body>
  98. </html>