OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <body> | 3 <body> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
5 <script> | 5 <script> |
6 var element; | 6 var element; |
7 | 7 |
8 function testDOMStringReflection(elementName, contentAttributeName, idlAttribute
Name) { | 8 function testDOMStringReflection(elementName, contentAttributeName, idlAttribute
Name, treatNullAsEmptyString) { |
9 idlAttributeName = idlAttributeName || contentAttributeName; | 9 idlAttributeName = idlAttributeName || contentAttributeName; |
10 element = document.createElement(elementName); | 10 element = document.createElement(elementName); |
11 debug('Reflected DOMString attribute test for ' + elementName + '/@' + conte
ntAttributeName); | 11 debug('Reflected DOMString attribute test for ' + elementName + '/@' + conte
ntAttributeName); |
12 debug('Initial value:'); | 12 debug('Initial value:'); |
13 shouldBeEqualToString('element.' + idlAttributeName, ''); | 13 shouldBeEqualToString('element.' + idlAttributeName, ''); |
14 shouldBeNull('element.getAttribute("' + contentAttributeName + '")'); | 14 shouldBeNull('element.getAttribute("' + contentAttributeName + '")'); |
15 | 15 |
16 debug('Setting a value via the IDL attribute:'); | 16 debug('Setting a value via the IDL attribute:'); |
17 shouldBeEqualToString('element.' + idlAttributeName + ' = "foo"; element.' +
idlAttributeName, 'foo'); | 17 shouldBeEqualToString('element.' + idlAttributeName + ' = "foo"; element.' +
idlAttributeName, 'foo'); |
18 shouldBeEqualToString('element.getAttribute("' + contentAttributeName + '")'
, 'foo'); | 18 shouldBeEqualToString('element.getAttribute("' + contentAttributeName + '")'
, 'foo'); |
19 | 19 |
20 debug('Setting a value via the content attribute:'); | 20 debug('Setting a value via the content attribute:'); |
21 shouldBeEqualToString('element.setAttribute("' + contentAttributeName + '",
" bar\\n"); element.' + idlAttributeName, ' bar\n'); | 21 shouldBeEqualToString('element.setAttribute("' + contentAttributeName + '",
" bar\\n"); element.' + idlAttributeName, ' bar\n'); |
22 shouldBeEqualToString('element.getAttribute("' + contentAttributeName + '")'
, ' bar\n'); | 22 shouldBeEqualToString('element.getAttribute("' + contentAttributeName + '")'
, ' bar\n'); |
23 | 23 |
24 debug('Setting null via the IDL attribute:'); | 24 debug('Setting null via the IDL attribute:'); |
25 shouldBeEqualToString('element.' + idlAttributeName + ' = null; element.' +
idlAttributeName, 'null'); | 25 if (treatNullAsEmptyString) { |
26 shouldBeEqualToString('element.getAttribute("' + contentAttributeName + '")'
, 'null'); | 26 shouldBeEqualToString('element.' + idlAttributeName + ' = null; element.
' + idlAttributeName, ''); |
| 27 shouldBeEqualToString('element.getAttribute("' + contentAttributeName +
'")', ''); |
| 28 } else { |
| 29 shouldBeEqualToString('element.' + idlAttributeName + ' = null; element.
' + idlAttributeName, 'null'); |
| 30 shouldBeEqualToString('element.getAttribute("' + contentAttributeName +
'")', 'null'); |
| 31 } |
27 | 32 |
28 debug('Setting null via the content attribute:'); | 33 debug('Setting null via the content attribute:'); |
29 shouldBeEqualToString('element.setAttribute("' + contentAttributeName + '",
null); element.' + idlAttributeName, 'null'); | 34 shouldBeEqualToString('element.setAttribute("' + contentAttributeName + '",
null); element.' + idlAttributeName, 'null'); |
30 shouldBeEqualToString('element.getAttribute("' + contentAttributeName + '")'
, 'null'); | 35 shouldBeEqualToString('element.getAttribute("' + contentAttributeName + '")'
, 'null'); |
31 | 36 |
32 debug('Setting undefined via the IDL attribute:'); | 37 debug('Setting undefined via the IDL attribute:'); |
33 shouldBeEqualToString('element.' + idlAttributeName + ' = undefined; element
.' + idlAttributeName, 'undefined'); | 38 shouldBeEqualToString('element.' + idlAttributeName + ' = undefined; element
.' + idlAttributeName, 'undefined'); |
34 shouldBeEqualToString('element.getAttribute("' + contentAttributeName + '")'
, 'undefined'); | 39 shouldBeEqualToString('element.getAttribute("' + contentAttributeName + '")'
, 'undefined'); |
35 | 40 |
36 debug('Setting undefined via the content attribute:'); | 41 debug('Setting undefined via the content attribute:'); |
(...skipping 15 matching lines...) Expand all Loading... |
52 testDOMStringReflection('fieldset', 'name'); | 57 testDOMStringReflection('fieldset', 'name'); |
53 testDOMStringReflection('form', 'name'); | 58 testDOMStringReflection('form', 'name'); |
54 testDOMStringReflection('input', 'name'); | 59 testDOMStringReflection('input', 'name'); |
55 testDOMStringReflection('input', 'step'); | 60 testDOMStringReflection('input', 'step'); |
56 testDOMStringReflection('keygen', 'name'); | 61 testDOMStringReflection('keygen', 'name'); |
57 testDOMStringReflection('object', 'name'); | 62 testDOMStringReflection('object', 'name'); |
58 testDOMStringReflection('output', 'name'); | 63 testDOMStringReflection('output', 'name'); |
59 testDOMStringReflection('select', 'name'); | 64 testDOMStringReflection('select', 'name'); |
60 testDOMStringReflection('textarea', 'name'); | 65 testDOMStringReflection('textarea', 'name'); |
61 | 66 |
| 67 // [TreatNullAs=EmptyString] |
| 68 testDOMStringReflection('frame', 'marginheight', 'marginHeight', true); |
| 69 testDOMStringReflection('frame', 'marginwidth', 'marginWidth', true); |
| 70 testDOMStringReflection('iframe', 'marginheight', 'marginHeight', true); |
| 71 testDOMStringReflection('iframe', 'marginwidth', 'marginWidth', true); |
| 72 testDOMStringReflection('body', 'text', 'text', true); |
| 73 testDOMStringReflection('body', 'link', 'link', true); |
| 74 testDOMStringReflection('body', 'alink', 'aLink', true); |
| 75 testDOMStringReflection('body', 'vlink', 'vLink', true); |
| 76 testDOMStringReflection('body', 'bgcolor', 'bgColor', true); |
| 77 testDOMStringReflection('font', 'color', 'color', true); |
| 78 testDOMStringReflection('img', 'border', 'border', true); |
| 79 testDOMStringReflection('object', 'border', 'border', true); |
| 80 testDOMStringReflection('table', 'bgcolor', 'bgColor', true); |
| 81 testDOMStringReflection('table', 'cellpadding', 'cellPadding', true); |
| 82 testDOMStringReflection('table', 'cellspacing', 'cellSpacing', true); |
| 83 testDOMStringReflection('td', 'bgcolor', 'bgColor', true); |
| 84 testDOMStringReflection('th', 'bgcolor', 'bgColor', true); |
| 85 testDOMStringReflection('tr', 'bgcolor', 'bgColor', true); |
| 86 |
| 87 |
62 // Add more DOMString attributes! | 88 // Add more DOMString attributes! |
63 | 89 |
64 </script> | 90 </script> |
65 </body> | 91 </body> |
66 </html> | 92 </html> |
OLD | NEW |