5 function addTextarea(properties, opt_innerHTML) {
6 var title = docToAppendTo.createTextNode();
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;
19 textarea[property] = value;
21 textarea.innerHTML = opt_innerHTML ||
22 'Lorem ipsum dolor ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuv';
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);
33 function addAllTextareas(iframe, compatMode) {
34 iframe.style.cssText = 'width:100%;border:0;'
35 docToAppendTo = iframe.contentWindow.document;
37 docToAppendTo.body.style.cssText = 'margin:0';
39 if (docToAppendTo.compatMode != compatMode)
40 testFailed('This document should be in ' + compatMode + ' mode.');
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);
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'});
74 iframe.style.height = docToAppendTo.body.offsetHeight + 5 + 'px';
77 // Set the domain in the top-level page as well as the iframe.
78 // So they can communicate despite use of the data url.
79 document.domain = 'mydummydomain';
80 document.body.style.margin = 0;
82 var standardsIframe = document.createElement('iframe');
83 // Create a page with a doctype so it's standards mode.
84 standardsIframe.src = 'data:text/html;charset=utf-8,%3C!DOCTYPE%20HTML%3E%3Cbody%3E%3Cscript%3Edocument.domain%20%3D%20"mydummydomain"%3B%3C%2Fbody%3E%3C%2Fhtml%3E%0D%0A';
85 standardsIframe.onload = function(e) {
86 addAllTextareas(e.target, 'CSS1Compat');
88 document.body.appendChild(standardsIframe);
90 var quirksIframe = document.createElement('iframe');
91 quirksIframe.onload = function(e) {
92 addAllTextareas(e.target, 'BackCompat');
94 document.body.appendChild(quirksIframe);