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

Unified Diff: LayoutTests/fast/forms/textarea-minlength.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/textarea-minlength.html
diff --git a/LayoutTests/fast/forms/textarea-minlength.html b/LayoutTests/fast/forms/textarea-minlength.html
new file mode 100644
index 0000000000000000000000000000000000000000..45146638f9d52def8b751fa276bb6fc91afe9fd9
--- /dev/null
+++ b/LayoutTests/fast/forms/textarea-minlength.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description('Tests for HTMLTextAreaElement.minLength behaviors.');
+
+var textArea = document.createElement('textarea');
+document.body.appendChild(textArea);
+
+// No minlength attribute
+shouldBe('textArea.minLength', '-1');
+
+// Invalid minlength attributes
+textArea.setAttribute('minlength', '-3');
+shouldBe('textArea.minLength', '-1');
+textArea.setAttribute('minlength', 'xyz');
+shouldBe('textArea.minLength', '-1');
+
+// Valid minlength attributes
+textArea.setAttribute('minlength', '1');
+shouldBe('textArea.minLength', '1');
+textArea.setAttribute('minlength', '256');
+shouldBe('textArea.minLength', '256');
+
+// Set values to .minLength
+textArea.minLength = 6;
+shouldBe('textArea.getAttribute("minlength")', '"6"');
+
+shouldThrow('textArea.minLength = -1', '"IndexSizeError: Failed to set the \'minLength\' property on \'HTMLTextAreaElement\': The value provided (-1) is not positive or 0."');
+shouldBe('textArea.getAttribute("minlength")', '"6"'); // Not changed
+textArea.maxLength = 10;
+shouldThrow('textArea.minLength = 11', '"IndexSizeError: Failed to set the \'minLength\' property on \'HTMLTextAreaElement\': The minLength provided (11) is greater than the maximum bound (10)."');
+shouldBe('textArea.getAttribute("minlength")', '"6"'); // Not changed
+shouldBe('textArea.minLength = 10; textArea.getAttribute("minlength")', '"10"');
+
+textArea.minLength = null;
+shouldBe('textArea.minLength', '0');
+shouldBe('textArea.getAttribute("minlength")', '"0"');
+
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698