test_bug717878_input_scroll.html 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=717878
  5. -->
  6. <head>
  7. <meta charset="utf-8">
  8. <title>Test for Bug 717878</title>
  9. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  10. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  11. </head>
  12. <body>
  13. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717878">Mozilla Bug 717878</a>
  14. <p id="display"></p>
  15. <div id="content" style="display: none">
  16. </div>
  17. <!-- size=10 and monospace font ensure there's no overflow in either direction -->
  18. <input id="no-overflow" type="text"
  19. size="10"
  20. style="
  21. font-family: monospace;
  22. font-size: 1em;"
  23. value="Short">
  24. <!-- size=10, monospace font, and height=0.5em ensure overflow in both directions -->
  25. <input id="overflow" type="text"
  26. size="10"
  27. style="
  28. font-family: monospace;
  29. font-size: 1em;
  30. height: 0.5em;"
  31. value="This is a long string">
  32. <pre id="test">
  33. <script type="application/javascript">
  34. /** Test for Bug 717878 **/
  35. /**
  36. * Test an element's scroll properties for correctness
  37. *
  38. * @param element Element to test
  39. * @param prop Specify the property to test,
  40. * i.e. "scrollLeft" or "scrollTop"
  41. * @param propMax Specify the scrollMax property to test,
  42. * i.e. "scrollLeftMax" or "scrollTopMax"
  43. * @param is_overflow Specify whether the element is
  44. * scrollable in the above direction
  45. */
  46. function test_scroll(element, scroll, scrollMax, is_overflow) {
  47. is(element[scroll], 0, element.id + " initial " + scroll + " != 0");
  48. if (is_overflow) {
  49. isnot(element[scrollMax], 0, element.id + " " + scrollMax + " == 0");
  50. } else {
  51. is(element[scrollMax], 0, element.id + " " + scrollMax + " != 0");
  52. }
  53. element[scroll] = 10;
  54. if (is_overflow) {
  55. isnot(element[scroll], 0, element.id + " unable to scroll " + scroll);
  56. } else {
  57. is(element[scroll], 0, element.id + " able to scroll " + scroll);
  58. }
  59. element[scroll] = element[scrollMax];
  60. is(element[scroll], element[scrollMax], element.id + " did not scroll to " + scrollMax);
  61. element[scroll] = element[scrollMax] + 10;
  62. is(element[scroll], element[scrollMax], element.id + " scrolled past " + scrollMax);
  63. }
  64. var no_overflow = document.getElementById("no-overflow");
  65. test_scroll(no_overflow, "scrollLeft", "scrollLeftMax", /* is_overflow */ false);
  66. test_scroll(no_overflow, "scrollTop", "scrollTopMax", /* is_overflow */ false);
  67. var overflow = document.getElementById("overflow");
  68. test_scroll(overflow, "scrollLeft", "scrollLeftMax", /* is_overflow */ true);
  69. test_scroll(overflow, "scrollTop", "scrollTopMax", /* is_overflow */ true);
  70. </script>
  71. </pre>
  72. </body>
  73. </html>