| Index: LayoutTests/fast/forms/ValidityState-tooShort-textarea.html
|
| diff --git a/LayoutTests/fast/forms/ValidityState-tooShort-textarea.html b/LayoutTests/fast/forms/ValidityState-tooShort-textarea.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..78da2227e40bf43358c32e65011a2e740a5a26ae
|
| --- /dev/null
|
| +++ b/LayoutTests/fast/forms/ValidityState-tooShort-textarea.html
|
| @@ -0,0 +1,94 @@
|
| +<!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 tooShort flag with <textarea> elements.');
|
| +
|
| +var textarea = document.createElement('textarea');
|
| +document.body.appendChild(textarea);
|
| +
|
| +debug('No minlength and no value');
|
| +shouldBeFalse('textarea.validity.tooShort');
|
| +
|
| +debug('');
|
| +debug('Non-dirty value');
|
| +textarea.defaultValue = 'ab';
|
| +textarea.minLength = 3;
|
| +shouldBe('textarea.value.length', '2');
|
| +shouldBeFalse('textarea.validity.tooShort');
|
| +
|
| +textarea.defaultValue = 'a';
|
| +shouldBe('textarea.value.length', '1');
|
| +shouldBeFalse('textarea.validity.tooShort');
|
| +
|
| +debug('');
|
| +debug('Dirty value and longer than minLength');
|
| +textarea = document.createElement('textarea');
|
| +document.body.appendChild(textarea);
|
| +textarea.defaultValue = 'ab';
|
| +textarea.minLength = 3;
|
| +textarea.focus();
|
| +textarea.setSelectionRange(2, 2); // Move the cursor at the end.
|
| +document.execCommand('delete');
|
| +shouldBe('textarea.value.length', '1');
|
| +shouldBeTrue('textarea.validity.tooShort');
|
| +// Make the value empty, which means valid.
|
| +document.execCommand('delete');
|
| +shouldBe('textarea.value.length', '0');
|
| +shouldBeFalse('textarea.validity.tooShort');
|
| +document.execCommand('InsertText', false, 'ab');
|
| +shouldBe('textarea.value.length', '2');
|
| +shouldBeTrue('textarea.validity.tooShort');
|
| +// Make the value >=minLength.
|
| +document.execCommand('InsertText', false, 'c');
|
| +shouldBe('textarea.value.length', '3');
|
| +shouldBeFalse('textarea.validity.tooShort');
|
| +
|
| +debug('');
|
| +debug('Sets a value via DOM property');
|
| +textarea = document.createElement('textarea');
|
| +document.body.appendChild(textarea);
|
| +textarea.minLength = 3;
|
| +textarea.defaultValue = 'ab';
|
| +shouldBeFalse('textarea.validity.tooShort');
|
| +
|
| +debug('');
|
| +debug('Disabling makes the control valid');
|
| +textarea.focus();
|
| +textarea.setSelectionRange(2, 2); // Move the cursor at the end.
|
| +document.execCommand('delete');
|
| +shouldBeTrue('textarea.validity.tooShort');
|
| +shouldBeFalse('textarea.disabled = true; textarea.validity.tooShort');
|
| +shouldBeTrue('textarea.disabled = false; textarea.validity.tooShort');
|
| +
|
| +debug('');
|
| +debug('A value set by resetting a form doesn\'t make tooShort true.');
|
| +// Make a dirty textarea.
|
| +var parent = document.createElement('div');
|
| +document.body.appendChild(parent);
|
| +parent.innerHTML = '<form><textarea minlength=3>ab</textarea></form>';
|
| +textarea = parent.firstChild.firstChild;
|
| +textarea.focus();
|
| +textarea.setSelectionRange(2, 2);
|
| +document.execCommand('delete');
|
| +shouldBeTrue('textarea.validity.tooShort');
|
| +parent.firstChild.reset();
|
| +shouldBe('textarea.value', '"ab"');
|
| +shouldBeFalse('textarea.validity.tooShort');
|
| +
|
| +debug('');
|
| +debug('A value set by a child node change doesn\'t make tooShort true.');
|
| +parent.innerHTML = '<textarea minlength=3>ab</textarea>';
|
| +textarea = parent.firstChild;
|
| +shouldBeFalse('textarea.validity.tooShort');
|
| +parent.firstChild.innerHTML = 'a';
|
| +shouldBe('textarea.value', '"a"');
|
| +shouldBeFalse('textarea.validity.tooShort');
|
| +</script>
|
| +</body>
|
| +</html>
|
|
|