blob: 219f8b895c06c2f73f7df5433c6d29de9ca40acd [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="xpath-test-pre.js"></script>
</head>
<body>
<p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=15436">bug 15436</a>:
Wrong proximity positions for XPath reverse axes.</p>
<div id="d">
<div id="d1"></div>
<div id="d2">
<div id="d21"></div>
</div>
<div id="d3">
<div id="d31"></div>
</div>
</div>
<div id="console"></div>
<script>
shouldBe("document.evaluate('preceding-sibling::*[1]', document.getElementById('d3'), null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue.id", "'d2'");
shouldBe("document.evaluate('preceding::*[1]', document.getElementById('d31'), null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue.id", "'d21'");
shouldBe("document.evaluate('preceding::*[2]', document.getElementById('d31'), null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue.id", "'d2'");
shouldBe("document.evaluate('preceding::*[3]', document.getElementById('d31'), null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue.id", "'d1'");
shouldBe("document.evaluate('preceding::*[4]', document.getElementById('d31'), null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue.tagName", "'A'");
shouldBe("document.evaluate('preceding::*[5]', document.getElementById('d31'), null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue.tagName", "'P'");
shouldBe("document.evaluate('ancestor::*[1]', document.getElementById('d31'), null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue.id", "'d3'");
shouldBe("document.evaluate('ancestor-or-self::*[1]', document.getElementById('d31'), null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue.id", "'d31'");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>