Line 0
Link Here
|
|
|
1 |
<?xml version="1.0" encoding="utf-8"?> |
2 |
<!DOCTYPE html> |
3 |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> |
4 |
<head> |
5 |
<title>XPath preceding axis misses nested elements</title> |
6 |
<style>div#msg { white-space: pre; }</style> |
7 |
<script> |
8 |
if (window.layoutTestController) |
9 |
layoutTestController.dumpAsText(); |
10 |
|
11 |
window.addEventListener("load", function() { |
12 |
var msg = document.getElementById("msg"); |
13 |
function print(s) { msg.textContent += s; } |
14 |
function id(el) { return el.tagName + (el.id ? "#" + el.id : ""); } |
15 |
function query(el, xpath, expected) { |
16 |
print("Query \"" + xpath + "\" from " + id(el) + "\n"); |
17 |
var res = document.evaluate(xpath, |
18 |
el, |
19 |
function() { return "http://www.w3.org/1999/xhtml"; }, |
20 |
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, |
21 |
null); |
22 |
|
23 |
var resstr = ""; |
24 |
for (var i = 0; i < res.snapshotLength; i++) { |
25 |
var el = res.snapshotItem(i); |
26 |
resstr += " " + id(el); |
27 |
} |
28 |
print("Result:" + resstr + "\n"); |
29 |
print("Expected: " + expected + "\n"); |
30 |
if (resstr != (" " + expected)) { |
31 |
print("***FAIL***\n"); |
32 |
} else { |
33 |
print("***SUCCESS***\n"); |
34 |
} |
35 |
print("\n"); |
36 |
} |
37 |
|
38 |
print("Querying in the following...\n\n"); |
39 |
print(document.getElementById("test").outerHTML + "\n\n"); |
40 |
|
41 |
query(document.getElementById("D"), "preceding::xhtml:span", "span#A span#B span#C"); |
42 |
}, false); |
43 |
</script> |
44 |
</head> |
45 |
<body> |
46 |
<div id="test"> |
47 |
<span id="A"/> |
48 |
<div> |
49 |
<span id="B"> |
50 |
<span id="C"/> |
51 |
</span> |
52 |
</div> |
53 |
<span id="D"/> |
54 |
</div> |
55 |
<div id="msg"/> |
56 |
</body> |
57 |
</html> |
0 |
+ text/xml |
58 |
+ text/xml |