1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
7 <div id=
"console"></div>
10 doc
= (new DOMParser
).parseFromString(
11 '<?xml version="1.0" encoding="ISO-8859-1"?>' +
13 '<?xml-stylesheet "Data" ?>' +
14 '<!' + '-- comment -->' +
15 '<doc attr="<&nbsp;>">0 <elem>1</elem><!' + '-- comment -->a<![CDATA[-cdata-]]>b<elem>2</elem><empty></empty></doc>',
19 while (PI
.nodeType
!= Node
.PROCESSING_INSTRUCTION_NODE
)
22 COMMENT
= doc
.firstChild
;
23 while (COMMENT
.nodeType
!= Node
.COMMENT_NODE
)
24 COMMENT
= COMMENT
.nextSibling
;
26 ATTR
= doc
.documentElement
.getAttributeNode("attr");
28 CDATA
= doc
.documentElement
.firstChild
;
29 while (CDATA
.nodeType
!= Node
.CDATA_SECTION_NODE
)
30 CDATA
= CDATA
.nextSibling
;
32 TEXT
= doc
.documentElement
.firstChild
;
34 EMPTY
= doc
.documentElement
.lastChild
;
36 shouldBe("doc.evaluate('.', doc, null, XPathResult.STRING_TYPE, null).stringValue", "'0 1a-cdata-b2'");
37 shouldBe("doc.evaluate('.', doc.documentElement, null, XPathResult.STRING_TYPE, null).stringValue", "'0 1a-cdata-b2'");
38 shouldBe("doc.evaluate('.', PI, null, XPathResult.STRING_TYPE, null).stringValue", "'\"Data\" '");
39 shouldBe("doc.evaluate('.', COMMENT, null, XPathResult.STRING_TYPE, null).stringValue", "' comment '");
40 shouldBe("doc.evaluate('.', CDATA, null, XPathResult.STRING_TYPE, null).stringValue", "'-cdata-'");
41 shouldBe("doc.evaluate('.', TEXT, null, XPathResult.STRING_TYPE, null).stringValue", "'0 '");
42 shouldBe("doc.evaluate('.', EMPTY, null, XPathResult.STRING_TYPE, null).stringValue", "''");
43 shouldBe("doc.evaluate('.', ATTR, null, XPathResult.STRING_TYPE, null).stringValue", "'< >'");