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