OLD | NEW |
| (Empty) |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
2 <html> | |
3 <head> | |
4 <script src="../../resources/js-test.js"></script> | |
5 </head> | |
6 <body> | |
7 <p id="description"></p> | |
8 <div id="console"></div> | |
9 <script> | |
10 description('Test for edge cases of <textarea> rows and cols attributes.')
; | |
11 | |
12 var parent = document.createElement('div'); | |
13 document.body.appendChild(parent); | |
14 parent.innerHTML = '<textarea>default</textarea>'; | |
15 | |
16 debug('Default values'); | |
17 var textarea = parent.firstChild; | |
18 var defaultRows = textarea.rows; | |
19 var defaultCols = textarea.cols; | |
20 var defaultHeight = textarea.offsetHeight; | |
21 var defaultWidth = textarea.offsetWidth; | |
22 shouldBe('defaultRows', '2'); | |
23 shouldBe('defaultCols', '20'); | |
24 shouldBeTrue('defaultHeight > 0'); | |
25 shouldBeTrue('defaultWidth > 0'); | |
26 | |
27 debug('rows = 1'); | |
28 parent.innerHTML = '<textarea rows="1">rows = 1</textarea>'; | |
29 textarea = parent.firstChild; | |
30 shouldBe('textarea.rows', '1'); | |
31 shouldBeTrue('textarea.offsetHeight > 0'); | |
32 shouldBeTrue('textarea.offsetHeight < defaultHeight'); | |
33 shouldBe('textarea.offsetWidth', 'defaultWidth'); | |
34 | |
35 debug('rows = 2; should match default height'); | |
36 parent.innerHTML = '<textarea rows="2">rows = 2; should match default height</te
xtarea>'; | |
37 textarea = parent.firstChild; | |
38 shouldBe('textarea.rows', 'defaultRows'); | |
39 shouldBe('textarea.offsetHeight', 'defaultHeight'); | |
40 shouldBe('textarea.offsetWidth', 'defaultWidth'); | |
41 | |
42 debug('rows = 3'); | |
43 parent.innerHTML = '<textarea rows="3">rows = 3</textarea>'; | |
44 textarea = parent.firstChild; | |
45 shouldBe('textarea.rows', '3'); | |
46 shouldBeTrue('textarea.offsetHeight > defaultHeight'); | |
47 shouldBe('textarea.offsetWidth', 'defaultWidth'); | |
48 | |
49 debug('rows; should be default height'); | |
50 parent.innerHTML = '<textarea rows>rows; should be default height</textarea>'; | |
51 textarea = parent.firstChild; | |
52 shouldBe('textarea.rows', 'defaultRows'); | |
53 shouldBe('textarea.offsetHeight', 'defaultHeight'); | |
54 shouldBe('textarea.offsetWidth', 'defaultWidth'); | |
55 | |
56 debug('rows = 0; should be default height'); | |
57 parent.innerHTML = '<textarea rows="0">rows = 0; should be default height</texta
rea>'; | |
58 textarea = parent.firstChild; | |
59 shouldBe('textarea.rows', 'defaultRows'); | |
60 shouldBe('textarea.offsetHeight', 'defaultHeight'); | |
61 shouldBe('textarea.offsetWidth', 'defaultWidth'); | |
62 | |
63 debug('rows = -1; should be default height'); | |
64 parent.innerHTML = '<textarea rows="-1">rows = -1; should be default height</tex
tarea>'; | |
65 textarea = parent.firstChild; | |
66 shouldBe('textarea.rows', 'defaultRows'); | |
67 shouldBe('textarea.offsetHeight', 'defaultHeight'); | |
68 shouldBe('textarea.offsetWidth', 'defaultWidth'); | |
69 | |
70 debug('rows = x; should be default height'); | |
71 parent.innerHTML = '<textarea rows="x">rows = x; should be default height</texta
rea>'; | |
72 textarea = parent.firstChild; | |
73 shouldBe('textarea.rows', 'defaultRows'); | |
74 shouldBe('textarea.offsetHeight', 'defaultHeight'); | |
75 shouldBe('textarea.offsetWidth', 'defaultWidth'); | |
76 | |
77 debug('cols = 1'); | |
78 parent.innerHTML = '<textarea cols="1">cols = 1</textarea>'; | |
79 textarea = parent.firstChild; | |
80 shouldBe('textarea.cols', '1'); | |
81 shouldBeTrue('textarea.offsetWidth > 0'); | |
82 shouldBeTrue('textarea.offsetWidth < defaultWidth'); | |
83 shouldBe('textarea.offsetHeight', 'defaultHeight'); | |
84 | |
85 debug('cols = 20; should match default width'); | |
86 parent.innerHTML = '<textarea cols="20">cols = 20; should match default width</t
extarea>'; | |
87 textarea = parent.firstChild; | |
88 shouldBe('textarea.cols', 'defaultCols'); | |
89 shouldBe('textarea.offsetWidth', 'defaultWidth'); | |
90 shouldBe('textarea.offsetHeight', 'defaultHeight'); | |
91 | |
92 debug('cols = 40'); | |
93 parent.innerHTML = '<textarea cols="40">cols = 40</textarea>'; | |
94 textarea = parent.firstChild; | |
95 shouldBe('textarea.cols', '40'); | |
96 shouldBeTrue('textarea.offsetWidth > defaultWidth'); | |
97 shouldBe('textarea.offsetHeight', 'defaultHeight'); | |
98 | |
99 debug('cols; should be default width'); | |
100 parent.innerHTML = '<textarea cols>cols; should be default width</textarea>'; | |
101 textarea = parent.firstChild; | |
102 shouldBe('textarea.cols', 'defaultCols'); | |
103 shouldBe('textarea.offsetWidth', 'defaultWidth'); | |
104 shouldBe('textarea.offsetHeight', 'defaultHeight'); | |
105 | |
106 debug('cols = 0; should be default width'); | |
107 parent.innerHTML = '<textarea cols="0">cols = 0; should be default width</textar
ea>'; | |
108 textarea = parent.firstChild; | |
109 shouldBe('textarea.cols', 'defaultCols'); | |
110 shouldBe('textarea.offsetWidth', 'defaultWidth'); | |
111 shouldBe('textarea.offsetHeight', 'defaultHeight'); | |
112 | |
113 debug('cols = -1; should be default width'); | |
114 parent.innerHTML = '<textarea cols="-1">cols = -1; should be default width</text
area>'; | |
115 textarea = parent.firstChild; | |
116 shouldBe('textarea.cols', 'defaultCols'); | |
117 shouldBe('textarea.offsetWidth', 'defaultWidth'); | |
118 shouldBe('textarea.offsetHeight', 'defaultHeight'); | |
119 | |
120 debug('cols = x; should be default width'); | |
121 parent.innerHTML = '<textarea cols="x">cols = x; should be default width</textar
ea>'; | |
122 textarea = parent.firstChild; | |
123 shouldBe('textarea.cols', 'defaultCols'); | |
124 shouldBe('textarea.offsetWidth', 'defaultWidth'); | |
125 shouldBe('textarea.offsetHeight', 'defaultHeight'); | |
126 </script> | |
127 </body> | |
128 </html> | |
OLD | NEW |