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 | <?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css" ?> |
michael@0 | 2 | <root> |
michael@0 | 3 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js" xmlns="http://www.w3.org/1999/xhtml"/> |
michael@0 | 4 | |
michael@0 | 5 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 6 | <p id="display"></p> |
michael@0 | 7 | <div id="content" style="display: none;"></div> |
michael@0 | 8 | <textarea id="test" style="height: 300px; max-width: 800px; overflow: scroll;" |
michael@0 | 9 | rows="10" cols="160" readonly="readonly"/> |
michael@0 | 10 | </body> |
michael@0 | 11 | |
michael@0 | 12 | <pre id="test" xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 13 | <script class="testbody" type="text/javascript" xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 14 | <![CDATA[ |
michael@0 | 15 | var passedNodes = new WeakMap(); |
michael@0 | 16 | function setPass(aNode) { |
michael@0 | 17 | passedNodes.set(aNode, true); |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 21 | |
michael@0 | 22 | window.addEventListener("load", function() { |
michael@0 | 23 | const nsIDOMNodeFilter = SpecialPowers.Ci.nsIDOMNodeFilter; |
michael@0 | 24 | var walker = document.createTreeWalker( |
michael@0 | 25 | document, |
michael@0 | 26 | nsIDOMNodeFilter.SHOW_TEXT | nsIDOMNodeFilter.SHOW_DOCUMENT, |
michael@0 | 27 | null |
michael@0 | 28 | ); |
michael@0 | 29 | setPass(walker.firstChild()); |
michael@0 | 30 | while (walker.nextSibling()) { |
michael@0 | 31 | setPass(walker.currentNode); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | /* |
michael@0 | 35 | From http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113/traversal.html#Traversal-TreeWalker |
michael@0 | 36 | Omitting nodes from the logical view of a subtree can result in a structure that |
michael@0 | 37 | is substantially different from the same subtree in the complete, unfiltered |
michael@0 | 38 | document. Nodes that are siblings in the TreeWalker view may be children of |
michael@0 | 39 | different, widely separated nodes in the original view. For instance, consider a |
michael@0 | 40 | NodeFilter that skips all nodes except for Text nodes and the root node of a |
michael@0 | 41 | document. In the logical view that results, all text nodes will be siblings and |
michael@0 | 42 | appear as direct children of the root node, no matter how deeply nested the |
michael@0 | 43 | structure of the original document. |
michael@0 | 44 | */ |
michael@0 | 45 | |
michael@0 | 46 | walker2 = document.createTreeWalker(document, nsIDOMNodeFilter.SHOW_TEXT, null); |
michael@0 | 47 | while (walker2.nextNode()) { |
michael@0 | 48 | var cNode = walker2.currentNode; |
michael@0 | 49 | ok(passedNodes.get(cNode), "Every text node should appear: " + walker2.currentNode.nodeValue); |
michael@0 | 50 | walker.currentNode = cNode; |
michael@0 | 51 | var parent = walker.parentNode(); |
michael@0 | 52 | is(parent, document, "parent of text node should be document"); |
michael@0 | 53 | |
michael@0 | 54 | // Check nextSibling's previousSibling. |
michael@0 | 55 | walker.currentNode = cNode; |
michael@0 | 56 | if (walker.nextSibling()) { |
michael@0 | 57 | is(cNode, walker.previousSibling(), "nextSibling.previousSibling should be consistent"); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | // Check previousSibling's nextSibling. |
michael@0 | 61 | walker.currentNode = cNode; |
michael@0 | 62 | if (walker.previousSibling()) { |
michael@0 | 63 | is(cNode, walker.nextSibling(), "previousSibling.nextSibling should be consistent"); |
michael@0 | 64 | } |
michael@0 | 65 | } |
michael@0 | 66 | SimpleTest.finish(); |
michael@0 | 67 | }, true); |
michael@0 | 68 | ]]> |
michael@0 | 69 | </script> |
michael@0 | 70 | </pre> |
michael@0 | 71 | |
michael@0 | 72 | <test> |
michael@0 | 73 | zero |
michael@0 | 74 | <one> |
michael@0 | 75 | one-A |
michael@0 | 76 | <two> |
michael@0 | 77 | two-A |
michael@0 | 78 | </two> |
michael@0 | 79 | <two> |
michael@0 | 80 | two-B |
michael@0 | 81 | </two> |
michael@0 | 82 | one-B |
michael@0 | 83 | </one> |
michael@0 | 84 | <one> |
michael@0 | 85 | one-C |
michael@0 | 86 | <two> |
michael@0 | 87 | two-D |
michael@0 | 88 | </two> |
michael@0 | 89 | <two> |
michael@0 | 90 | two-E |
michael@0 | 91 | </two> |
michael@0 | 92 | one-F |
michael@0 | 93 | </one> |
michael@0 | 94 | zero |
michael@0 | 95 | </test> |
michael@0 | 96 | </root> |
michael@0 | 97 |