3 <script src=
"../../resources/js-test.js"></script>
4 <script src=
"xpath-test-pre.js"></script>
7 <p>Test that iterators are invalidated even if the original context is detached.
</p>
8 <div id=
"console"></div>
10 var doc
= document
.implementation
.createDocument(null, "doc", null);
11 var root
= doc
.createElement("div");
12 root
.appendChild(doc
.createElement("span"));
13 root
.appendChild(doc
.createElement("p"));
15 var result
= doc
.evaluate(".//*", root
, null, XPathResult
.ORDERED_NODE_ITERATOR_TYPE
, null);
16 shouldBe("result.invalidIteratorState", "false");
17 shouldBe("result.iterateNext().tagName", "'span'");
19 debug("Modifying the document...");
20 doc
.documentElement
.setAttribute("foo", "bar");
22 shouldBe("result.invalidIteratorState", "true");
23 shouldThrow("result.iterateNext()");