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