summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/xpath/name-null-namespace.html
blob: 562f70042a76ff0867bbbabc5953a5926f0d1a33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<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>