blob: a3d9559889ef8a734911085c65415923d8b7b35d [file] [log] [blame]
<html>
<head>
<script src="../../resources/js-test.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()");
</script>
</body>
</html>