blob: 6fba55d6d5b195acd0e19503b7ecb9af66dd88a3 [file] [log] [blame]
antti@apple.comb39b4672013-11-10 22:17:32 +00001<html>
2<body>
3<script>
4var docToAppendTo;
5function addTextarea(properties, opt_innerHTML) {
6 var title = docToAppendTo.createTextNode();
7 title.nodeValue = '';
8 var wrapper = docToAppendTo.createElement('div');
9 wrapper.style.cssText = 'display:inline-block;border:1px solid blue;font-size:12px;';
10 var textarea = docToAppendTo.createElement('textarea');
11 for (property in properties) {
12 var value = properties[property];
13 title.nodeValue += property + ': "' + value + '", ';
14 if (property == 'wrap')
15 textarea.setAttribute(property, value);
16 else if (property == 'style')
17 textarea.style.cssText = value;
18 else
19 textarea[property] = value;
20 }
21 textarea.innerHTML = opt_innerHTML ||
22 "Lorem ipsum dolor ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuv";
23
24 var span = document.createElement('span');
25 span.style.cssText = 'display:inline-block;width:80px;';
26 span.appendChild(title);
27 wrapper.appendChild(span);
28 wrapper.appendChild(document.createElement('br'));
29 wrapper.appendChild(textarea)
30 docToAppendTo.body.appendChild(wrapper);
31}
32
33function addAllTextareas(iframe, compatMode) {
34 iframe.style.cssText = 'width:100%;border:0;'
35 docToAppendTo = iframe.contentWindow.document;
36
37 docToAppendTo.body.style.cssText = 'margin:0';
38
39 if (docToAppendTo.compatMode != compatMode)
40 testFailed('This document should be in ' + compatMode + ' mode.');
41
42 var compatModeTitle = docToAppendTo.createElement('div');
43 compatModeTitle.innerHTML = 'CompatMode: ' + docToAppendTo.compatMode;
44 compatModeTitle.style.cssText = 'margin:5px 0;font-weight:bold;';
45 docToAppendTo.body.appendChild(compatModeTitle);
46
47 addTextarea({}, 'Lorem ipsum dolor');
48 addTextarea({disabled: 'true'});
49 addTextarea({style: 'padding:10px'});
50 addTextarea({style: 'padding:0px'});
51 addTextarea({style: 'margin:10px'});
52 addTextarea({style: 'margin:0px'});
53 addTextarea({style: 'width:60px'});
54 addTextarea({style: 'width:60px; padding:20px'});
55 addTextarea({style: 'width:60px; padding:0'});
56 addTextarea({style: 'height:60px'});
57 addTextarea({style: 'width:60px; height:60px'});
58 addTextarea({style: 'overflow:hidden'});
59 addTextarea({style: 'overflow:scroll'});
60 addTextarea({style: 'overflow:hidden; width:60px; height:60px'});
61 addTextarea({style: 'overflow:scroll; width:60px; height:60px'});
62 addTextarea({cols: 5, style: 'width:60px; height:60px'});
63 addTextarea({rows: 4, style: 'width:60px; height:60px'});
64 addTextarea({cols: 5, rows: 4, style: 'width:60px; height:60px'});
65 addTextarea({cols: 3});
66 addTextarea({rows: 3});
67 addTextarea({cols: 7});
68 addTextarea({rows: 7});
69 addTextarea({cols: 5, rows: 4});
70 addTextarea({wrap: 'off'});
71 addTextarea({wrap: 'hard'});
72 addTextarea({wrap: 'soft'});
73 addTextarea({style: 'white-space:normal'});
74 addTextarea({style: 'white-space:pre'});
75 addTextarea({style: 'white-space:prewrap'});
76 addTextarea({style: 'white-space:nowrap'});
77 addTextarea({style: 'white-space:pre-line'});
78 addTextarea({style: 'word-wrap:normal'});
79 addTextarea({wrap: 'off', style: 'white-space:pre-wrap'});
80
81 iframe.style.height = docToAppendTo.body.offsetHeight + 5 + 'px';
82}
83
84document.body.style.margin = 0;
85
86var standardsIframe = document.createElement('iframe');
87// Reference a page with a doctype so it's standards mode.
88standardsIframe.src = 'resources/basic-textareas-standards.html';
89standardsIframe.onload = function(e) {
90 addAllTextareas(e.target, 'CSS1Compat');
91}
92document.body.appendChild(standardsIframe);
93
94var quirksIframe = document.createElement('iframe');
95quirksIframe.onload = function(e) {
96 addAllTextareas(e.target, 'BackCompat');
97}
98document.body.appendChild(quirksIframe);
99</script>
100</body>
101</html>