Adding test for bug 361933

This commit is contained in:
bzbarsky%mit.edu 2006-11-30 06:39:47 +00:00
parent 1b93ffb172
commit 744c1ea6a7
2 changed files with 47 additions and 0 deletions

View File

@ -167,3 +167,21 @@ function do_check_serialize(dom) {
do_check_equiv(dom, roundtrip(dom)); do_check_equiv(dom, roundtrip(dom));
} }
function Pipe() {
var p = C["@mozilla.org/pipe;1"].createInstance(I.nsIPipe);
p.init(false, false, 0, 0xffffffff, null);
return p;
}
function ScriptableInput(arg) {
if (arg instanceof I.nsIPipe) {
arg = arg.inputStream;
}
var str = C["@mozilla.org/scriptableinputstream;1"].
createInstance(I.nsIScriptableInputStream);
str.init(arg);
return str;
}

View File

@ -12,6 +12,7 @@ var tests = [
test5, test5,
test6, test6,
test7, test7,
test8,
null null
]; ];
@ -259,3 +260,31 @@ function test7() {
'<root xmlns="http://www.w3.org/1999/xhtml"><child1 xmlns="">' + '<root xmlns="http://www.w3.org/1999/xhtml"><child1 xmlns="">' +
'<a0:child2 xmlns:a0="http://www.w3.org/1999/xhtml" xmlns=""/></child1></root>'); '<a0:child2 xmlns:a0="http://www.w3.org/1999/xhtml" xmlns=""/></child1></root>');
} }
function test8() {
// Test behavior of serializing with a given charset.
var str1 = '<?xml version="1.0" encoding="ISO-8859-1"?>\n<root/>';
var str2 = '<?xml version="1.0" encoding="UTF8"?>\n<root/>';
var doc1 = ParseXML(str1);
var doc2 = ParseXML(str2);
var p = Pipe();
DOMSerializer().serializeToStream(doc1, p.outputStream, "ISO-8859-1");
p.outputStream.close();
do_check_eq(ScriptableInput(p).read(-1), str1);
p = Pipe();
DOMSerializer().serializeToStream(doc2, p.outputStream, "ISO-8859-1");
p.outputStream.close();
do_check_eq(ScriptableInput(p).read(-1), str1);
p = Pipe();
DOMSerializer().serializeToStream(doc1, p.outputStream, "UTF8");
p.outputStream.close();
do_check_eq(ScriptableInput(p).read(-1), str2);
p = Pipe();
DOMSerializer().serializeToStream(doc2, p.outputStream, "UTF8");
p.outputStream.close();
do_check_eq(ScriptableInput(p).read(-1), str2);
}