Home | History | Annotate | Download | only in xpath
      1 <html>
      2 <head>
      3 <link rel="stylesheet" href="../js/resources/js-test-style.css">
      4 <script src="../js/resources/js-test-pre.js"></script>
      5 </head>
      6 <body>
      7 <p id="sometext">
      8 <STRONG>strong</STRONG><strong>strong</strong><FOO>FOO</FOO><foo>foo</foo>
      9 </p>
     10 <div id="console"></div>
     11 <script type="text/javascript">
     12 
     13     function testHTML(query, expectedCount)
     14     {
     15         res = document.evaluate(query, document, function() { return "http://www.w3.org/1999/xhtml" }, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
     16         debug("HTML " + query);
     17         shouldBe('res.snapshotLength', expectedCount);
     18     }
     19 
     20     function testXML(query, expectedCount)
     21     {
     22         res = doc.evaluate(query, doc, function() { return "http://www.w3.org/1999/xhtml" }, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
     23         debug("XML " + query);
     24         shouldBe('res.snapshotLength', expectedCount);
     25     }
     26 
     27     testHTML('//*[@id="sometext"]//strong', '2');
     28     testHTML('//*[@id="sometext"]//Strong', '2');
     29     testHTML('//*[@id="Sometext"]//strong', '0');
     30     testHTML('//*[@id="sometext"]//foo', '2');
     31     testHTML('//*[@id="sometext"]//FOO', '2');
     32 
     33     var doc = (new DOMParser).parseFromString('<p id="sometext" xmlns="http://www.w3.org/1999/xhtml"><STRONG>strong</STRONG><strong>strong</strong><FOO xmlns="">FOO</FOO><foo xmlns="">foo</foo></p>', 'application/xhtml+xml');
     34 
     35     testXML('//*[@id="sometext"]//x:strong', '1');
     36     testXML('//*[@id="sometext"]//x:Strong', '0');
     37     testXML('//*[@id="Sometext"]//x:strong', '0');
     38     testXML('//*[@id="sometext"]//foo', '1');
     39     testXML('//*[@id="sometext"]//FOO', '1');
     40 
     41     var successfullyParsed = true;
     42 
     43 </script>
     44 <script src="../js/resources/js-test-post.js"></script>
     45 </body>
     46 </html>
     47