| <?xml version="1.0" encoding="utf-8"?> |
| <!DOCTYPE html> |
| <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> |
| <head> |
| <title>XPath preceding axis misses nested elements</title> |
| <style>div#msg { white-space: pre; }</style> |
| <script> |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| |
| window.addEventListener("load", function() { |
| var msg = document.getElementById("msg"); |
| function print(s) { msg.textContent += s; } |
| function id(el) { return el.tagName + (el.id ? "#" + el.id : ""); } |
| function query(el, xpath, expected) { |
| print("Query \"" + xpath + "\" from " + id(el) + "\n"); |
| var res = document.evaluate(xpath, |
| el, |
| function() { return "http://www.w3.org/1999/xhtml"; }, |
| XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, |
| null); |
| |
| var resstr = ""; |
| for (var i = 0; i < res.snapshotLength; i++) { |
| var el = res.snapshotItem(i); |
| resstr += " " + id(el); |
| } |
| print("Result:" + resstr + "\n"); |
| print("Expected: " + expected + "\n"); |
| if (resstr != (" " + expected)) { |
| print("***FAIL***\n"); |
| } else { |
| print("***SUCCESS***\n"); |
| } |
| print("\n"); |
| } |
| |
| print("Querying in the following...\n\n"); |
| print(document.getElementById("test").outerHTML + "\n\n"); |
| |
| query(document.getElementById("D"), "preceding::xhtml:span", "span#A span#B span#C"); |
| }, false); |
| </script> |
| </head> |
| <body> |
| <div id="test"> |
| <span id="A"/> |
| <div> |
| <span id="B"> |
| <span id="C"/> |
| </span> |
| </div> |
| <span id="D"/> |
| </div> |
| <div id="msg"/> |
| </body> |
| </html> |