1<html> 2<head> 3<link rel="stylesheet" href="../js/resources/js-test-style.css"> 4<script src="../js/resources/js-test-pre.js"></script> 5<script src="xpath-test-pre.js"></script> 6</head> 7<body> 8<p>Test that iterators are invalidated even if the original context is detached.</p> 9<div id="console"></div> 10<script> 11var doc = document.implementation.createDocument(null, "doc", null); 12var root = doc.createElement("div"); 13root.appendChild(doc.createElement("span")); 14root.appendChild(doc.createElement("p")); 15 16var result = doc.evaluate(".//*", root, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); 17shouldBe("result.invalidIteratorState", "false"); 18shouldBe("result.iterateNext().tagName", "'span'"); 19 20debug("Modifying the document..."); 21doc.documentElement.setAttribute("foo", "bar"); 22 23shouldBe("result.invalidIteratorState", "true"); 24shouldThrow("result.iterateNext()"); 25 26var successfullyParsed = true; 27 28</script> 29<script src="../js/resources/js-test-post.js"></script> 30</body> 31</html> 32