<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>