Rubber-stamped by Brady Eidson.
[webbrowser.git] / LayoutTests / fast / xpath / name-null-namespace.html
blob562f70042a76ff0867bbbabc5953a5926f0d1a33
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();
8 var strXML = '<doc><record/><record/><record/><record/><record foo="a-a"/></doc>';
9 var doc = (new DOMParser()).parseFromString(strXML, "text/xml");
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-");
15 // This doesn't match.
16 doc.firstChild.childNodes[1].setAttributeNS("bar", "b:foo", "-a-");
18 // These both match, too.
19 doc.firstChild.childNodes[2].setAttributeNS("", "foo", "-a-");
20 doc.firstChild.childNodes[3].setAttributeNS(null, "foo", "-a-");
22 // The last (static) record matches, of course.
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);
32 if (objNodes.length == 4)
33 document.write("SUCCESS");
34 else
35 document.write("FAILURE: matched " + objNodes.length + " nodes.");
36 </script>