tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / forms / script-tests / textarea-rows-cols.js
1 description('Test for edge cases of <textarea> rows and cols attributes.');
2
3 var parent = document.createElement('div');
4 document.body.appendChild(parent);
5 parent.innerHTML = '<textarea>default</textarea>';
6
7 debug('Default values');
8 var textarea = parent.firstChild;
9 var defaultRows = textarea.rows;
10 var defaultCols = textarea.cols;
11 var defaultHeight = textarea.offsetHeight;
12 var defaultWidth = textarea.offsetWidth;
13 shouldBe('defaultRows', '2');
14 shouldBe('defaultCols', '20');
15 shouldBeTrue('defaultHeight > 0');
16 shouldBeTrue('defaultWidth > 0');
17
18 debug('rows = 1');
19 parent.innerHTML = '<textarea rows="1">rows = 1</textarea>';
20 textarea = parent.firstChild;
21 shouldBe('textarea.rows', '1');
22 shouldBeTrue('textarea.offsetHeight > 0');
23 shouldBeTrue('textarea.offsetHeight < defaultHeight');
24 shouldBe('textarea.offsetWidth', 'defaultWidth');
25
26 debug('rows = 2; should match default height');
27 parent.innerHTML = '<textarea rows="2">rows = 2; should match default height</textarea>';
28 textarea = parent.firstChild;
29 shouldBe('textarea.rows', 'defaultRows');
30 shouldBe('textarea.offsetHeight', 'defaultHeight');
31 shouldBe('textarea.offsetWidth', 'defaultWidth');
32
33 debug('rows = 3');
34 parent.innerHTML = '<textarea rows="3">rows = 3</textarea>';
35 textarea = parent.firstChild;
36 shouldBe('textarea.rows', '3');
37 shouldBeTrue('textarea.offsetHeight > defaultHeight');
38 shouldBe('textarea.offsetWidth', 'defaultWidth');
39
40 debug('rows; should be default height');
41 parent.innerHTML = '<textarea rows>rows; should be default height</textarea>';
42 textarea = parent.firstChild;
43 shouldBe('textarea.rows', 'defaultRows');
44 shouldBe('textarea.offsetHeight', 'defaultHeight');
45 shouldBe('textarea.offsetWidth', 'defaultWidth');
46
47 debug('rows = 0; should be default height');
48 parent.innerHTML = '<textarea rows="0">rows = 0; should be default height</textarea>';
49 textarea = parent.firstChild;
50 shouldBe('textarea.rows', 'defaultRows');
51 shouldBe('textarea.offsetHeight', 'defaultHeight');
52 shouldBe('textarea.offsetWidth', 'defaultWidth');
53
54 debug('rows = -1; should be default height');
55 parent.innerHTML = '<textarea rows="-1">rows = -1; should be default height</textarea>';
56 textarea = parent.firstChild;
57 shouldBe('textarea.rows', 'defaultRows');
58 shouldBe('textarea.offsetHeight', 'defaultHeight');
59 shouldBe('textarea.offsetWidth', 'defaultWidth');
60
61 debug('rows = x; should be default height');
62 parent.innerHTML = '<textarea rows="x">rows = x; should be default height</textarea>';
63 textarea = parent.firstChild;
64 shouldBe('textarea.rows', 'defaultRows');
65 shouldBe('textarea.offsetHeight', 'defaultHeight');
66 shouldBe('textarea.offsetWidth', 'defaultWidth');
67
68 debug('cols = 1');
69 parent.innerHTML = '<textarea cols="1">cols = 1</textarea>';
70 textarea = parent.firstChild;
71 shouldBe('textarea.cols', '1');
72 shouldBeTrue('textarea.offsetWidth > 0');
73 shouldBeTrue('textarea.offsetWidth < defaultWidth');
74 shouldBe('textarea.offsetHeight', 'defaultHeight');
75
76 debug('cols = 20; should match default width');
77 parent.innerHTML = '<textarea cols="20">cols = 20; should match default width</textarea>';
78 textarea = parent.firstChild;
79 shouldBe('textarea.cols', 'defaultCols');
80 shouldBe('textarea.offsetWidth', 'defaultWidth');
81 shouldBe('textarea.offsetHeight', 'defaultHeight');
82
83 debug('cols = 40');
84 parent.innerHTML = '<textarea cols="40">cols = 40</textarea>';
85 textarea = parent.firstChild;
86 shouldBe('textarea.cols', '40');
87 shouldBeTrue('textarea.offsetWidth > defaultWidth');
88 shouldBe('textarea.offsetHeight', 'defaultHeight');
89
90 debug('cols; should be default width');
91 parent.innerHTML = '<textarea cols>cols; should be default width</textarea>';
92 textarea = parent.firstChild;
93 shouldBe('textarea.cols', 'defaultCols');
94 shouldBe('textarea.offsetWidth', 'defaultWidth');
95 shouldBe('textarea.offsetHeight', 'defaultHeight');
96
97 debug('cols = 0; should be default width');
98 parent.innerHTML = '<textarea cols="0">cols = 0; should be default width</textarea>';
99 textarea = parent.firstChild;
100 shouldBe('textarea.cols', 'defaultCols');
101 shouldBe('textarea.offsetWidth', 'defaultWidth');
102 shouldBe('textarea.offsetHeight', 'defaultHeight');
103
104 debug('cols = -1; should be default width');
105 parent.innerHTML = '<textarea cols="-1">cols = -1; should be default width</textarea>';
106 textarea = parent.firstChild;
107 shouldBe('textarea.cols', 'defaultCols');
108 shouldBe('textarea.offsetWidth', 'defaultWidth');
109 shouldBe('textarea.offsetHeight', 'defaultHeight');
110
111 debug('cols = x; should be default width');
112 parent.innerHTML = '<textarea cols="x">cols = x; should be default width</textarea>';
113 textarea = parent.firstChild;
114 shouldBe('textarea.cols', 'defaultCols');
115 shouldBe('textarea.offsetWidth', 'defaultWidth');
116 shouldBe('textarea.offsetHeight', 'defaultHeight');