test_bug511075.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=511075
  5. -->
  6. <head>
  7. <title>Test for Bug 511075</title>
  8. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  10. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  11. <style>
  12. #scroller {
  13. border: 1px solid black;
  14. }
  15. </style>
  16. </head>
  17. <body onload="runTests()">
  18. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=511075">Mozilla Bug 511075</a>
  19. <p id="display"></p>
  20. <div id="content" style="display: none">
  21. </div>
  22. <pre id="test">
  23. <script type="application/javascript">
  24. /** Test for Bug 511075 **/
  25. SimpleTest.waitForExplicitFinish();
  26. SimpleTest.requestFlakyTimeout("untriaged");
  27. var tests = [
  28. function() {
  29. ok(true, "Setting location.hash should scroll.");
  30. nextTest();
  31. // Click the top scroll arrow.
  32. var x = scroller.getBoundingClientRect().width - 5;
  33. var y = 5;
  34. // On MacOSX the top scroll arrow can be below the slider just above
  35. // the bottom scroll arrow.
  36. if (navigator.platform.indexOf("Mac") >= 0)
  37. y = scroller.getBoundingClientRect().height - 40;
  38. synthesizeMouse(scroller, x, y, { type : "mousedown" }, window);
  39. synthesizeMouse(scroller, x, y, { type: "mouseup" }, window);
  40. },
  41. function() {
  42. ok(true, "Clicking the top scroll arrow should scroll.");
  43. nextTest();
  44. // Click the bottom scroll arrow.
  45. var x = scroller.getBoundingClientRect().width - 5;
  46. var y = scroller.getBoundingClientRect().height - 25;
  47. synthesizeMouse(scroller, x, y, { type : "mousedown" }, window);
  48. synthesizeMouse(scroller, x, y, { type: "mouseup" }, window);
  49. },
  50. function() {
  51. ok(true, "Clicking the bottom scroll arrow should scroll.");
  52. nextTest();
  53. // Click the scrollbar.
  54. var x = scroller.getBoundingClientRect().width - 5;
  55. synthesizeMouse(scroller, x, 40, { type : "mousedown" }, window);
  56. synthesizeMouse(scroller, x, 40, { type: "mouseup" }, window);
  57. },
  58. function() {
  59. ok(true, "Clicking the scrollbar should scroll");
  60. nextTest();
  61. // Click the scrollbar.
  62. var x = scroller.getBoundingClientRect().width - 5;
  63. var y = scroller.getBoundingClientRect().height - 50;
  64. synthesizeMouse(scroller, x, y, { type : "mousedown" }, window);
  65. synthesizeMouse(scroller, x, y, { type: "mouseup" }, window);
  66. },
  67. function() {
  68. scroller.onscroll = null;
  69. ok(true, "Clicking the scrollbar should scroll");
  70. finish();
  71. }
  72. ];
  73. document.onmousedown = function () { return false; };
  74. document.onmouseup = function () { return true; };
  75. var scroller;
  76. var timer = 0;
  77. function failure() {
  78. ok(false, scroller.onscroll + " did not run!");
  79. scroller.onscroll = null;
  80. finish();
  81. }
  82. function nextTest() {
  83. clearTimeout(timer);
  84. scroller.onscroll = tests.shift();
  85. timer = setTimeout(failure, 2000);
  86. }
  87. function runTests() {
  88. scroller = document.getElementById("scroller");
  89. nextTest();
  90. window.location.hash = "initialPosition";
  91. }
  92. function finish() {
  93. document.onmousedown = null;
  94. document.onmouseup = null;
  95. clearTimeout(timer);
  96. window.location.hash = "topPosition";
  97. SimpleTest.finish();
  98. }
  99. </script>
  100. </pre>
  101. <div id="scroller" style="overflow: scroll; width: 100px; height: 150px;">
  102. <a id="topPosition" name="topPosition">top</a>
  103. <div style="width: 20000px; height: 20000px;"></div>
  104. <a id="initialPosition" name="initialPosition">initialPosition</a>
  105. <div style="width: 20000px; height: 20000px;"></div>
  106. </div>
  107. </body>
  108. </html>