content/base/test/test_bug276037-2.xhtml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/test/test_bug276037-2.xhtml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,106 @@
     1.4 +<html xmlns="http://www.w3.org/1999/xhtml">
     1.5 +<!--
     1.6 +https://bugzilla.mozilla.org/show_bug.cgi?id=276037
     1.7 +-->
     1.8 +<head>
     1.9 +  <title>Test for Bug 276037</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=276037">Mozilla Bug 276037</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 +
    1.23 +/** Test for Bug 276037 **/
    1.24 +function countElements (node, namespaceURI, tagName) {
    1.25 +  var count = 0;
    1.26 +  for (var i = 0; i < node.childNodes.length; i++) {
    1.27 +    var child = node.childNodes[i];
    1.28 +    if (child.nodeType == Node.ELEMENT_NODE && child.tagName == tagName &&
    1.29 +        child.namespaceURI == namespaceURI) {
    1.30 +      count++;
    1.31 +    }
    1.32 +    if (child.hasChildNodes()) {
    1.33 +      count += countElements(child, namespaceURI, tagName);
    1.34 +    }
    1.35 +  }
    1.36 +  return count;
    1.37 +}
    1.38 +
    1.39 +function checkElements(namespaceURI, tagName) {
    1.40 +  var elementsNS = document.getElementsByTagNameNS(namespaceURI, tagName);
    1.41 +  var elements = document.getElementsByTagName(tagName);
    1.42 +  var elementCount = countElements(document, namespaceURI, tagName);
    1.43 +  const gEBTN = 'document.getElementsByTagName(\'' + tagName + '\').length: ' + elements.length;
    1.44 +  const gEBTNNS = '; document.getElementsByTagNameNS(\'' + namespaceURI + '\', \'' + tagName + '\').length: ' + elementsNS.length;
    1.45 +
    1.46 +  var text1 = gEBTN + '; element count: ' + elementCount;
    1.47 +  var text2 = gEBTNNS + '; element count: ' + elementCount;
    1.48 +
    1.49 +  is(elements.length, elementCount, text1);
    1.50 +  is(elementsNS.length, elementCount, text2);
    1.51 +  is(global.gEBTN[namespaceURI][tagName].length, elementCount, text1);
    1.52 +  is(global.gEBTNNS[namespaceURI][tagName].length, elementCount, text2);
    1.53 +}
    1.54 +
    1.55 +const xhtmlNS = 'http://www.w3.org/1999/xhtml';
    1.56 +
    1.57 +function checkSpansAndScripts () {
    1.58 +  checkElements(xhtmlNS, 'span');
    1.59 +  checkElements(xhtmlNS, 'script');
    1.60 +}
    1.61 +
    1.62 +SimpleTest.waitForExplicitFinish();
    1.63 +addLoadEvent(function() { checkSpansAndScripts() });
    1.64 +addLoadEvent(SimpleTest.finish);
    1.65 +
    1.66 +// Init our global lists
    1.67 +var global = {};
    1.68 +global.gEBTN = {};
    1.69 +global.gEBTN[xhtmlNS] = {};
    1.70 +global.gEBTNNS = {};
    1.71 +global.gEBTNNS[xhtmlNS] = {};
    1.72 +global.gEBTN[xhtmlNS].span = document.getElementsByTagName("span");
    1.73 +global.gEBTNNS[xhtmlNS].span = document.getElementsByTagNameNS(xhtmlNS, "span");
    1.74 +global.gEBTN[xhtmlNS].script = document.getElementsByTagName("script");
    1.75 +global.gEBTNNS[xhtmlNS].script = document.getElementsByTagNameNS(xhtmlNS, "script");
    1.76 +]]>
    1.77 +</script>
    1.78 +<p><span>Static text in span.</span></p>
    1.79 +<script type="text/javascript">
    1.80 +checkSpansAndScripts();
    1.81 +</script>
    1.82 +<p><span>Static text in span.</span></p>
    1.83 +<script type="text/javascript">
    1.84 +checkSpansAndScripts();
    1.85 +</script>
    1.86 +<p><span>Static text in span.</span></p>
    1.87 +<script type="text/javascript">
    1.88 +checkSpansAndScripts();
    1.89 +</script>
    1.90 +<p><span>Static text in span.</span></p>
    1.91 +<script type="text/javascript">
    1.92 +checkSpansAndScripts();
    1.93 +</script>
    1.94 +<p><span>Static text in span.</span></p>
    1.95 +<script type="text/javascript">
    1.96 +checkSpansAndScripts();
    1.97 +</script>
    1.98 +<p><span>Static text in span.</span></p>
    1.99 +<script type="text/javascript">
   1.100 +checkSpansAndScripts();
   1.101 +</script>
   1.102 +<p><span>Static text in span.</span></p>
   1.103 +<script type="text/javascript">
   1.104 +checkSpansAndScripts();
   1.105 +</script>
   1.106 +</pre>
   1.107 +</body>
   1.108 +</html>
   1.109 +

mercurial