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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/forms/ValidityState-tooLong-textarea.html
diff --git a/LayoutTests/fast/forms/ValidityState-tooLong-textarea.html b/LayoutTests/fast/forms/ValidityState-tooLong-textarea.html
index c8cbb9c53a2ee03299fd70f46f4532726df2a1c7..9fc7c2dd44a029419a95cf58812a077751ff8546 100644
--- a/LayoutTests/fast/forms/ValidityState-tooLong-textarea.html
+++ b/LayoutTests/fast/forms/ValidityState-tooLong-textarea.html
@@ -50,11 +50,20 @@ textarea.value = 'abcde';
shouldBeFalse('textarea.validity.tooLong');
debug('');
-debug('Disabled');
-textarea.disabled = true;
-shouldBeFalse('textarea.validity.tooLong');
-textarea.disabled = false;
+debug('Disabling makes the control valid');
+textarea.focus();
+textarea.setSelectionRange(5, 5); // Move the cursor at the end.
+document.execCommand('delete');
+shouldBeTrue('textarea.validity.tooLong');
+shouldBeFalse('textarea.disabled = true; textarea.validity.tooLong');
+shouldBeTrue('textarea.disabled = false; textarea.validity.tooLong');
+// FIXME: The grapheme test below doesn't do its job because initial value is
+// always valid. After making a modificaton to trigger validity check, one can
+// see that the test would fail, which possibly reveals a code issue.
+// https://code.google.com/p/chromium/issues/detail?id=421727
+// Once this is figured out, implement a similar test in
+// ValidityState-tooShort-textarea.html
debug('');
debug('Grapheme length is not greater than maxLength though character length is greater');
// fancyX should be treated as 1 grapheme.
@@ -90,6 +99,45 @@ shouldBeFalse('textarea.validity.tooLong');
parent.firstChild.innerHTML = 'abcdef';
shouldBe('textarea.value', '"abcdef"');
shouldBeFalse('textarea.validity.tooLong');
+
+debug('');
+debug('minlength and maxlength together');
+textarea.maxLength = 3;
+textarea.minLength = 3;
+textarea.value = 'abcde';
+textarea.focus();
+textarea.setSelectionRange(5, 5);
+document.execCommand('delete');
+shouldBeTrue('textarea.validity.tooLong');
+shouldBeFalse('textarea.validity.tooShort');
+document.execCommand('delete');
+shouldBeFalse('textarea.validity.tooLong');
+shouldBeFalse('textarea.validity.tooShort');
+document.execCommand('delete');
+shouldBeFalse('textarea.validity.tooLong');
+shouldBeTrue('textarea.validity.tooShort');
+
+debug('');
+debug('minlength and maxlength clashing');
+textarea.setAttribute('maxlength', '2');
+textarea.setAttribute('minlength', '4');
+textarea.value = 'abcde';
+textarea.focus();
+textarea.setSelectionRange(5, 5);
+document.execCommand('delete');
+shouldBeTrue('textarea.validity.tooLong');
+shouldBeFalse('textarea.validity.tooShort');
+document.execCommand('delete');
+shouldBeTrue('textarea.validity.tooLong');
+shouldBeTrue('textarea.validity.tooShort');
+document.execCommand('delete');
+shouldBeFalse('textarea.validity.tooLong');
+shouldBeTrue('textarea.validity.tooShort');
+document.execCommand('delete');
+document.execCommand('delete');
+shouldBeFalse('textarea.validity.tooLong');
+shouldBeFalse('textarea.validity.tooShort');
+
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698