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

Side by Side Diff: LayoutTests/fast/forms/ValidityState-tooLong-textarea.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
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <p id="description"></p> 7 <p id="description"></p>
8 <div id="console"></div> 8 <div id="console"></div>
9 <script> 9 <script>
10 description('Tests for tooLong flag with &lt;textarea> elements.'); 10 description('Tests for tooLong flag with &lt;textarea> elements.');
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 debug(''); 44 debug('');
45 debug('Sets a value via DOM property'); 45 debug('Sets a value via DOM property');
46 textarea = document.createElement('textarea'); 46 textarea = document.createElement('textarea');
47 document.body.appendChild(textarea); 47 document.body.appendChild(textarea);
48 textarea.maxLength = 3; 48 textarea.maxLength = 3;
49 textarea.value = 'abcde'; 49 textarea.value = 'abcde';
50 shouldBeFalse('textarea.validity.tooLong'); 50 shouldBeFalse('textarea.validity.tooLong');
51 51
52 debug(''); 52 debug('');
53 debug('Disabled'); 53 debug('Disabling makes the control valid');
54 textarea.disabled = true; 54 textarea.focus();
55 shouldBeFalse('textarea.validity.tooLong'); 55 textarea.setSelectionRange(5, 5); // Move the cursor at the end.
56 textarea.disabled = false; 56 document.execCommand('delete');
57 shouldBeTrue('textarea.validity.tooLong');
58 shouldBeFalse('textarea.disabled = true; textarea.validity.tooLong');
59 shouldBeTrue('textarea.disabled = false; textarea.validity.tooLong');
57 60
61 // FIXME: The grapheme test below doesn't do its job because initial value is
62 // always valid. After making a modificaton to trigger validity check, one can
63 // see that the test would fail, which possibly reveals a code issue.
64 // https://code.google.com/p/chromium/issues/detail?id=421727
65 // Once this is figured out, implement a similar test in
66 // ValidityState-tooShort-textarea.html
58 debug(''); 67 debug('');
59 debug('Grapheme length is not greater than maxLength though character length is greater'); 68 debug('Grapheme length is not greater than maxLength though character length is greater');
60 // fancyX should be treated as 1 grapheme. 69 // fancyX should be treated as 1 grapheme.
61 // U+0305 COMBINING OVERLINE 70 // U+0305 COMBINING OVERLINE
62 // U+0332 COMBINING LOW LINE 71 // U+0332 COMBINING LOW LINE
63 var fancyX = "x\u0305\u0332"; 72 var fancyX = "x\u0305\u0332";
64 textarea = document.createElement('textarea'); 73 textarea = document.createElement('textarea');
65 document.body.appendChild(textarea); 74 document.body.appendChild(textarea);
66 textarea.value = fancyX; // 3 characters, 1 grapheme cluster. 75 textarea.value = fancyX; // 3 characters, 1 grapheme cluster.
67 textarea.maxLength = 1; 76 textarea.maxLength = 1;
(...skipping 15 matching lines...) Expand all
83 shouldBeFalse('textarea.validity.tooLong'); 92 shouldBeFalse('textarea.validity.tooLong');
84 93
85 debug(''); 94 debug('');
86 debug('A value set by a child node change doesn\'t make tooLong true.'); 95 debug('A value set by a child node change doesn\'t make tooLong true.');
87 parent.innerHTML = '<textarea maxlength=2>abc</textarea>'; 96 parent.innerHTML = '<textarea maxlength=2>abc</textarea>';
88 textarea = parent.firstChild; 97 textarea = parent.firstChild;
89 shouldBeFalse('textarea.validity.tooLong'); 98 shouldBeFalse('textarea.validity.tooLong');
90 parent.firstChild.innerHTML = 'abcdef'; 99 parent.firstChild.innerHTML = 'abcdef';
91 shouldBe('textarea.value', '"abcdef"'); 100 shouldBe('textarea.value', '"abcdef"');
92 shouldBeFalse('textarea.validity.tooLong'); 101 shouldBeFalse('textarea.validity.tooLong');
102
103 debug('');
104 debug('minlength and maxlength together');
105 textarea.maxLength = 3;
106 textarea.minLength = 3;
107 textarea.value = 'abcde';
108 textarea.focus();
109 textarea.setSelectionRange(5, 5);
110 document.execCommand('delete');
111 shouldBeTrue('textarea.validity.tooLong');
112 shouldBeFalse('textarea.validity.tooShort');
113 document.execCommand('delete');
114 shouldBeFalse('textarea.validity.tooLong');
115 shouldBeFalse('textarea.validity.tooShort');
116 document.execCommand('delete');
117 shouldBeFalse('textarea.validity.tooLong');
118 shouldBeTrue('textarea.validity.tooShort');
119
120 debug('');
121 debug('minlength and maxlength clashing');
122 textarea.setAttribute('maxlength', '2');
123 textarea.setAttribute('minlength', '4');
124 textarea.value = 'abcde';
125 textarea.focus();
126 textarea.setSelectionRange(5, 5);
127 document.execCommand('delete');
128 shouldBeTrue('textarea.validity.tooLong');
129 shouldBeFalse('textarea.validity.tooShort');
130 document.execCommand('delete');
131 shouldBeTrue('textarea.validity.tooLong');
132 shouldBeTrue('textarea.validity.tooShort');
133 document.execCommand('delete');
134 shouldBeFalse('textarea.validity.tooLong');
135 shouldBeTrue('textarea.validity.tooShort');
136 document.execCommand('delete');
137 document.execCommand('delete');
138 shouldBeFalse('textarea.validity.tooLong');
139 shouldBeFalse('textarea.validity.tooShort');
140
93 </script> 141 </script>
94 </body> 142 </body>
95 </html> 143 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698