Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / xsl / xslt-processor-template.html
blob55a0ddcc0f8f83a0b38a8dedfd0a791e6da0d837
1 <html>
2 <head>
3 </head>
4 <body id="body">
5 <p>This tests that XSLT transforms can traverse into XHTML template element content when applying XSL template.
6 If the test succeeds, the transform will have swapped the position of the body spans (A and B) with the template content spans (C and D)
7 and replaced the spans with divs.</p>
8 <script>
9 if (window.testRunner)
10 testRunner.dumpAsText();
12 var requester = new XMLHttpRequest();
13 var processor = new XSLTProcessor();
14 var serializer = new XMLSerializer();
16 function getXMLDocument(name)
18 requester.open("GET", name, false);
19 requester.send(null);
20 return requester.responseXML;
23 function addStringResult(text)
25 document.writeln("<span>" + text + "</span>");
28 function divChildTextNodes(parent) {
29 var output = '';
31 for (var child = parent.firstChild; child; child = child.nextSibling) {
32 if (child.tagName == 'div') {
33 output += child.textContent;
37 return output;
40 var xml = getXMLDocument("xslt-xhtml-template.xml");
41 var xsl = getXMLDocument("resources/xhtml-template.xsl");
43 processor.importStylesheet(xsl);
45 var ownerDocument = document.implementation.createDocument("", "test", null);
46 var frag = processor.transformToFragment(xml, ownerDocument);
48 addStringResult('Body divs: ' + divChildTextNodes(frag.querySelector('body')) +
49 ', Template content divs: ' + divChildTextNodes(frag.querySelector('template').content));
51 </script>
52 </body>
53 </html>