Home | History | Annotate | Download | only in script-tests
      1 description('Test TreeWalker with skipping');
      2 
      3 var walker;
      4 var testElement = document.createElement("div");
      5 testElement.innerHTML='<div id="A1"><div id="B1" class="keep"></div><div id="B2">this text matters</div><div id="B3" class="keep"></div></div>';
      6 
      7 var filter = {
      8   acceptNode: function(node) {
      9     if (node.className == 'keep')
     10       return NodeFilter.FILTER_ACCEPT;
     11 
     12     return NodeFilter.FILTER_SKIP;
     13   }
     14 }
     15 
     16 debug("<br>Testing nextSibling")
     17 walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, filter, false);
     18 shouldBe("walker.firstChild(); walker.currentNode.id", "'B1'");
     19 shouldBe("walker.nextSibling(); walker.currentNode.id", "'B3'");
     20 
     21 debug("<br>Testing previousSibling")
     22 walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, filter, false);
     23 walker.currentNode = testElement.querySelectorAll('#B3')[0];
     24 shouldBe("walker.previousSibling(); walker.currentNode.id", "'B1'");
     25 
     26 
     27 var successfullyParsed = true;
     28