| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <p>This test checks whether XSLTProcessor.transformToFragment() does not crash |
| when the target document does not have a root node.</p> |
| 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>' + |
| var p = new XSLTProcessor; |
| 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); |
| <p>PASS: You didn't crash.</p> |