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