8 startDocument: function() {
9 evts.push("startDocument");
13 startElement: function startElement() {
14 evts.push("startElement");
19 processingInstruction: noop,
20 ignorableWhitespace: noop,
21 startPrefixMapping: noop,
22 endPrefixMapping: noop
25 function XMLDeclHandler(version, encoding, standalone) {
26 evts.splice(evts.length, 0, version, encoding, standalone);
29 const nsISAXXMLReader = Components.interfaces.nsISAXXMLReader;
30 var saxReader = Components.classes["@mozilla.org/saxparser/xmlreader;1"]
31 .createInstance(nsISAXXMLReader);
32 saxReader.contentHandler = contentHandler;
33 saxReader.declarationHandler = XMLDeclHandler;
36 saxReader.parseFromString("<root/>", "application/xml");
37 do_check_eq(evts.length, 2);
38 do_check_eq(evts[0], "startDocument");
39 do_check_eq(evts[1], "startElement");
42 saxReader.parseFromString("<?xml version='1.0'?><root/>", "application/xml");
43 do_check_eq(evts.length, 5);
44 do_check_eq(evts[0], "startDocument");
45 do_check_eq(evts[1], "1.0");
46 do_check_eq(evts[2], "");
47 do_check_false(evts[3]);
48 do_check_eq(evts[4], "startElement");
51 saxReader.parseFromString("<?xml version='1.0' encoding='UTF-8'?><root/>", "application/xml");
52 do_check_eq(evts.length, 5);
53 do_check_eq(evts[0], "startDocument");
54 do_check_eq(evts[1], "1.0");
55 do_check_eq(evts[2], "UTF-8");
56 do_check_false(evts[3]);
57 do_check_eq(evts[4], "startElement");
60 saxReader.parseFromString("<?xml version='1.0' standalone='yes'?><root/>", "application/xml");
61 do_check_eq(evts.length, 5);
62 do_check_eq(evts[0], "startDocument");
63 do_check_eq(evts[1], "1.0");
64 do_check_eq(evts[2], "");
65 do_check_true(evts[3]);
66 do_check_eq(evts[4], "startElement");
69 saxReader.parseFromString("<?xml version='1.0' encoding='UTF-8' standalone='yes'?><root/>", "application/xml");
70 do_check_eq(evts.length, 5);
71 do_check_eq(evts[0], "startDocument");
72 do_check_eq(evts[1], "1.0");
73 do_check_eq(evts[2], "UTF-8");
74 do_check_true(evts[3]);
75 do_check_eq(evts[4], "startElement");
79 saxReader.parseFromString("<?xml encoding='UTF-8'?><root/>", "application/xml");
80 do_check_eq(evts.length, 1);
81 do_check_eq(evts[0], "startDocument");