Home | History | Annotate | Download | only in Borrowed
      1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
      2 <html>
      3 <body>
      4 <p>Tests that accessing XPath namespace axis doesn't cause a crash, see 
      5 <a href="bug http://bugs.webkit.org/show_bug.cgi?id=12724">bug 12724</a>.</p>
      6 <p>The actual results are incorrect, because XPath namespace nodes are not implemented yet.</p>
      7 
      8 <div id="console"></div>
      9 
     10 <script>
     11 SRC_1 = '<?xml version="1.0" encoding="utf-8"?>\
     12 <docu>\
     13 <elem xmlns:unused="urn:uuu000"/>\
     14 <elem xmlns="urn:sss111"/>\
     15 <y:elem xmlns:y="urn:yyyy222"/>\
     16 </docu>'
     17 
     18     if (window.layoutTestController)
     19         layoutTestController.dumpAsText();
     20 
     21     function shouldBe(actual, expected) {
     22         if (actual == expected)
     23             document.write("PASS: " + actual + " result nodes<br>");
     24         else
     25             document.write("FAILURE: " + actual + " result nodes (should be " + expected + ")<br>");
     26     }
     27 
     28     doc = (new DOMParser).parseFromString(SRC_1, "application/xml");
     29 
     30     EXPR = '//namespace::node()'
     31     nodeset = doc.evaluate(EXPR, doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
     32     shouldBe(nodeset.snapshotLength, 7)
     33 
     34     EXPR = '//node()/namespace::node()'
     35     nodeset = doc.evaluate(EXPR, doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
     36     shouldBe(nodeset.snapshotLength, 7)
     37 
     38     EXPR = '//*/namespace::node()'
     39     nodeset = doc.evaluate(EXPR, doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
     40     shouldBe(nodeset.snapshotLength, 7)
     41 
     42     EXPR = '/*/*/namespace::node()'
     43     nodeset = doc.evaluate(EXPR, doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
     44     shouldBe(nodeset.snapshotLength, 6)
     45 
     46     EXPR = '/*/namespace::node()|/*/*/namespace::node()'
     47     nodeset = doc.evaluate(EXPR, doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
     48     shouldBe(nodeset.snapshotLength, 7)
     49 
     50     EXPR = '//*'
     51     nodeset = doc.evaluate(EXPR, doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
     52     shouldBe(nodeset.snapshotLength, 4)
     53 
     54 </script>
     55 </body>
     56 </html>
     57