tor-browser

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

test_bug613019.html (3013B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=613019
      5 -->
      6 <head>
      7  <title>Test for Bug 613019</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script src="/tests/SimpleTest/EventUtils.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=613019">Mozilla Bug 613019</a>
     14 <div id="content">
     15  <input type="text" maxlength="2" style="width:200px" value="Test">
     16  <textarea maxlength="2" style="width:200px">Test</textarea>
     17  <input type="text" minlength="6" style="width:200px" value="Test">
     18  <textarea minlength="6" style="width:200px">Test</textarea>
     19 </div>
     20 <pre id="test">
     21 <script class="testbody" type="text/javascript">
     22 
     23 /** Test for Bug 613019 */
     24 
     25 function testInteractivityOfMaxLength(elem) {
     26  // verify that user interactivity is necessary for validity state to apply.
     27  is(elem.value, "Test", "Element has incorrect starting value.");
     28  is(elem.validity.tooLong, false, "Element should not be tooLong.");
     29 
     30  elem.setSelectionRange(elem.value.length, elem.value.length)
     31  elem.focus();
     32 
     33  synthesizeKey("KEY_Backspace");
     34  is(elem.value, "Tes", "Element value was not changed correctly.");
     35  is(elem.validity.tooLong, true, "Element should still be tooLong.");
     36 
     37  synthesizeKey("KEY_Backspace");
     38  is(elem.value, "Te", "Element value was not changed correctly.");
     39  is(elem.validity.tooLong, false, "Element should no longer be tooLong.");
     40 
     41  elem.value = "Test";
     42  is(elem.validity.tooLong, false,
     43     "Element should not be tooLong after non-interactive value change.");
     44 }
     45 
     46 function testInteractivityOfMinLength(elem) {
     47  // verify that user interactivity is necessary for validity state to apply.
     48  is(elem.value, "Test", "Element has incorrect starting value.");
     49  is(elem.validity.tooLong, false, "Element should not be tooShort.");
     50 
     51  elem.setSelectionRange(elem.value.length, elem.value.length)
     52  elem.focus();
     53 
     54  sendString("e");
     55  is(elem.value, "Teste", "Element value was not changed correctly.");
     56  is(elem.validity.tooShort, true, "Element should still be tooShort.");
     57 
     58  sendString("d");
     59  is(elem.value, "Tested", "Element value was not changed correctly.");
     60  is(elem.validity.tooShort, false, "Element should no longer be tooShort.");
     61 
     62  elem.value = "Test";
     63  is(elem.validity.tooShort, false,
     64     "Element should not be tooShort after non-interactive value change.");
     65 }
     66 
     67 function test() {
     68  window.getSelection().removeAllRanges();
     69  testInteractivityOfMaxLength(document.querySelector("input[type=text][maxlength]"));
     70  testInteractivityOfMaxLength(document.querySelector("textarea[maxlength]"));
     71  testInteractivityOfMinLength(document.querySelector("input[type=text][minlength]"));
     72  testInteractivityOfMinLength(document.querySelector("textarea[minlength]"));
     73  SimpleTest.finish();
     74 }
     75 
     76 window.onload = function() {
     77  SimpleTest.waitForExplicitFinish();
     78  setTimeout(test, 0);
     79 };
     80 
     81 </script>
     82 </pre>
     83 </body>
     84 </html>