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