Reinstate active flag for iterators
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / dom / traversal / TreeWalker.html
index e0e285a779db3a12b2919e67afd04a10522686fa..2570c9a200682ff3844d116308da13c4bdbe5fff 100644 (file)
 
 // TODO .previousNode, .nextNode
 
+test(function() {
+  var depth = 0;
+  var walker = document.createTreeWalker(document, NodeFilter.SHOW_ALL,
+    function() {
+      if (depth == 0) {
+        depth++;
+        walker.firstChild();
+      }
+      return NodeFilter.FILTER_ACCEPT;
+    });
+  walker.currentNode = document.body;
+  assert_throws("InvalidStateError", function() { walker.parentNode() });
+  depth--;
+  assert_throws("InvalidStateError", function() { walker.firstChild() });
+  depth--;
+  assert_throws("InvalidStateError", function() { walker.lastChild() });
+  depth--;
+  assert_throws("InvalidStateError", function() { walker.previousSibling() });
+  depth--;
+  assert_throws("InvalidStateError", function() { walker.nextSibling() });
+  depth--;
+  assert_throws("InvalidStateError", function() { walker.previousNode() });
+  depth--;
+  assert_throws("InvalidStateError", function() { walker.nextNode() });
+}, "Recursive filters need to throw");
+
 function filterNode(node, whatToShow, filter) {
     // "If active flag is set throw an "InvalidStateError"."
     // Ignore active flag for these tests, we aren't calling recursively