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