Reinstate active flag for iterators
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / dom / traversal / NodeIterator.html
index d883f436218c2124ff3c144056f217152e1f70b8..677858d2a51c03de1f120a97679740e00fdb6af5 100644 (file)
@@ -3,8 +3,8 @@
 <link rel="author" title="Aryeh Gregor" href=ayg@aryeh.name>
 <meta name=timeout content=long>
 <div id=log></div>
-<script src=../../../../../resources/testharness.js></script>
-<script src=../../../../../resources/testharnessreport.js></script>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
 <script src=../common.js></script>
 <script>
 "use strict";
@@ -52,6 +52,23 @@ test(function() {
   assert_throws({name: "failed"}, function() { iter.nextNode() });
 }, "Propagate exception from filter function");
 
+test(function() {
+  var depth = 0;
+  var iter = document.createNodeIterator(document, NodeFilter.SHOW_ALL,
+    function() {
+      if (iter.referenceNode != document && depth == 0) {
+        depth++;
+        iter.nextNode();
+      }
+      return NodeFilter.FILTER_ACCEPT;
+    });
+  iter.nextNode();
+  iter.nextNode();
+  assert_throws("InvalidStateError", function() { iter.nextNode() });
+  depth--;
+  assert_throws("InvalidStateError", function() { iter.previousNode() });
+}, "Recursive filters need to throw");
+
 function testIterator(root, whatToShow, filter) {
   var iter = document.createNodeIterator(root, whatToShow, filter);