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> 11 var doc = document.implementation.createDocument(null, "doc", null); 12 var root = doc.createElement("div"); 13 root.appendChild(doc.createElement("span")); 14 root.appendChild(doc.createElement("p")); 15 16 var result = doc.evaluate(".//*", root, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); 17 shouldBe("result.invalidIteratorState", "false"); 18 shouldBe("result.iterateNext().tagName", "'span'"); 19 20 debug("Modifying the document..."); 21 doc.documentElement.setAttribute("foo", "bar"); 22 23 shouldBe("result.invalidIteratorState", "true"); 24 shouldThrow("result.iterateNext()"); 25 26 var successfullyParsed = true; 27 28 </script> 29 <script src="../js/resources/js-test-post.js"></script> 30 </body> 31 </html> 32