test_bug159346.xul 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?xml version="1.0"?>
  2. <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
  3. <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
  4. <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  5. xmlns:html="http://www.w3.org/1999/xhtml"
  6. title="Test for Bug 159346">
  7. <!--
  8. https://bugzilla.mozilla.org/show_bug.cgi?id=159346
  9. -->
  10. <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  11. <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
  12. <scrollbar id="scrollbar" curpos="0" maxpos="500"/>
  13. <script class="testbody" type="application/javascript">
  14. <![CDATA[
  15. var scrollbar = document.getElementById("scrollbar");
  16. var downButton =
  17. document.getAnonymousElementByAttribute(scrollbar, "sbattr",
  18. "scrollbar-down-bottom");
  19. function init()
  20. {
  21. downButton.style.display = "-moz-box";
  22. SimpleTest.executeSoon(doTest1);
  23. }
  24. function getCurrentPos()
  25. {
  26. return Number(scrollbar.getAttribute("curpos"));
  27. }
  28. function doTest1()
  29. {
  30. var lastPos = 0;
  31. synthesizeMouseAtCenter(downButton, { type: "mousedown" });
  32. ok(getCurrentPos() > lastPos,
  33. "scrollbar didn't change curpos by mousedown #1");
  34. lastPos = getCurrentPos();
  35. setTimeout(function () {
  36. ok(getCurrentPos() > lastPos,
  37. "scrollbar didn't change curpos by auto repeat #1");
  38. synthesizeMouseAtCenter(downButton, { type: "mouseup" });
  39. lastPos = getCurrentPos();
  40. setTimeout(function () {
  41. is(getCurrentPos(), lastPos,
  42. "scrollbar changed curpos after mouseup #1");
  43. SimpleTest.executeSoon(doTest2);
  44. }, 1000);
  45. }, 1000);
  46. }
  47. function doTest2()
  48. {
  49. SpecialPowers.setIntPref("ui.scrollbarButtonAutoRepeatBehavior", 0);
  50. scrollbar.setAttribute("curpos", 0);
  51. var lastPos = 0;
  52. synthesizeMouseAtCenter(downButton, { type: "mousedown" });
  53. ok(getCurrentPos() > lastPos,
  54. "scrollbar didn't change curpos by mousedown #2");
  55. lastPos = getCurrentPos();
  56. synthesizeMouse(downButton, -10, -10, { type: "mousemove" });
  57. lastPos = getCurrentPos();
  58. setTimeout(function () {
  59. is(getCurrentPos(), lastPos,
  60. "scrollbar changed curpos by auto repeat when cursor is outside of scrollbar button #2");
  61. synthesizeMouseAtCenter(downButton, { type: "mousemove" });
  62. lastPos = getCurrentPos();
  63. setTimeout(function () {
  64. ok(getCurrentPos() > lastPos,
  65. "scrollbar didn't change curpos by mousemove after cursor is back on the scrollbar button #2");
  66. synthesizeMouseAtCenter(downButton, { type: "mouseup" });
  67. SimpleTest.executeSoon(doTest3);
  68. }, 1000);
  69. }, 1000);
  70. }
  71. function doTest3()
  72. {
  73. SpecialPowers.setIntPref("ui.scrollbarButtonAutoRepeatBehavior", 1);
  74. scrollbar.setAttribute("curpos", 0);
  75. var lastPos = 0;
  76. synthesizeMouseAtCenter(downButton, { type: "mousedown" });
  77. ok(getCurrentPos() > lastPos,
  78. "scrollbar didn't change curpos by mousedown #3");
  79. synthesizeMouse(downButton, -10, -10, { type: "mousemove" });
  80. lastPos = getCurrentPos();
  81. setTimeout(function () {
  82. ok(getCurrentPos() > lastPos,
  83. "scrollbar didn't change curpos by auto repeat when cursor is outside of scrollbar button #3");
  84. synthesizeMouseAtCenter(downButton, { type: "mousemove" });
  85. lastPos = getCurrentPos();
  86. setTimeout(function () {
  87. ok(getCurrentPos() > lastPos,
  88. "scrollbar didn't change curpos by mousemove after cursor is back on the scrollbar button #3");
  89. synthesizeMouseAtCenter(downButton, { type: "mouseup" });
  90. SpecialPowers.clearUserPref("ui.scrollbarButtonAutoRepeatBehavior");
  91. SimpleTest.finish();
  92. }, 1000);
  93. }, 1000);
  94. }
  95. SimpleTest.waitForExplicitFinish();
  96. ]]>
  97. </script>
  98. <body id="html_body" xmlns="http://www.w3.org/1999/xhtml">
  99. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=159346">Mozilla Bug 159346</a>
  100. <p id="display"></p>
  101. <pre id="test">
  102. </pre>
  103. <script>
  104. addLoadEvent(init);
  105. </script>
  106. </body>
  107. </window>