summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/xpath/detached-subtree-invalidate-iterator.html
diff options
context:
space:
mode:
Diffstat (limited to 'LayoutTests/fast/xpath/detached-subtree-invalidate-iterator.html')
-rw-r--r--LayoutTests/fast/xpath/detached-subtree-invalidate-iterator.html31
1 files changed, 31 insertions, 0 deletions
diff --git a/LayoutTests/fast/xpath/detached-subtree-invalidate-iterator.html b/LayoutTests/fast/xpath/detached-subtree-invalidate-iterator.html
new file mode 100644
index 0000000..33673eb
--- /dev/null
+++ b/LayoutTests/fast/xpath/detached-subtree-invalidate-iterator.html
@@ -0,0 +1,31 @@
+<html>
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+<script src="xpath-test-pre.js"></script>
+</head>
+<body>
+<p>Test that iterators are invalidated even if the original context is detached.</p>
+<div id="console"></div>
+<script>
+var doc = document.implementation.createDocument(null, "doc", null);
+var root = doc.createElement("div");
+root.appendChild(doc.createElement("span"));
+root.appendChild(doc.createElement("p"));
+
+var result = doc.evaluate(".//*", root, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
+shouldBe("result.invalidIteratorState", "false");
+shouldBe("result.iterateNext().tagName", "'span'");
+
+debug("Modifying the document...");
+doc.documentElement.setAttribute("foo", "bar");
+
+shouldBe("result.invalidIteratorState", "true");
+shouldThrow("result.iterateNext()");
+
+var successfullyParsed = true;
+
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>