summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/textarea/textarea-minlength.html
blob: 7d9fe293d803a1b6e19dd0d2ddb22c7dd63e209e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!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>