1 //-------------------------------------------------------------------------------------------------------
2 // Java script library to run traversal layout tests
4 function dumpNodeIterator(it, expectedResult) {
5 var string = '<p><b>Expect ' + expectedResult + '</b>: ';
6 var checkIt = document.createNodeIterator(root, NodeFilter.SHOW_ELEMENT, testNodeFiter, false);
7 var printedPointer = false;
9 var node = checkIt.nextNode();
12 if (!printedPointer && (it.referenceNode == node || it.referenceNode == undefined)) {
13 printedPointer = true;
14 var s = it.referenceNode == undefined ? node.id + ' ' : '[' + node.id + '] ';
15 if (it.pointerBeforeReferenceNode)
21 string += node.id + " ";
27 //-------------------------------------------------------------------------------------------------------
29 function nodeDepth(node) {
31 while ((node = node.parentNode))
36 //-------------------------------------------------------------------------------------------------------
38 function dumpTreeWalker(tw, root, start, backwards) {
39 var string = '<p><b>Tree Walker: </b><br>';
40 if (root == undefined)
41 root = tw.currentNode;
42 var rootDepth = nodeDepth(root);
43 if (start == undefined)
45 tw.currentNode = start;
46 string += start.id + '<br>';
48 var current = tw.currentNode;
49 if (backwards == undefined)
52 backwards ? tw.previousNode() : tw.nextNode();
53 var n = tw.currentNode;
56 var depth = nodeDepth(n) - rootDepth;
57 for (i = 0; i < depth; i++)
59 string += n.id + '<br>';
64 //-------------------------------------------------------------------------------------------------------