Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=440974 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 440974</title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=440974">Mozilla Bug 440974</a> |
michael@0 | 13 | <p id="display"></p> |
michael@0 | 14 | <div id="content" style="display: none"> |
michael@0 | 15 | |
michael@0 | 16 | </div> |
michael@0 | 17 | <pre id="test"> |
michael@0 | 18 | <script class="testbody" type="text/javascript"> |
michael@0 | 19 | |
michael@0 | 20 | /** Test for Bug 440974 **/ |
michael@0 | 21 | |
michael@0 | 22 | function isTxResult(node) |
michael@0 | 23 | { |
michael@0 | 24 | return node.namespaceURI == "http://www.mozilla.org/TransforMiix" && |
michael@0 | 25 | node.localName == "result"; |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | var xmldoc, xsltdoc; |
michael@0 | 29 | [ xmldoc, xsltdoc ] = [ new DOMParser().parseFromString(xml, "text/xml") for (xml of [ |
michael@0 | 30 | |
michael@0 | 31 | '<items><item><id>1</id></item><item><id>2</id></item><item><id>3</id></item></items>' , |
michael@0 | 32 | |
michael@0 | 33 | '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\n\ |
michael@0 | 34 | <xsl:output method="xml" />\n\ |
michael@0 | 35 | <xsl:template match="item"><foo id="{id}"/></xsl:template>\n\ |
michael@0 | 36 | </xsl:stylesheet>' |
michael@0 | 37 | |
michael@0 | 38 | ]) ]; |
michael@0 | 39 | var processor = new XSLTProcessor; |
michael@0 | 40 | processor.importStylesheet(xsltdoc); |
michael@0 | 41 | var result = processor.transformToDocument(xmldoc); |
michael@0 | 42 | var resultElements = Array.prototype.filter.call(result.getElementsByTagName('*'), isTxResult); |
michael@0 | 43 | is(resultElements.length, 1, "there should be only one 'transformiix:result' element"); |
michael@0 | 44 | is(resultElements[0], result.documentElement, "the 'transformiix:result' element should be the document element"); |
michael@0 | 45 | |
michael@0 | 46 | </script> |
michael@0 | 47 | </pre> |
michael@0 | 48 | </body> |
michael@0 | 49 | </html> |