1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
7 <p id=
"description"></p>
8 <div id=
"console"></div>
10 description('Tests for tooShort flag with <input> elements.');
12 var input
= document
.createElement('input');
13 document
.body
.appendChild(input
);
15 debug('No minlength and no value');
16 shouldBeFalse('input.validity.tooShort');
19 debug('Non-dirty value');
20 input
.setAttribute('value', 'ab');
22 shouldBe('input.value.length', '2');
23 shouldBeFalse('input.validity.tooShort');
25 input
.setAttribute('value', 'a');
26 shouldBe('input.value.length', '1');
27 shouldBeFalse('input.validity.tooShort');
30 debug('Dirty value and longer than minLength');
31 input
= document
.createElement('input');
32 document
.body
.appendChild(input
);
33 input
.setAttribute('value', 'ab');
36 input
.setSelectionRange(2, 2); // Move the cursor at the end.
37 document
.execCommand('delete');
38 shouldBe('input.value.length', '1');
39 shouldBeTrue('input.validity.tooShort');
40 // Make the value empty, which means valid.
41 document
.execCommand('delete');
42 shouldBe('input.value.length', '0');
43 shouldBeFalse('input.validity.tooShort');
44 document
.execCommand('InsertText', false, 'ab');
45 shouldBe('input.value.length', '2');
46 shouldBeTrue('input.validity.tooShort');
47 // Make the value >=minLength.
48 document
.execCommand('InsertText', false, 'c');
49 shouldBe('input.value.length', '3');
50 shouldBeFalse('input.validity.tooShort');
53 debug('Sets a value via DOM property');
56 shouldBeFalse('input.validity.tooShort');
59 debug('Disabling makes the control valid');
61 input
.setSelectionRange(2, 2);
62 document
.execCommand('delete');
63 shouldBeTrue('input.validity.tooShort');
64 shouldBeFalse('input.disabled = true; input.validity.tooShort');
65 shouldBeTrue('input.disabled = false; input.validity.tooShort');
68 debug('Change the type with a too long value');
71 input
.type
= 'search';
73 input
.setSelectionRange(1, 1);
74 document
.execCommand('InsertText', false, 'b');
75 shouldBeTrue('input.validity.tooShort');
76 shouldBeFalse('input.type = "number"; input.validity.tooShort');