| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <body> |
| <p>This test checks whether XSLTProcessor.transformToFragment() does not crash |
| when the target document does not have a root node.</p> |
| |
| <div id="console"></div> |
| <script> |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| |
| var xml = (new DOMParser()).parseFromString('<doc/>', 'application/xml'); |
| var xsl = (new DOMParser()).parseFromString( |
| '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">' + |
| '<xsl:output method="xml" omit-xml-declaration="yes"/>' + |
| ' <xsl:template match="doc">SUCCESS</xsl:template>' + |
| '</xsl:stylesheet>', |
| 'application/xml'); |
| |
| var p = new XSLTProcessor; |
| p.importStylesheet(xsl); |
| var ownerDocument = document.implementation.createDocument("", "", null); |
| var f = p.transformToFragment(xml, ownerDocument); |
| |
| // Firefox throws an exception here, while WebKit doesn't: |
| // "An attempt was made to create or change an object in a way which is incorrect with regard to namespaces." |
| ownerDocument = document.implementation.createDocument("", null, null); |
| f = p.transformToFragment(xml, ownerDocument); |
| </script> |
| <p>PASS: You didn't crash.</p> |
| </body> |
| </html> |