Home | History | Annotate | Download | only in TreeWalker
      1 Test JS objects as NodeFilters.
      2 
      3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
      4 
      5 
      6 Testing with raw function filter
      7  filtering node A1
      8 PASS walker.firstChild(); walker.currentNode.id is 'A1'
      9  filtering node B1
     10  filtering node B2
     11 PASS walker.nextNode(); walker.currentNode.id is 'B2'
     12 
     13 Testing with object filter
     14  filtering node A1
     15 PASS walker.firstChild(); walker.currentNode.id is 'A1'
     16  filtering node B1
     17  filtering node B2
     18 PASS walker.nextNode(); walker.currentNode.id is 'B2'
     19 
     20 Testing with null filter
     21 PASS walker.firstChild(); walker.currentNode.id is 'A1'
     22 PASS walker.nextNode(); walker.currentNode.id is 'B1'
     23 
     24 Testing with undefined filter
     25 PASS walker.firstChild(); walker.currentNode.id is 'A1'
     26 PASS walker.nextNode(); walker.currentNode.id is 'B1'
     27 
     28 Testing with object lacking acceptNode property
     29 PASS walker.firstChild(); threw exception TypeError: NodeFilter object does not have an acceptNode function.
     30 PASS walker.currentNode.id; is 'root'
     31 PASS walker.nextNode(); threw exception TypeError: NodeFilter object does not have an acceptNode function.
     32 PASS walker.currentNode.id; is 'root'
     33 
     34 Testing with object with non-function acceptNode property
     35 PASS walker.firstChild(); threw exception TypeError: NodeFilter object does not have an acceptNode function.
     36 PASS walker.currentNode.id; is 'root'
     37 PASS walker.nextNode(); threw exception TypeError: NodeFilter object does not have an acceptNode function.
     38 PASS walker.currentNode.id; is 'root'
     39 
     40 Testing with function having acceptNode function
     41 PASS walker.firstChild(); walker.currentNode.id is 'A1'
     42 PASS walker.nextNode(); walker.currentNode.id is 'B1'
     43 
     44 Testing acceptNode callee
     45 Callee: function (node) {
     46     debug('Callee: ' + arguments.callee);
     47     return NodeFilter.FILTER_ACCEPT;
     48   }
     49 PASS walker.firstChild(); walker.currentNode.id is 'A1'
     50 PASS successfullyParsed is true
     51 
     52 TEST COMPLETE
     53 
     54