Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / xsl / extra-lf-at-end.html
blobad2ca02c5bc185e569bc29438a0c43922e6ed4f9
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <title>bug 15919</title>
5 </head>
6 <body>
7 <p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=15919">bug 15919</a>:
8 XSLTProcessor.transformToFragment creates an extra not defined TEXT_NODE at the end.</p>
9 <div id="log"></div>
11 <script type="text/javascript">
13 if (window.testRunner)
14 testRunner.dumpAsText();
16 function log(message) {
17 var newChild = document.createElement("div");
18 newChild.appendChild(document.createTextNode(message));
19 document.getElementById("log").appendChild(newChild);
22 function assertEquals(oExpected, oExpr, sWarning) {
23 oActual = eval(oExpr);
24 if(oExpected !== oActual)
25 log('FAIL: Expected "'+ oExpected+'" was: "'+oActual+'" - '+sWarning);
26 else
27 log('PASS: ' + oExpr + ' ' + sWarning);
30 var oProc = new XSLTProcessor();
32 var oStylesheet = new DOMParser().parseFromString(
33 '<?xml version="1.0" encoding="UTF-8"?>' +
34 '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">'+
35 '<xsl:output method="xml" omit-xml-declaration="yes" />'+
36 '<xsl:param name="text" select="\'default\'" />'+
37 '<xsl:template match="/">'+
38 '<div><xsl:value-of select="$text" /></div>'+
39 '<br />'+
40 '</xsl:template>'+
41 '</xsl:stylesheet>', 'text/xml');
43 oProc.importStylesheet(oStylesheet);
44 var oResult = new DOMParser().parseFromString('<root />', 'text/xml');
46 oProc.setParameter('', 'text', 'Hello World!');
48 oResult = oProc.transformToFragment(oStylesheet, oResult);
50 assertEquals(11, "oResult.nodeType", 'should of type DOCUMENT_FRAGMENT_NODE(11)')
51 assertEquals('Hello World!', "oProc.getParameter(null, 'text')", 'getParameter should return the correct value');
52 assertEquals('div', "oResult.firstChild.nodeName", 'can have multiple children, firstchild should be the div');
53 assertEquals('br', "oResult.lastChild.nodeName", 'can have multiple children, lastchild should be the br');
54 assertEquals('Hello World!', "oResult.firstChild.textContent || oResult.firstChild.text", 'textContent should be set to parameter value');
55 log("Done");
56 </script>
57 </body>
58 </html>