1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/forms/test/test_bug717878_input_scroll.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,82 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=717878 1.8 +--> 1.9 +<head> 1.10 + <meta charset="utf-8"> 1.11 + <title>Test for Bug 717878</title> 1.12 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717878">Mozilla Bug 717878</a> 1.17 +<p id="display"></p> 1.18 +<div id="content" style="display: none"> 1.19 +</div> 1.20 +<!-- size=10 and monospace font ensure there's no overflow in either direction --> 1.21 +<input id="no-overflow" type="text" 1.22 + size="10" 1.23 + style=" 1.24 + font-family: monospace; 1.25 + font-size: 1em;" 1.26 + value="Short"> 1.27 +<!-- size=10, monospace font, and height=0.5em ensure overflow in both directions --> 1.28 +<input id="overflow" type="text" 1.29 + size="10" 1.30 + style=" 1.31 + font-family: monospace; 1.32 + font-size: 1em; 1.33 + height: 0.5em;" 1.34 + value="This is a long string"> 1.35 +<pre id="test"> 1.36 +<script type="application/javascript"> 1.37 + 1.38 +/** Test for Bug 717878 **/ 1.39 + 1.40 +/** 1.41 + * Test an element's scroll properties for correctness 1.42 + * 1.43 + * @param element Element to test 1.44 + * @param prop Specify the property to test, 1.45 + * i.e. "scrollLeft" or "scrollTop" 1.46 + * @param propMax Specify the scrollMax property to test, 1.47 + * i.e. "scrollLeftMax" or "scrollTopMax" 1.48 + * @param is_overflow Specify whether the element is 1.49 + * scrollable in the above direction 1.50 + */ 1.51 +function test_scroll(element, scroll, scrollMax, is_overflow) { 1.52 + 1.53 + is(element[scroll], 0, element.id + " initial " + scroll + " != 0"); 1.54 + if (is_overflow) { 1.55 + isnot(element[scrollMax], 0, element.id + " " + scrollMax + " == 0"); 1.56 + } else { 1.57 + is(element[scrollMax], 0, element.id + " " + scrollMax + " != 0"); 1.58 + } 1.59 + 1.60 + element[scroll] = 10; 1.61 + if (is_overflow) { 1.62 + isnot(element[scroll], 0, element.id + " unable to scroll " + scroll); 1.63 + } else { 1.64 + is(element[scroll], 0, element.id + " able to scroll " + scroll); 1.65 + } 1.66 + 1.67 + element[scroll] = element[scrollMax]; 1.68 + is(element[scroll], element[scrollMax], element.id + " did not scroll to " + scrollMax); 1.69 + 1.70 + element[scroll] = element[scrollMax] + 10; 1.71 + is(element[scroll], element[scrollMax], element.id + " scrolled past " + scrollMax); 1.72 +} 1.73 + 1.74 +var no_overflow = document.getElementById("no-overflow"); 1.75 +test_scroll(no_overflow, "scrollLeft", "scrollLeftMax", /* is_overflow */ false); 1.76 +test_scroll(no_overflow, "scrollTop", "scrollTopMax", /* is_overflow */ false); 1.77 + 1.78 +var overflow = document.getElementById("overflow"); 1.79 +test_scroll(overflow, "scrollLeft", "scrollLeftMax", /* is_overflow */ true); 1.80 +test_scroll(overflow, "scrollTop", "scrollTopMax", /* is_overflow */ true); 1.81 + 1.82 +</script> 1.83 +</pre> 1.84 +</body> 1.85 +</html>