tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug717878_input_scroll.html (3541B)


      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 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 <!-- ditto, with appearance:none -->
     25 <input id="no-overflow2" type="text"
     26  size="10"
     27  style="
     28    -webkit-appearance:none;
     29    font-family: monospace;
     30    font-size: 1em;"
     31  value="Short">
     32 <!-- size=10, monospace font, and height=0.5em ensure overflow in both directions -->
     33 <input id="overflow" type="text"
     34  size="10"
     35  style="
     36    font-family: monospace;
     37    font-size: 3em;
     38    height: 0.5em;"
     39  value="This is a long string">
     40 <!-- ditto, with appearance:none -->
     41 <input id="overflow2" type="text"
     42  size="10"
     43  style="
     44    -webkit-appearance:none;
     45    font-family: monospace;
     46    font-size: 3em;
     47    height: 0.5em;"
     48  value="This is a long string">
     49 <pre id="test">
     50 <script type="application/javascript">
     51 
     52 /** Test for Bug 717878 */
     53 
     54 /**
     55 * Test an element's scroll properties for correctness
     56 *
     57 * @param element Element to test
     58 * @param prop Specify the property to test,
     59 *             i.e. "scrollLeft" or "scrollTop"
     60 * @param propMax Specify the scrollMax property to test,
     61 *                i.e. "scrollLeftMax" or "scrollTopMax"
     62 * @param is_overflow Specify whether the element is
     63 *                    scrollable in the above direction
     64 */
     65 function test_scroll(element, scroll, scrollMax, is_overflow) {
     66 
     67  is(element[scroll], 0, element.id + " initial " + scroll + " != 0");
     68  if (is_overflow) {
     69    isnot(element[scrollMax], 0, element.id + " " + scrollMax + " == 0");
     70  } else {
     71    is(element[scrollMax], 0, element.id + " " + scrollMax + " != 0");
     72  }
     73 
     74  element[scroll] = 10;
     75  if (is_overflow) {
     76    isnot(element[scroll], 0, element.id + " unable to scroll " + scroll);
     77  } else {
     78    is(element[scroll], 0, element.id + " able to scroll " + scroll);
     79  }
     80 
     81  element[scroll] = element[scrollMax];
     82  isfuzzy(element[scroll], element[scrollMax], 1, element.id + " did not scroll to " + scrollMax);
     83 
     84  element[scroll] = element[scrollMax] + 10;
     85  isfuzzy(element[scroll], element[scrollMax], 1, element.id + " scrolled past " + scrollMax);
     86 }
     87 
     88 var no_overflow = document.getElementById("no-overflow");
     89 test_scroll(no_overflow, "scrollLeft", "scrollLeftMax", /* is_overflow */ false);
     90 test_scroll(no_overflow, "scrollTop", "scrollTopMax", /* is_overflow */ false);
     91 
     92 var no_overflow2 = document.getElementById("no-overflow2");
     93 test_scroll(no_overflow2, "scrollLeft", "scrollLeftMax", /* is_overflow */ false);
     94 test_scroll(no_overflow2, "scrollTop", "scrollTopMax", /* is_overflow */ false);
     95 
     96 var overflow = document.getElementById("overflow");
     97 test_scroll(overflow, "scrollLeft", "scrollLeftMax", /* is_overflow */ true);
     98 test_scroll(overflow, "scrollTop", "scrollTopMax", /* is_overflow */ true);
     99 
    100 var overflow2 = document.getElementById("overflow2");
    101 test_scroll(overflow2, "scrollLeft", "scrollLeftMax", /* is_overflow */ true);
    102 test_scroll(overflow2, "scrollTop", "scrollTopMax", /* is_overflow */ true);
    103 
    104 </script>
    105 </pre>
    106 </body>
    107 </html>