dom/xslt/tests/mochitest/test_bug566629.xhtml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/xslt/tests/mochitest/test_bug566629.xhtml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +<html xmlns="http://www.w3.org/1999/xhtml">
     1.5 +<!--
     1.6 +https://bugzilla.mozilla.org/show_bug.cgi?id=566629
     1.7 +-->
     1.8 +<head>
     1.9 +  <title>Test for Bug 566629</title>
    1.10 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.11 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.12 +</head>
    1.13 +<body>
    1.14 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=566629">Mozilla Bug 566629</a>
    1.15 +<p id="display"></p>
    1.16 +<div id="content" style="display: none">
    1.17 +  
    1.18 +</div>
    1.19 +<pre id="test">
    1.20 +<script class="testbody" type="text/javascript">
    1.21 +<![CDATA[
    1.22 +/** Test for Bug 566629 **/
    1.23 +
    1.24 +var xsltdoc = new DOMParser().parseFromString(
    1.25 +    '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\
    1.26 +                     xmlns:xhtml="http://www.w3.org/1999/xhtml">\
    1.27 +       <xsl:template match="/">\
    1.28 +         <xsl:value-of select="count(//body)"/>\
    1.29 +         <xsl:text>,</xsl:text>\
    1.30 +         <xsl:value-of select="count(//xhtml:body)"/>\
    1.31 +         <xsl:text>,</xsl:text>\
    1.32 +         <xsl:value-of select="count(//xsl:body)"/>\
    1.33 +         <xsl:text>,</xsl:text>\
    1.34 +         <xsl:value-of select="name(//xhtml:body)"/>\
    1.35 +         <xsl:text>,</xsl:text>\
    1.36 +         <xsl:value-of select="local-name(//xhtml:body)"/>\
    1.37 +       </xsl:template>\
    1.38 +     </xsl:stylesheet>',
    1.39 +    "text/xml");
    1.40 +
    1.41 +var processor = new XSLTProcessor;
    1.42 +processor.importStylesheet(xsltdoc);
    1.43 +var result = processor.transformToFragment(document, document);
    1.44 +ok(result instanceof DocumentFragment, "returned a docfragment");
    1.45 +is(result.firstChild.nodeValue, "0,1,0,body,body",
    1.46 +   "correct treatment of HTML elements in XSLT");
    1.47 +
    1.48 +is(document.evaluate("count(//body)", document, null, XPathResult.ANY_TYPE, null).numberValue,
    1.49 +   0, "namespace-less node-test");
    1.50 +is(document.evaluate("count(//a:body)", document,
    1.51 +		     function() { return "http://www.w3.org/1999/xhtml" },
    1.52 +		     XPathResult.ANY_TYPE, null).numberValue,
    1.53 +   1, "with-namespace node-test");
    1.54 +is(document.evaluate("count(//a:body)", document,
    1.55 +		     function() { return "foo" },
    1.56 +		     XPathResult.ANY_TYPE, null).numberValue,
    1.57 +   0, "wrong-namespace node-test");
    1.58 +is(document.evaluate("count(//a:bODy)", document,
    1.59 +		     function() { return "http://www.w3.org/1999/xhtml" },
    1.60 +		     XPathResult.ANY_TYPE, null).numberValue,
    1.61 +   0, "with-namespace wrong-casing node-test");
    1.62 +is(document.evaluate("count(//bODy)", document, null, XPathResult.ANY_TYPE, null).numberValue,
    1.63 +   0, "without-namespace wrong-casing node-test");
    1.64 +is(document.evaluate("name(//a:body)", document,
    1.65 +		     function() { return "http://www.w3.org/1999/xhtml" },
    1.66 +		     XPathResult.ANY_TYPE, null).stringValue,
    1.67 +   "body", "name()");
    1.68 +is(document.evaluate("local-name(//a:body)", document,
    1.69 +		     function() { return "http://www.w3.org/1999/xhtml" },
    1.70 +		     XPathResult.ANY_TYPE, null).stringValue,
    1.71 +   "body", "local-name()");
    1.72 +]]>
    1.73 +</script>
    1.74 +</pre>
    1.75 +</body>
    1.76 +</html>

mercurial