OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script> |
| 5 function parseHTMLContent() |
| 6 { |
| 7 var htmlContent = |
| 8 "<!DOCTYPE html>" + |
| 9 "<html>" + |
| 10 "<head>" + |
| 11 "<noscript>" + |
| 12 "<p>Scripts must be disabled for the document cr
eated using DOMParser.parseFromString()</p>" + |
| 13 "</noscript>" + |
| 14 "</head>" + |
| 15 "<body>" + |
| 16 "<div id='text'></div>" + |
| 17 "<script>document.getElementById('text').textContent
= 'Newly added text';<\/script>" + |
| 18 "</body>" + |
| 19 "</html>"; |
| 20 var parser = new DOMParser(); |
| 21 var htmlDocument = parser.parseFromString(htmlContent, "text/html"); |
| 22 if (!htmlDocument) |
| 23 document.getElementById("result").textContent = "FAIL"; |
| 24 else { |
| 25 document.getElementById("result").textContent = "PASS"; |
| 26 document.getElementById("content").innerHTML = htmlDocument.documentElem
ent.innerHTML; |
| 27 } |
| 28 } |
| 29 |
| 30 function runTest() |
| 31 { |
| 32 if (window.testRunner) { |
| 33 testRunner.dumpAsText(); |
| 34 } |
| 35 parseHTMLContent(); |
| 36 } |
| 37 </script> |
| 38 </head> |
| 39 <body onload="runTest();"> |
| 40 <p>This tests DOMParser supports creating Document for HTML content with mime-ty
pe "text/html".</p> |
| 41 <div id="content"></div> |
| 42 <div id="result"></div> |
| 43 </body> |
| 44 </html> |
OLD | NEW |