Home | History | Annotate | Download | only in xpath
      1 <p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=12340">bug 12340</a>:
      2 XPath name() function doesn't work with nodes and attributes in null namespace.
      3 </p>
      4 <script>
      5 if (window.layoutTestController)
      6   layoutTestController.dumpAsText();
      7 
      8 var strXML = '<doc><record/><record/><record/><record/><record foo="a-a"/></doc>';
      9 var doc = (new DOMParser()).parseFromString(strXML, "text/xml");
     10 
     11 // This matches in both Firefox and WebKit, which indicates that 
     12 // XPathEvaluator does not normalize the document.
     13 doc.firstChild.childNodes[0].setAttributeNS("bar", "foo", "-a-");
     14 
     15 // This doesn't match.
     16 doc.firstChild.childNodes[1].setAttributeNS("bar", "b:foo", "-a-");
     17 
     18 // These both match, too.
     19 doc.firstChild.childNodes[2].setAttributeNS("", "foo", "-a-");
     20 doc.firstChild.childNodes[3].setAttributeNS(null, "foo", "-a-");
     21 
     22 // The last (static) record matches, of course.
     23 
     24 
     25 var xpe = new XPathEvaluator();
     26 var objResult = xpe.evaluate("//@*[name()='foo']", doc, null, 0, null);
     27 var itm = null;
     28 var objNodes = [];
     29 while (itm = objResult.iterateNext())
     30   objNodes.push(itm);
     31 
     32 if (objNodes.length == 4)
     33   document.write("SUCCESS");
     34 else
     35   document.write("FAILURE: matched " + objNodes.length + " nodes.");
     36 </script>
     37