Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: LayoutTests/fast/forms/ValidityState-tooShort-input.html

Issue 435753003: Implement minlength for <input> and <textarea>. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add layout tests for minlength & maxlength together; fix comments Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10 description('Tests for tooShort flag with &lt;input> elements.');
11
12 var input = document.createElement('input');
13 document.body.appendChild(input);
14
15 debug('No minlength and no value');
16 shouldBeFalse('input.validity.tooShort');
17
18 debug('');
19 debug('Non-dirty value');
20 input.setAttribute('value', 'ab');
21 input.minLength = 3;
22 shouldBe('input.value.length', '2');
23 shouldBeFalse('input.validity.tooShort');
24
25 input.setAttribute('value', 'a');
26 shouldBe('input.value.length', '1');
27 shouldBeFalse('input.validity.tooShort');
28
29 debug('');
30 debug('Dirty value and longer than minLength');
31 input = document.createElement('input');
32 document.body.appendChild(input);
33 input.setAttribute('value', 'ab');
34 input.minLength = 3;
35 input.focus();
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');
51
52 debug('');
53 debug('Sets a value via DOM property');
54 input.minLength = 3;
55 input.value = 'ab';
56 shouldBeFalse('input.validity.tooShort');
57
58 debug('');
59 debug('Disabling makes the control valid');
60 input.focus();
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');
66
67 debug('');
68 debug('Change the type with a too long value');
69 input.minLength = 3;
70 input.value = 'a';
71 input.type = 'search';
72 input.focus();
73 input.setSelectionRange(1, 1);
74 document.execCommand('InsertText', false, 'b');
75 shouldBeTrue('input.validity.tooShort');
76 shouldBeFalse('input.type = "number"; input.validity.tooShort');
77 </script>
78 </body>
79 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698