tor-browser

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

test_bug536895.html (1568B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=536895
      5 -->
      6 <head>
      7  <title>Test for Bug 536895</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     10 </head>
     11 <body>
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=536895">Mozilla Bug 536895</a>
     13 <p id="display"></p>
     14 <div id="content" style="display: none">
     15 <textarea id="t"></textarea>
     16 <input id="i" type="text">
     17 <input id="p" type="password">
     18 </div>
     19 <pre id="test">
     20 <script type="application/javascript">
     21 
     22 /** Test for Bug 536895 */
     23 
     24 function checkNegativeMaxLengthException(element)
     25 {
     26  caught = false;
     27  try {
     28    element.setAttribute('maxLength', -10);
     29  } catch(e) {
     30    caught = true;
     31  }
     32  ok(!caught, "Setting maxLength attribute to a negative value shouldn't throw an exception");
     33 
     34  caught = false;
     35  try {
     36    element.maxLength = -20;
     37  } catch(e) {
     38    is(e.name, "IndexSizeError", "Should be an IndexSizeError exception");
     39    caught = true;
     40  }
     41  ok(caught, "Setting negative maxLength from the DOM should throw an exception");
     42 
     43  is(element.getAttribute('maxLength'), "-10", "When the exception is raised, the maxLength attribute shouldn't change");
     44 }
     45 
     46 /* TODO: correct behavior may be checked for email, telephone, url and search input types */
     47 checkNegativeMaxLengthException(document.getElementById('t'));
     48 checkNegativeMaxLengthException(document.getElementById('i'));
     49 checkNegativeMaxLengthException(document.getElementById('p'));
     50 
     51 </script>
     52 </pre>
     53 </body>
     54 </html>