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