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