summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/xsl/xslt-fragment-in-empty-doc.html
blob: 7fea5ba6ec7f6da31d5b64ca3c431ec951b2b806 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!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>