Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Side by Side Diff: LayoutTests/fast/dom/domstring-attribute-reflection.html

Issue 59903003: Remove TreatNullAs=NullString for HTMLButtonElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@nullb
Patch Set: update tests Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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, treatNullAsString) {
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, ''); 25 if (treatNullAsString) {
26 shouldBeNull('element.getAttribute("' + contentAttributeName + '")'); 26 shouldBeEqualToString('element.' + idlAttributeName + ' = null; element. ' + idlAttributeName, 'null');
27 shouldBeEqualToString('element.getAttribute("' + contentAttributeName + '")', 'null');
28 } else {
29 shouldBeEqualToString('element.' + idlAttributeName + ' = null; element. ' + idlAttributeName, '');
30 shouldBeNull('element.getAttribute("' + contentAttributeName + '")');
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:');
37 shouldBeEqualToString('element.setAttribute("' + contentAttributeName + '", undefined); element.' + idlAttributeName, 'undefined'); 42 shouldBeEqualToString('element.setAttribute("' + contentAttributeName + '", undefined); element.' + idlAttributeName, 'undefined');
38 shouldBeEqualToString('element.getAttribute("' + contentAttributeName + '")' , 'undefined'); 43 shouldBeEqualToString('element.getAttribute("' + contentAttributeName + '")' , 'undefined');
39 44
40 debug('Setting non-string via the IDL attribute:'); 45 debug('Setting non-string via the IDL attribute:');
41 shouldBeEqualToString('element.' + idlAttributeName + ' = 123; element.' + i dlAttributeName, '123'); 46 shouldBeEqualToString('element.' + idlAttributeName + ' = 123; element.' + i dlAttributeName, '123');
42 shouldBeEqualToString('element.getAttribute("' + contentAttributeName + '")' , '123'); 47 shouldBeEqualToString('element.getAttribute("' + contentAttributeName + '")' , '123');
43 48
44 debug('Setting non-string via the content attribute:'); 49 debug('Setting non-string via the content attribute:');
45 shouldBeEqualToString('element.setAttribute("' + contentAttributeName + '", 456); element.' + idlAttributeName, '456'); 50 shouldBeEqualToString('element.setAttribute("' + contentAttributeName + '", 456); element.' + idlAttributeName, '456');
46 shouldBeEqualToString('element.getAttribute("' + contentAttributeName + '")' , '456'); 51 shouldBeEqualToString('element.getAttribute("' + contentAttributeName + '")' , '456');
47 52
48 debug('\n'); 53 debug('\n');
49 } 54 }
50 55
51 testDOMStringReflection('button', 'name'); 56 testDOMStringReflection('button', 'name', 'name', true);
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
62 // Add more DOMString attributes! 67 // Add more DOMString attributes!
63 68
64 </script> 69 </script>
65 </body> 70 </body>
66 </html> 71 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698