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=566629 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 566629</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=566629">Mozilla Bug 566629</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 566629 **/ |
michael@0 | 21 | |
michael@0 | 22 | var xsltdoc = new DOMParser().parseFromString( |
michael@0 | 23 | '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\ |
michael@0 | 24 | xmlns:xhtml="http://www.w3.org/1999/xhtml">\ |
michael@0 | 25 | <xsl:template match="/">\ |
michael@0 | 26 | <xsl:value-of select="count(//body)"/>\ |
michael@0 | 27 | <xsl:text>,</xsl:text>\ |
michael@0 | 28 | <xsl:value-of select="count(//xhtml:body)"/>\ |
michael@0 | 29 | <xsl:text>,</xsl:text>\ |
michael@0 | 30 | <xsl:value-of select="count(//xsl:body)"/>\ |
michael@0 | 31 | <xsl:text>,</xsl:text>\ |
michael@0 | 32 | <xsl:value-of select="name(//body)"/>\ |
michael@0 | 33 | <xsl:text>,</xsl:text>\ |
michael@0 | 34 | <xsl:value-of select="local-name(//body)"/>\ |
michael@0 | 35 | </xsl:template>\ |
michael@0 | 36 | </xsl:stylesheet>', |
michael@0 | 37 | "text/xml"); |
michael@0 | 38 | |
michael@0 | 39 | var processor = new XSLTProcessor; |
michael@0 | 40 | processor.importStylesheet(xsltdoc); |
michael@0 | 41 | var result = processor.transformToFragment(document, document); |
michael@0 | 42 | ok(result instanceof DocumentFragment, "returned a docfragment"); |
michael@0 | 43 | is(result.firstChild.nodeValue, "1,1,0,BODY,body", |
michael@0 | 44 | "correct treatment of HTML elements in XSLT"); |
michael@0 | 45 | |
michael@0 | 46 | is(document.evaluate("count(//body)", document, null, XPathResult.ANY_TYPE, null).numberValue, |
michael@0 | 47 | 1, "namespace-less node-test"); |
michael@0 | 48 | is(document.evaluate("count(//a:body)", document, |
michael@0 | 49 | function() { return "http://www.w3.org/1999/xhtml" }, |
michael@0 | 50 | XPathResult.ANY_TYPE, null).numberValue, |
michael@0 | 51 | 1, "with-namespace node-test"); |
michael@0 | 52 | is(document.evaluate("count(//a:body)", document, |
michael@0 | 53 | function() { return "foo" }, |
michael@0 | 54 | XPathResult.ANY_TYPE, null).numberValue, |
michael@0 | 55 | 0, "wrong-namespace node-test"); |
michael@0 | 56 | is(document.evaluate("//bODy", document, null, XPathResult.ANY_TYPE, null).iterateNext(), |
michael@0 | 57 | document.body, "case insensitive matching"); |
michael@0 | 58 | is(document.evaluate("count(//a:bODy)", document, |
michael@0 | 59 | function() { return "http://www.w3.org/1999/xhtml" }, |
michael@0 | 60 | XPathResult.ANY_TYPE, null).numberValue, |
michael@0 | 61 | 0, "with-namespace but wrong casing node-test"); |
michael@0 | 62 | is(document.evaluate("name(//body)", document, null, XPathResult.ANY_TYPE, null).stringValue, |
michael@0 | 63 | "BODY", "uppercase name() function"); |
michael@0 | 64 | is(document.evaluate("local-name(//body)", document, null, XPathResult.ANY_TYPE, null).stringValue, |
michael@0 | 65 | "body", "lowercase local-name() function"); |
michael@0 | 66 | |
michael@0 | 67 | </script> |
michael@0 | 68 | </pre> |
michael@0 | 69 | </body> |
michael@0 | 70 | </html> |