test_bug566629.xhtml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <!--
  3. https://bugzilla.mozilla.org/show_bug.cgi?id=566629
  4. -->
  5. <head>
  6. <title>Test for Bug 566629</title>
  7. <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  8. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  9. </head>
  10. <body>
  11. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=566629">Mozilla Bug 566629</a>
  12. <p id="display"></p>
  13. <div id="content" style="display: none">
  14. </div>
  15. <pre id="test">
  16. <script class="testbody" type="text/javascript">
  17. <![CDATA[
  18. /** Test for Bug 566629 **/
  19. var xsltdoc = new DOMParser().parseFromString(
  20. '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\
  21. xmlns:xhtml="http://www.w3.org/1999/xhtml">\
  22. <xsl:template match="/">\
  23. <xsl:value-of select="count(//body)"/>\
  24. <xsl:text>,</xsl:text>\
  25. <xsl:value-of select="count(//xhtml:body)"/>\
  26. <xsl:text>,</xsl:text>\
  27. <xsl:value-of select="count(//xsl:body)"/>\
  28. <xsl:text>,</xsl:text>\
  29. <xsl:value-of select="name(//xhtml:body)"/>\
  30. <xsl:text>,</xsl:text>\
  31. <xsl:value-of select="local-name(//xhtml:body)"/>\
  32. </xsl:template>\
  33. </xsl:stylesheet>',
  34. "text/xml");
  35. var processor = new XSLTProcessor;
  36. processor.importStylesheet(xsltdoc);
  37. var result = processor.transformToFragment(document, document);
  38. ok(result instanceof DocumentFragment, "returned a docfragment");
  39. is(result.firstChild.nodeValue, "0,1,0,body,body",
  40. "correct treatment of HTML elements in XSLT");
  41. is(document.evaluate("count(//body)", document, null, XPathResult.ANY_TYPE, null).numberValue,
  42. 0, "namespace-less node-test");
  43. is(document.evaluate("count(//a:body)", document,
  44. function() { return "http://www.w3.org/1999/xhtml" },
  45. XPathResult.ANY_TYPE, null).numberValue,
  46. 1, "with-namespace node-test");
  47. is(document.evaluate("count(//a:body)", document,
  48. function() { return "foo" },
  49. XPathResult.ANY_TYPE, null).numberValue,
  50. 0, "wrong-namespace node-test");
  51. is(document.evaluate("count(//a:bODy)", document,
  52. function() { return "http://www.w3.org/1999/xhtml" },
  53. XPathResult.ANY_TYPE, null).numberValue,
  54. 0, "with-namespace wrong-casing node-test");
  55. is(document.evaluate("count(//bODy)", document, null, XPathResult.ANY_TYPE, null).numberValue,
  56. 0, "without-namespace wrong-casing node-test");
  57. is(document.evaluate("name(//a:body)", document,
  58. function() { return "http://www.w3.org/1999/xhtml" },
  59. XPathResult.ANY_TYPE, null).stringValue,
  60. "body", "name()");
  61. is(document.evaluate("local-name(//a:body)", document,
  62. function() { return "http://www.w3.org/1999/xhtml" },
  63. XPathResult.ANY_TYPE, null).stringValue,
  64. "body", "local-name()");
  65. ]]>
  66. </script>
  67. </pre>
  68. </body>
  69. </html>