blob: ad2ca02c5bc185e569bc29438a0c43922e6ed4f9 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>bug 15919</title>
</head>
<body>
<p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=15919">bug 15919</a>:
XSLTProcessor.transformToFragment creates an extra not defined TEXT_NODE at the end.</p>
<div id="log"></div>
<script type="text/javascript">
if (window.testRunner)
testRunner.dumpAsText();
function log(message) {
var newChild = document.createElement("div");
newChild.appendChild(document.createTextNode(message));
document.getElementById("log").appendChild(newChild);
}
function assertEquals(oExpected, oExpr, sWarning) {
oActual = eval(oExpr);
if(oExpected !== oActual)
log('FAIL: Expected "'+ oExpected+'" was: "'+oActual+'" - '+sWarning);
else
log('PASS: ' + oExpr + ' ' + sWarning);
}
var oProc = new XSLTProcessor();
var oStylesheet = new DOMParser().parseFromString(
'<?xml version="1.0" encoding="UTF-8"?>' +
'<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">'+
'<xsl:output method="xml" omit-xml-declaration="yes" />'+
'<xsl:param name="text" select="\'default\'" />'+
'<xsl:template match="/">'+
'<div><xsl:value-of select="$text" /></div>'+
'<br />'+
'</xsl:template>'+
'</xsl:stylesheet>', 'text/xml');
oProc.importStylesheet(oStylesheet);
var oResult = new DOMParser().parseFromString('<root />', 'text/xml');
oProc.setParameter('', 'text', 'Hello World!');
oResult = oProc.transformToFragment(oStylesheet, oResult);
assertEquals(11, "oResult.nodeType", 'should of type DOCUMENT_FRAGMENT_NODE(11)')
assertEquals('Hello World!', "oProc.getParameter(null, 'text')", 'getParameter should return the correct value');
assertEquals('div', "oResult.firstChild.nodeName", 'can have multiple children, firstchild should be the div');
assertEquals('br', "oResult.lastChild.nodeName", 'can have multiple children, lastchild should be the br');
assertEquals('Hello World!', "oResult.firstChild.textContent || oResult.firstChild.text", 'textContent should be set to parameter value');
log("Done");
</script>
</body>
</html>