blob: 7d9fe293d803a1b6e19dd0d2ddb22c7dd63e209e [file] [log] [blame]
<!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');
// Leading whitespaces in minlength attributes
textArea.setAttribute('minlength', '\t \n\r1');
shouldBe('textArea.minLength', '1');
textArea.setAttribute('minlength', "\u20021");
shouldBe('textArea.minLength', '-1');
textArea.setAttribute('minlength', "\u20091");
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>