blob: 562f70042a76ff0867bbbabc5953a5926f0d1a33 [file] [log] [blame]
<p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=12340">bug 12340</a>:
XPath name() function doesn't work with nodes and attributes in null namespace.
</p>
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();
var strXML = '<doc><record/><record/><record/><record/><record foo="a-a"/></doc>';
var doc = (new DOMParser()).parseFromString(strXML, "text/xml");
// This matches in both Firefox and WebKit, which indicates that
// XPathEvaluator does not normalize the document.
doc.firstChild.childNodes[0].setAttributeNS("bar", "foo", "-a-");
// This doesn't match.
doc.firstChild.childNodes[1].setAttributeNS("bar", "b:foo", "-a-");
// These both match, too.
doc.firstChild.childNodes[2].setAttributeNS("", "foo", "-a-");
doc.firstChild.childNodes[3].setAttributeNS(null, "foo", "-a-");
// The last (static) record matches, of course.
var xpe = new XPathEvaluator();
var objResult = xpe.evaluate("//@*[name()='foo']", doc, null, 0, null);
var itm = null;
var objNodes = [];
while (itm = objResult.iterateNext())
objNodes.push(itm);
if (objNodes.length == 4)
document.write("SUCCESS");
else
document.write("FAILURE: matched " + objNodes.length + " nodes.");
</script>