OLD | NEW |
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 Loading... |
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> |
OLD | NEW |