|
1 <html xmlns="http://www.w3.org/1999/xhtml"> |
|
2 <!-- |
|
3 https://bugzilla.mozilla.org/show_bug.cgi?id=276037 |
|
4 --> |
|
5 <head> |
|
6 <title>Test for Bug 276037</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=276037">Mozilla Bug 276037</a> |
|
12 <p id="display"></p> |
|
13 <div id="content" style="display: none"> |
|
14 |
|
15 </div> |
|
16 <pre id="test"> |
|
17 <script class="testbody" type="text/javascript"> |
|
18 <![CDATA[ |
|
19 |
|
20 /** Test for Bug 276037 **/ |
|
21 function countElements (node, namespaceURI, tagName) { |
|
22 var count = 0; |
|
23 for (var i = 0; i < node.childNodes.length; i++) { |
|
24 var child = node.childNodes[i]; |
|
25 if (child.nodeType == Node.ELEMENT_NODE && child.tagName == tagName && |
|
26 child.namespaceURI == namespaceURI) { |
|
27 count++; |
|
28 } |
|
29 if (child.hasChildNodes()) { |
|
30 count += countElements(child, namespaceURI, tagName); |
|
31 } |
|
32 } |
|
33 return count; |
|
34 } |
|
35 |
|
36 function checkElements(namespaceURI, tagName) { |
|
37 var elementsNS = document.getElementsByTagNameNS(namespaceURI, tagName); |
|
38 var elements = document.getElementsByTagName(tagName); |
|
39 var elementCount = countElements(document, namespaceURI, tagName); |
|
40 const gEBTN = 'document.getElementsByTagName(\'' + tagName + '\').length: ' + elements.length; |
|
41 const gEBTNNS = '; document.getElementsByTagNameNS(\'' + namespaceURI + '\', \'' + tagName + '\').length: ' + elementsNS.length; |
|
42 |
|
43 var text1 = gEBTN + '; element count: ' + elementCount; |
|
44 var text2 = gEBTNNS + '; element count: ' + elementCount; |
|
45 |
|
46 is(elements.length, elementCount, text1); |
|
47 is(elementsNS.length, elementCount, text2); |
|
48 is(global.gEBTN[namespaceURI][tagName].length, elementCount, text1); |
|
49 is(global.gEBTNNS[namespaceURI][tagName].length, elementCount, text2); |
|
50 } |
|
51 |
|
52 const xhtmlNS = 'http://www.w3.org/1999/xhtml'; |
|
53 |
|
54 function checkSpansAndScripts () { |
|
55 checkElements(xhtmlNS, 'span'); |
|
56 checkElements(xhtmlNS, 'script'); |
|
57 } |
|
58 |
|
59 SimpleTest.waitForExplicitFinish(); |
|
60 addLoadEvent(function() { checkSpansAndScripts() }); |
|
61 addLoadEvent(SimpleTest.finish); |
|
62 |
|
63 // Init our global lists |
|
64 var global = {}; |
|
65 global.gEBTN = {}; |
|
66 global.gEBTN[xhtmlNS] = {}; |
|
67 global.gEBTNNS = {}; |
|
68 global.gEBTNNS[xhtmlNS] = {}; |
|
69 global.gEBTN[xhtmlNS].span = document.getElementsByTagName("span"); |
|
70 global.gEBTNNS[xhtmlNS].span = document.getElementsByTagNameNS(xhtmlNS, "span"); |
|
71 global.gEBTN[xhtmlNS].script = document.getElementsByTagName("script"); |
|
72 global.gEBTNNS[xhtmlNS].script = document.getElementsByTagNameNS(xhtmlNS, "script"); |
|
73 ]]> |
|
74 </script> |
|
75 <p><span>Static text in span.</span></p> |
|
76 <script type="text/javascript"> |
|
77 checkSpansAndScripts(); |
|
78 </script> |
|
79 <p><span>Static text in span.</span></p> |
|
80 <script type="text/javascript"> |
|
81 checkSpansAndScripts(); |
|
82 </script> |
|
83 <p><span>Static text in span.</span></p> |
|
84 <script type="text/javascript"> |
|
85 checkSpansAndScripts(); |
|
86 </script> |
|
87 <p><span>Static text in span.</span></p> |
|
88 <script type="text/javascript"> |
|
89 checkSpansAndScripts(); |
|
90 </script> |
|
91 <p><span>Static text in span.</span></p> |
|
92 <script type="text/javascript"> |
|
93 checkSpansAndScripts(); |
|
94 </script> |
|
95 <p><span>Static text in span.</span></p> |
|
96 <script type="text/javascript"> |
|
97 checkSpansAndScripts(); |
|
98 </script> |
|
99 <p><span>Static text in span.</span></p> |
|
100 <script type="text/javascript"> |
|
101 checkSpansAndScripts(); |
|
102 </script> |
|
103 </pre> |
|
104 </body> |
|
105 </html> |
|
106 |