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

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 after adding descriptive message. 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
« no previous file with comments | « no previous file | LayoutTests/fast/dom/domparser-parsefromstring-mimetype-support-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 <!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) {
126 var message = document.createElement("div");
127 message.className = "pass";
128 message.textContent = exception;
129 document.body.appendChild(message);
121 var result = document.createElement("div"); 130 var result = document.createElement("div");
122 result.className = "pass"; 131 result.className = "pass";
123 result.textContent = "PASS"; 132 result.textContent = "PASS";
124 document.body.appendChild(result); 133 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 } 134 }
131 document.body.appendChild(document.createElement("br")); 135 document.body.appendChild(document.createElement("br"));
132 } 136 }
133 137
134 function runTest() 138 function runTest()
135 { 139 {
136 if (window.testRunner) { 140 if (window.testRunner) {
137 testRunner.dumpAsText(); 141 testRunner.dumpAsText();
138 } 142 }
139 shouldSupport(htmlContent, "text/html"); 143 shouldSupport(htmlContent, "text/html");
140 shouldSupport(xmlContent, "text/xml"); 144 shouldSupport(xmlContent, "text/xml");
141 shouldSupport(xmlContent, "application/xml"); 145 shouldSupport(xmlContent, "application/xml");
142 shouldSupport(xhtmlContent, "application/xhtml+xml"); 146 shouldSupport(xhtmlContent, "application/xhtml+xml");
143 shouldSupport(svgImageContent, "image/svg+xml"); 147 shouldSupport(svgImageContent, "image/svg+xml");
144 shouldNotSupport(xslContent, "text/xsl"); 148 shouldThrowException(xslContent, "text/xsl");
149 shouldThrowException(xmlContent, "text/dummy+xml");
150 shouldThrowException(xmlContent, "text/XML");
151 shouldThrowException(xmlContent, "TEXT/html");
145 } 152 }
146 </script> 153 </script>
147 </head> 154 </head>
148 <body onload="runTest();"> 155 <body onload="runTest();">
149 <p>This tests DOMParser supports creating Document for HTML content with mime-ty pe "text/html".</p> 156 <p>This tests DOMParser supports creating Document for HTML content with mime-ty pe "text/html".</p>
150 </body> 157 </body>
151 </html> 158 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/dom/domparser-parsefromstring-mimetype-support-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698