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

Side by Side Diff: LayoutTests/fast/dom/element-attribute-js-null.html

Issue 35803004: Remove TreatNullAs=NullString for media interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
« no previous file with comments | « no previous file | LayoutTests/fast/dom/element-attribute-js-null-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <style type="text/css"> 3 <style type="text/css">
4 .pass { color: green; } 4 .pass { color: green; }
5 .fail { color: red; } 5 .fail { color: red; }
6 </style> 6 </style>
7 <script> 7 <script>
8 function printOut(msg) 8 function printOut(msg)
9 { 9 {
10 var console = document.getElementById("console"); 10 var console = document.getElementById("console");
11 var span = document.createElement('span'); 11 var span = document.createElement('span');
12 span.innerHTML = msg + '<br>'; 12 span.innerHTML = msg + '<br>';
13 console.appendChild(span); 13 console.appendChild(span);
14 } 14 }
15 15
16 function resultStringifier(result) 16 function resultStringifier(result)
17 { 17 {
18 if (result === "") 18 if (result === "")
19 return "<b>the empty string</b>"; 19 return "<b>the empty string</b>";
20 else if (result === null) 20 else if (result === null)
21 return "<b>null</b>"; 21 return "<b>null</b>";
22 else if (result === undefined) 22 else if (result === undefined)
23 return "<b>undefined</b>"; 23 return "<b>undefined</b>";
24 return "the string '" + result + "'"; 24 return "the string '" + result + "'";
25 } 25 }
26 26
27 function nullTestElementAttribute(elementType, element, attr, expected) 27 function resolve(url)
28 {
29 var a = document.createElement('a');
30 a.href = url;
31 return a.href;
32 }
33
34 function nullTestElementAttribute(elementType, element, attr, expected, isUrl)
28 { 35 {
29 var exceptionThrown; 36 var exceptionThrown;
30 try { 37 try {
31 element[attr] = null; 38 element[attr] = null;
32 } catch (ec) { 39 } catch (ec) {
33 exceptionThrown = ec; 40 exceptionThrown = ec;
34 } 41 }
35 var result; 42 var result;
36 if (exceptionThrown) { 43 if (exceptionThrown) {
37 if (expected === 'exception') 44 if (expected === 'exception')
38 result = "<span class='pass'>TEST SUCCEEDED:</span> Exceptio n (" + exceptionThrown + ") was thrown as expected."; 45 result = "<span class='pass'>TEST SUCCEEDED:</span> Exceptio n (" + exceptionThrown + ") was thrown as expected.";
39 else 46 else
40 result = "<span class='fail'>TEST FAILED:</span> An exceptio n was thrown unexpectedly."; 47 result = "<span class='fail'>TEST FAILED:</span> An exceptio n was thrown unexpectedly.";
41 } else { 48 } else {
42 if (expected === 'exception') 49 if (expected === 'exception')
43 result = "<span class='fail'>TEST FAILED:</span> An exceptio n should have been thrown."; 50 result = "<span class='fail'>TEST FAILED:</span> An exceptio n should have been thrown.";
51 else if (isUrl && element[attr] === resolve(expected))
52 result = "<span class='pass'>TEST SUCCEEDED:</span> The valu e was " + resultStringifier(expected) + " resolved as a URL.";
44 else if (element[attr] === expected) 53 else if (element[attr] === expected)
45 result = "<span class='pass'>TEST SUCCEEDED:</span> The valu e was " + resultStringifier(expected) + "."; 54 result = "<span class='pass'>TEST SUCCEEDED:</span> The valu e was " + resultStringifier(expected) + ".";
46 else 55 else
47 result = "<span class='fail'>TEST FAILED:</span> The value s hould have been " + resultStringifier(expected) + " but was " + resultStringifie r(element[attr]) + "."; 56 result = "<span class='fail'>TEST FAILED:</span> The value s hould have been " + resultStringifier(expected) + " but was " + resultStringifie r(element[attr]) + ".";
48 } 57 }
49 result += " [tested " + elementType + "." + attr + "]"; 58 result += " [tested " + elementType + "." + attr + "]";
50 printOut(result); 59 printOut(result);
51 } 60 }
52 61
53 function runTests() 62 function runTests()
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 {name: 'coords', expectedNull: ''}, 144 {name: 'coords', expectedNull: ''},
136 {name: 'href', expectedNull: ''}, 145 {name: 'href', expectedNull: ''},
137 {name: 'shape', expectedNull: ''}, 146 {name: 'shape', expectedNull: ''},
138 {name: 'target', expectedNull: ''} 147 {name: 'target', expectedNull: ''}
139 ] 148 ]
140 }, 149 },
141 { 150 {
142 type: 'HTMLAudioElement', 151 type: 'HTMLAudioElement',
143 elementToUse: document.createElement('audio'), 152 elementToUse: document.createElement('audio'),
144 attributes: [ 153 attributes: [
145 {name: 'mediaGroup', expectedNull: ''}, 154 {name: 'mediaGroup', expectedNull: 'null'},
146 {name: 'preload', expectedNull: 'auto'}, 155 {name: 'preload', expectedNull: 'auto'},
147 {name: 'src', expectedNull: ''} 156 {name: 'src', expectedNull: 'null', isUrl: true}
148 ] 157 ]
149 }, 158 },
150 { 159 {
151 type: 'HTMLBaseElement', 160 type: 'HTMLBaseElement',
152 elementToUse: document.createElement('base'), 161 elementToUse: document.createElement('base'),
153 attributes: [ 162 attributes: [
154 {name: 'target', expectedNull: ''} 163 {name: 'target', expectedNull: ''}
155 ] 164 ]
156 }, 165 },
157 { 166 {
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 attributes: [ 498 attributes: [
490 {name: 'value', expectedNull: ''}, 499 {name: 'value', expectedNull: ''},
491 {name: 'name', expectedNull: ''} 500 {name: 'name', expectedNull: ''}
492 ] 501 ]
493 }, 502 },
494 { 503 {
495 type: 'HTMLSourceElement', 504 type: 'HTMLSourceElement',
496 elementToUse: document.createElement('source'), 505 elementToUse: document.createElement('source'),
497 attributes: [ 506 attributes: [
498 {name: 'media', expectedNull: 'null'}, 507 {name: 'media', expectedNull: 'null'},
499 {name: 'src', expectedNull: ''}, 508 {name: 'src', expectedNull: 'null', isUrl:true},
500 {name: 'type', expectedNull: 'null'} 509 {name: 'type', expectedNull: 'null'}
501 ] 510 ]
502 }, 511 },
503 { 512 {
504 type: 'HTMLStyleElement', 513 type: 'HTMLStyleElement',
505 elementToUse: document.createElement('style'), 514 elementToUse: document.createElement('style'),
506 attributes: [ 515 attributes: [
507 {name: 'media', expectedNull: ''}, 516 {name: 'media', expectedNull: ''},
508 {name: 'type', expectedNull: ''} 517 {name: 'type', expectedNull: ''}
509 ] 518 ]
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 attributes: [ 604 attributes: [
596 {name: 'text', expectedNull: ''} 605 {name: 'text', expectedNull: ''}
597 ] 606 ]
598 }, 607 },
599 { 608 {
600 type: 'HTMLTrackElement', 609 type: 'HTMLTrackElement',
601 elementToUse: document.createElement('track'), 610 elementToUse: document.createElement('track'),
602 attributes: [ 611 attributes: [
603 {name: 'kind', expectedNull: 'subtitles'}, 612 {name: 'kind', expectedNull: 'subtitles'},
604 {name: 'label', expectedNull: 'null'}, 613 {name: 'label', expectedNull: 'null'},
605 {name: 'src', expectedNull: ''}, 614 {name: 'src', expectedNull: 'null', isUrl:true},
606 {name: 'srclang', expectedNull: 'null'} 615 {name: 'srclang', expectedNull: 'null'}
607 ] 616 ]
608 }, 617 },
609 { 618 {
610 type: 'HTMLUListElement', 619 type: 'HTMLUListElement',
611 elementToUse: document.createElement('ul'), 620 elementToUse: document.createElement('ul'),
612 attributes: [ 621 attributes: [
613 {name: 'type', expectedNull: ''} 622 {name: 'type', expectedNull: ''}
614 ] 623 ]
615 }, 624 },
616 { 625 {
617 type: 'HTMLVideoElement', 626 type: 'HTMLVideoElement',
618 elementToUse: document.createElement('video'), 627 elementToUse: document.createElement('video'),
619 attributes: [ 628 attributes: [
620 {name: 'mediaGroup', expectedNull: ''}, 629 {name: 'mediaGroup', expectedNull: 'null'},
621 {name: 'poster', expectedNull: ''}, 630 {name: 'poster', expectedNull: 'null', isUrl:true},
622 {name: 'preload', expectedNull: 'auto'}, 631 {name: 'preload', expectedNull: 'auto'},
623 {name: 'src', expectedNull: ''} 632 {name: 'src', expectedNull: 'null', isUrl: true}
624 ] 633 ]
625 } 634 }
626 ]; 635 ];
627 636
628 for (element in listing) { 637 for (element in listing) {
629 var type = listing[element].type; 638 var type = listing[element].type;
630 var elementToUse = listing[element].elementToUse; 639 var elementToUse = listing[element].elementToUse;
631 var attrs = listing[element].attributes; 640 var attrs = listing[element].attributes;
632 for (attr in attrs) { 641 for (attr in attrs) {
633 nullTestElementAttribute(type, elementToUse, attrs[attr].nam e, attrs[attr].expectedNull); 642 nullTestElementAttribute(type, elementToUse, attrs[attr].nam e, attrs[attr].expectedNull, attrs[attr].isUrl);
634 } 643 }
635 printOut(''); 644 printOut('');
636 } 645 }
637 } 646 }
638 </script> 647 </script>
639 </head> 648 </head>
640 <body onload="runTests()"> 649 <body onload="runTests()">
641 <p>This test setting various attributes of a elements to JavaScript null.</p > 650 <p>This test setting various attributes of a elements to JavaScript null.</p >
642 <div id="console"></div> 651 <div id="console"></div>
643 </body> 652 </body>
644 </html> 653 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/dom/element-attribute-js-null-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698