summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/textarea/textarea-rows-cols.html
blob: 4100683f90089fbb50fc4679fc2a75e17fc1a2a7 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!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('Test for edge cases of &lt;textarea&gt; rows and cols attributes.');

var parent = document.createElement('div');
document.body.appendChild(parent);
parent.innerHTML = '<textarea>default</textarea>';

debug('Default values');
var textarea = parent.firstChild;
var defaultRows = textarea.rows;
var defaultCols = textarea.cols;
var defaultHeight = textarea.offsetHeight;
var defaultWidth = textarea.offsetWidth;
shouldBe('defaultRows', '2');
shouldBe('defaultCols', '20');
shouldBeTrue('defaultHeight > 0');
shouldBeTrue('defaultWidth > 0');

debug('rows = 1');
parent.innerHTML = '<textarea rows="1">rows = 1</textarea>';
textarea = parent.firstChild;
shouldBe('textarea.rows', '1');
shouldBeTrue('textarea.offsetHeight > 0');
shouldBeTrue('textarea.offsetHeight < defaultHeight');
shouldBe('textarea.offsetWidth', 'defaultWidth');

debug('rows = 2; should match default height');
parent.innerHTML = '<textarea rows="2">rows = 2; should match default height</textarea>';
textarea = parent.firstChild;
shouldBe('textarea.rows', 'defaultRows');
shouldBe('textarea.offsetHeight', 'defaultHeight');
shouldBe('textarea.offsetWidth', 'defaultWidth');

debug('rows = 3');
parent.innerHTML = '<textarea rows="3">rows = 3</textarea>';
textarea = parent.firstChild;
shouldBe('textarea.rows', '3');
shouldBeTrue('textarea.offsetHeight > defaultHeight');
shouldBe('textarea.offsetWidth', 'defaultWidth');

debug('rows; should be default height');
parent.innerHTML = '<textarea rows>rows; should be default height</textarea>';
textarea = parent.firstChild;
shouldBe('textarea.rows', 'defaultRows');
shouldBe('textarea.offsetHeight', 'defaultHeight');
shouldBe('textarea.offsetWidth', 'defaultWidth');

debug('rows = 0; should be default height');
parent.innerHTML = '<textarea rows="0">rows = 0; should be default height</textarea>';
textarea = parent.firstChild;
shouldBe('textarea.rows', 'defaultRows');
shouldBe('textarea.offsetHeight', 'defaultHeight');
shouldBe('textarea.offsetWidth', 'defaultWidth');

debug('rows = -1; should be default height');
parent.innerHTML = '<textarea rows="-1">rows = -1; should be default height</textarea>';
textarea = parent.firstChild;
shouldBe('textarea.rows', 'defaultRows');
shouldBe('textarea.offsetHeight', 'defaultHeight');
shouldBe('textarea.offsetWidth', 'defaultWidth');

debug('rows = x; should be default height');
parent.innerHTML = '<textarea rows="x">rows = x; should be default height</textarea>';
textarea = parent.firstChild;
shouldBe('textarea.rows', 'defaultRows');
shouldBe('textarea.offsetHeight', 'defaultHeight');
shouldBe('textarea.offsetWidth', 'defaultWidth');

debug('cols = 1');
parent.innerHTML = '<textarea cols="1">cols = 1</textarea>';
textarea = parent.firstChild;
shouldBe('textarea.cols', '1');
shouldBeTrue('textarea.offsetWidth > 0');
shouldBeTrue('textarea.offsetWidth < defaultWidth');
shouldBe('textarea.offsetHeight', 'defaultHeight');

debug('cols = 20; should match default width');
parent.innerHTML = '<textarea cols="20">cols = 20; should match default width</textarea>';
textarea = parent.firstChild;
shouldBe('textarea.cols', 'defaultCols');
shouldBe('textarea.offsetWidth', 'defaultWidth');
shouldBe('textarea.offsetHeight', 'defaultHeight');

debug('cols = 40');
parent.innerHTML = '<textarea cols="40">cols = 40</textarea>';
textarea = parent.firstChild;
shouldBe('textarea.cols', '40');
shouldBeTrue('textarea.offsetWidth > defaultWidth');
shouldBe('textarea.offsetHeight', 'defaultHeight');

debug('cols; should be default width');
parent.innerHTML = '<textarea cols>cols; should be default width</textarea>';
textarea = parent.firstChild;
shouldBe('textarea.cols', 'defaultCols');
shouldBe('textarea.offsetWidth', 'defaultWidth');
shouldBe('textarea.offsetHeight', 'defaultHeight');

debug('cols = 0; should be default width');
parent.innerHTML = '<textarea cols="0">cols = 0; should be default width</textarea>';
textarea = parent.firstChild;
shouldBe('textarea.cols', 'defaultCols');
shouldBe('textarea.offsetWidth', 'defaultWidth');
shouldBe('textarea.offsetHeight', 'defaultHeight');

debug('cols = -1; should be default width');
parent.innerHTML = '<textarea cols="-1">cols = -1; should be default width</textarea>';
textarea = parent.firstChild;
shouldBe('textarea.cols', 'defaultCols');
shouldBe('textarea.offsetWidth', 'defaultWidth');
shouldBe('textarea.offsetHeight', 'defaultHeight');

debug('cols = x; should be default width');
parent.innerHTML = '<textarea cols="x">cols = x; should be default width</textarea>';
textarea = parent.firstChild;
shouldBe('textarea.cols', 'defaultCols');
shouldBe('textarea.offsetWidth', 'defaultWidth');
shouldBe('textarea.offsetHeight', 'defaultHeight');
</script>
</body>
</html>