Bug 717878 - Add test for scrolling single-line inputs; r=mats
authorJim Chen <nchen@mozilla.com>
Sat, 26 Oct 2013 14:34:51 -0400
changeset 166170 f34f8e6cd6079e034f77dc9e87cc818c3959e235
parent 166169 301f6ed0096870e14f7174cf604de7294b2db740
child 166171 381f84dc910e5a6688f8097ea616fc39901c7ced
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs717878
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 717878 - Add test for scrolling single-line inputs; r=mats
layout/forms/test/mochitest.ini
layout/forms/test/test_bug717878_input_scroll.html
--- a/layout/forms/test/mochitest.ini
+++ b/layout/forms/test/mochitest.ini
@@ -27,13 +27,14 @@ support-files =
 [test_bug571352.html]
 [test_bug572406.html]
 [test_bug572649.html]
 [test_bug595310.html]
 [test_bug620936.html]
 [test_bug644542.html]
 [test_bug672810.html]
 [test_bug704049.html]
+[test_bug717878_input_scroll.html]
 [test_bug869314.html]
 [test_bug903715.html]
 [test_listcontrol_search.html]
 [test_select_prevent_default.html]
 [test_textarea_resize.html]
new file mode 100644
--- /dev/null
+++ b/layout/forms/test/test_bug717878_input_scroll.html
@@ -0,0 +1,82 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=717878
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 717878</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717878">Mozilla Bug 717878</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<!-- size=10 and monospace font ensure there's no overflow in either direction -->
+<input id="no-overflow" type="text"
+  size="10"
+  style="
+    font-family: monospace;
+    font-size: 1em;"
+  value="Short">
+<!-- size=10, monospace font, and height=0.5em ensure overflow in both directions -->
+<input id="overflow" type="text"
+  size="10"
+  style="
+    font-family: monospace;
+    font-size: 1em;
+    height: 0.5em;"
+  value="This is a long string">
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 717878 **/
+
+/**
+ * Test an element's scroll properties for correctness
+ *
+ * @param element Element to test
+ * @param prop Specify the property to test,
+ *             i.e. "scrollLeft" or "scrollTop"
+ * @param propMax Specify the scrollMax property to test,
+ *                i.e. "scrollLeftMax" or "scrollTopMax"
+ * @param is_overflow Specify whether the element is
+ *                    scrollable in the above direction
+ */
+function test_scroll(element, scroll, scrollMax, is_overflow) {
+
+  is(element[scroll], 0, element.id + " initial " + scroll + " != 0");
+  if (is_overflow) {
+    isnot(element[scrollMax], 0, element.id + " " + scrollMax + " == 0");
+  } else {
+    is(element[scrollMax], 0, element.id + " " + scrollMax + " != 0");
+  }
+
+  element[scroll] = 10;
+  if (is_overflow) {
+    isnot(element[scroll], 0, element.id + " unable to scroll " + scroll);
+  } else {
+    is(element[scroll], 0, element.id + " able to scroll " + scroll);
+  }
+
+  element[scroll] = element[scrollMax];
+  is(element[scroll], element[scrollMax], element.id + " did not scroll to " + scrollMax);
+
+  element[scroll] = element[scrollMax] + 10;
+  is(element[scroll], element[scrollMax], element.id + " scrolled past " + scrollMax);
+}
+
+var no_overflow = document.getElementById("no-overflow");
+test_scroll(no_overflow, "scrollLeft", "scrollLeftMax", /* is_overflow */ false);
+test_scroll(no_overflow, "scrollTop", "scrollTopMax", /* is_overflow */ false);
+
+var overflow = document.getElementById("overflow");
+test_scroll(overflow, "scrollLeft", "scrollLeftMax", /* is_overflow */ true);
+test_scroll(overflow, "scrollTop", "scrollTopMax", /* is_overflow */ true);
+
+</script>
+</pre>
+</body>
+</html>