OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>input max length</title> |
| 5 <link rel="author" title="Sam Gibson" href="mailto:sam@ifdown.net"> |
| 6 <link rel=help href="https://html.spec.whatwg.org/multipage/forms.html#the-m
axlength-and-minlength-attributes"> |
| 7 <script src="../../../../../../resources/testharness.js"></script> |
| 8 <script src="../../../../../../resources/testharnessreport.js"></script> |
| 9 </head> |
| 10 |
| 11 <body> |
| 12 <h1>Text input element</h1> |
| 13 |
| 14 <div style="display: none"> |
| 15 <input id="none" /> |
| 16 <input id="negative" type="-5" /> |
| 17 <input id="non-numeric" type="not-a-number" /> |
| 18 <input id="assign-negative" /> |
| 19 <input id="assign-non-numeric" /> |
| 20 </div> |
| 21 |
| 22 <div id="log"></div> |
| 23 |
| 24 <script type="text/javascript"> |
| 25 test( |
| 26 function() { |
| 27 assert_equals(document.getElementById("none").maxLength, -1); |
| 28 }, "Unset maxlength is -1"); |
| 29 |
| 30 test( |
| 31 function() { |
| 32 assert_equals(document.getElementById("negative").maxLength, -1); |
| 33 }, "Negative maxlength is always -1"); |
| 34 |
| 35 test( |
| 36 function() { |
| 37 assert_equals(document.getElementById("non-numeric").maxLength, -1); |
| 38 }, "Non-numeric maxlength is -1"); |
| 39 |
| 40 test( |
| 41 function() { |
| 42 assert_throws("INDEX_SIZE_ERR", function() { |
| 43 document.getElementById("assign-negative").maxLength = -5; |
| 44 }); |
| 45 }, "Assigning negative integer throws IndexSizeError"); |
| 46 |
| 47 test( |
| 48 function() { |
| 49 document.getElementById("assign-non-numeric").maxLength = "not-a-num
ber"; |
| 50 assert_equals(document.getElementById("assign-non-numeric").maxLengt
h, 0); |
| 51 }, "Assigning non-numeric to maxlength sets maxlength to 0"); |
| 52 </script> |
| 53 </body> |
| 54 </html> |
| 55 |
OLD | NEW |