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

Side by Side Diff: LayoutTests/fast/dom/domparser-parsefromstring-mimetype-support.html

Issue 24483007: Make DOMParser::parseFromString specification compliant and throw exception in error scenario. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing! Created 7 years, 2 months 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 <head> 3 <head>
4 <style> 4 <style>
5 .fail { 5 .fail {
6 color: red; 6 color: red;
7 font-weight: bold; 7 font-weight: bold;
8 } 8 }
9 9
10 .pass { 10 .pass {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 document.body.appendChild(content); 102 document.body.appendChild(content);
103 103
104 var result = document.createElement("div"); 104 var result = document.createElement("div");
105 result.className = "pass"; 105 result.className = "pass";
106 result.textContent = "PASS"; 106 result.textContent = "PASS";
107 document.body.appendChild(result); 107 document.body.appendChild(result);
108 } 108 }
109 document.body.appendChild(document.createElement("br")); 109 document.body.appendChild(document.createElement("br"));
110 } 110 }
111 111
112 function shouldNotSupport(content, mimeType) 112 function shouldThrowException(content, mimeType)
113 { 113 {
114 var description = document.createElement("div"); 114 var description = document.createElement("div");
115 description.innerHTML = (++count) + ". Should NOT support mime-type = \"" + mimeType + "\""; 115 description.innerHTML = (++count) + ". Should THROW exception for mime-type = \"" + mimeType + "\"";
116 document.body.appendChild(description); 116 document.body.appendChild(description);
117 117
118 var parser = new DOMParser(); 118 var parser = new DOMParser();
119 var resultDocument = parser.parseFromString(content, mimeType); 119 try {
120 if (!resultDocument) { 120 parser.parseFromString(content, mimeType);
121 var result = document.createElement("div");
122 result.className = "fail";
123 result.textContent = "FAIL";
124 document.body.appendChild(result);
125 } catch (exception) {
121 var result = document.createElement("div"); 126 var result = document.createElement("div");
122 result.className = "pass"; 127 result.className = "pass";
123 result.textContent = "PASS"; 128 result.textContent = "PASS";
124 document.body.appendChild(result); 129 document.body.appendChild(result);
125 } else {
126 var result = document.createElement("div");
127 result.className = "fail";
128 result.textContent = "FAIL";
129 document.body.appendChild(result);
130 } 130 }
131 document.body.appendChild(document.createElement("br")); 131 document.body.appendChild(document.createElement("br"));
132 } 132 }
133 133
134 function runTest() 134 function runTest()
135 { 135 {
136 if (window.testRunner) { 136 if (window.testRunner) {
137 testRunner.dumpAsText(); 137 testRunner.dumpAsText();
138 } 138 }
139 shouldSupport(htmlContent, "text/html"); 139 shouldSupport(htmlContent, "text/html");
140 shouldSupport(xmlContent, "text/xml"); 140 shouldSupport(xmlContent, "text/xml");
141 shouldSupport(xmlContent, "application/xml"); 141 shouldSupport(xmlContent, "application/xml");
142 shouldSupport(xhtmlContent, "application/xhtml+xml"); 142 shouldSupport(xhtmlContent, "application/xhtml+xml");
143 shouldSupport(svgImageContent, "image/svg+xml"); 143 shouldSupport(svgImageContent, "image/svg+xml");
144 shouldNotSupport(xslContent, "text/xsl"); 144 shouldThrowException(xslContent, "text/xsl");
145 shouldThrowException(xmlContent, "text/dummy+xml");
146 shouldThrowException(xmlContent, "text/XML");
147 shouldThrowException(xmlContent, "TEXT/html");
145 } 148 }
146 </script> 149 </script>
147 </head> 150 </head>
148 <body onload="runTest();"> 151 <body onload="runTest();">
149 <p>This tests DOMParser supports creating Document for HTML content with mime-ty pe "text/html".</p> 152 <p>This tests DOMParser supports creating Document for HTML content with mime-ty pe "text/html".</p>
150 </body> 153 </body>
151 </html> 154 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698