summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/xpath/detached-subtree-invalidate-iterator.html
blob: 33673eb6f6564631ed394324a1706a9774137669 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<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>