Home | History | Annotate | Download | only in xpath
      1 <html>
      2 <head>
      3 <script>
      4     if (window.layoutTestController)
      5       layoutTestController.dumpAsText();
      6 
      7     var results = "";
      8     var result;
      9     var testNum = 1;
     10     function init() {
     11         var tests = [
     12             "id('nested1')",
     13             "id('nested1')/div[1]",
     14             "id('nested1')//div[1]",
     15             "id('nested1')/div[1]/input[2]",
     16             "id('nested1')/div[1]//input[2]",
     17             "id('nested1')//div[1]/input[2]",
     18             "id('nested1')//div[1]//input[2]"
     19         ];
     20         for (var i = 0; i < tests.length; i++) {
     21             runXPath(tests[i]);
     22         }
     23         document.getElementById('results').innerHTML = results;
     24     }
     25     
     26     function runXPath(xpath) {
     27         var result = document.evaluate(xpath, document, null, XPathResult.ANY_TYPE, null).iterateNext();
     28         results += xpath + " " + (result ? "PASSED" : "FAILED") + ": " + result + "<br />";
     29     }
     30 </script>
     31 </head>
     32 <body onload="init()">
     33 <p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=15380">bug 15380</a>:
     34 XPath: id('foo') doesn't resolve correctly.</p>
     35 <div id="nested1">
     36         <div id="nested2">
     37             <input id="nested3a" type="button" value="nested3a">
     38             <input id="nested3b" type="button" value="nested3b">
     39         </div>
     40     </div>
     41     <div id="results"></div>
     42 </body>
     43 </html>
     44