5 <title>Test for the DOM Parsing and Serialization Standard
</title>
6 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
10 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=816410">Mozilla Bug
816410</a>
12 <div id=
"content" style=
"display: none">
16 <script type=
"application/javascript">
18 /** Test for Bug
816410 **/
20 function throws(fn, type, message) {
26 is(e.name, type, message);
33 let parser = new DOMParser();
34 is(typeof parser.parseFromString,
"function",
"parseFromString should exist");
35 is(typeof parser.parseFromBuffer,
"undefined",
"parseFromBuffer should NOT be visible from unprivileged callers");
36 is(typeof parser.parseFromStream,
"undefined",
"parseFromStream should NOT be visible from unprivileged callers");
37 is(typeof parser.init,
"undefined",
"init should NOT be visible from unprivileged callers");
39 // The three-arguments constructor should not be visible from
40 // unprivileged callers for interoperability with other browsers.
41 // But we have no way to do that right now.
43 new DOMParser(undefined);
50 todo(false,
"DOMParser constructor should not throw for extra arguments");
53 let serializer = new XMLSerializer();
54 is(typeof serializer.serializeToString,
"function",
"serializeToString should exist");
55 is(typeof serializer.serializeToStream,
"undefined",
"serializeToStream should NOT be visible from unprivileged callers");
57 // XMLSerializer constructor should not throw for extra arguments
58 new XMLSerializer(undefined);
59 new XMLSerializer(null);
60 new XMLSerializer(false);
62 new XMLSerializer(
"");
63 new XMLSerializer({});
66 {input:
"<html></html>", type:
"text/html",
67 expected: '
<html xmlns=
"http://www.w3.org/1999/xhtml"><head></head><body></body></html>'},
68 {input:
"<xml></xml>", type:
"text/xml", expected:
"<xml/>"},
69 {input:
"<xml></xml>", type:
"application/xml", expected:
"<xml/>"},
70 {input:
"<html></html>", type:
"application/xhtml+xml", expected:
"<html/>"},
71 {input:
"<svg></svg>", type:
"image/svg+xml", expected:
"<svg/>"},
73 for (let t of tests) {
74 is(serializer.serializeToString(parser.parseFromString(t.input, t.type)), t.expected,
75 "parseFromString test for " + t.type);
79 parser.parseFromString(
"<xml></xml>",
"foo/bar");
80 },
"TypeError",
"parseFromString should throw for the unknown type");