Bug 817844 - Fix WebIDL signature of serializeToStream/parseFromStream. r=bz

This commit is contained in:
Masatoshi Kimura 2012-12-05 19:49:32 -05:00
parent 63b95d95ed
commit 9e9d0a9573
3 changed files with 14 additions and 9 deletions

View File

@ -98,11 +98,14 @@ function runTest(parser, serializer) {
"parseFromString test for " + t.type); "parseFromString test for " + t.type);
let ostream = { let ostream = {
data: "",
write: function(buf, count) { this.data += buf; return count; } write: function(buf, count) { this.data += buf; return count; }
}; };
serializer.serializeToStream(parser.parseFromString(t.input, t.type), ostream, "UTF-8"); for (let charset of [null, "UTF-8"]) {
is(ostream.data, t.expected, "serializeToStream test for " + t.type); ostream.data = "";
serializer.serializeToStream(parser.parseFromString(t.input, t.type), ostream, charset);
is(ostream.data, t.expected,
"serializeToStream test for " + t.type + ", charset=" + charset);
}
if (t.type === "text/html") { if (t.type === "text/html") {
// parseFromBuffer and parseFromStream don't support "text/html". // parseFromBuffer and parseFromStream don't support "text/html".
@ -126,10 +129,12 @@ function runTest(parser, serializer) {
} }
let istream = Cc["@mozilla.org/io/string-input-stream;1"]. let istream = Cc["@mozilla.org/io/string-input-stream;1"].
createInstance(Ci.nsIStringInputStream); createInstance(Ci.nsIStringInputStream);
istream.setData(t.input, -1); for (let charset of [null, "UTF-8"]) {
is(serializer.serializeToString(parser.parseFromStream(istream, null, array.length, t.type)), istream.setData(t.input, -1);
t.expected, "parseFromStream test for " + t.type); is(serializer.serializeToString(parser.parseFromStream(istream, charset, t.input.length, t.type)),
t.expected, "parseFromStream test for " + t.type + ", charset=" + charset);
}
} }
throws(function() { throws(function() {
parser.parseFromString("<xml></xml>", "foo/bar"); parser.parseFromString("<xml></xml>", "foo/bar");

View File

@ -36,7 +36,7 @@ interface DOMParser {
Document parseFromBuffer(Uint8Array buf, unsigned long bufLen, Document parseFromBuffer(Uint8Array buf, unsigned long bufLen,
SupportedType type); SupportedType type);
[Creator, Throws, ChromeOnly] [Creator, Throws, ChromeOnly]
Document parseFromStream(InputStream stream, DOMString charset, Document parseFromStream(InputStream stream, DOMString? charset,
long contentLength, SupportedType type); long contentLength, SupportedType type);
[Throws, ChromeOnly] [Throws, ChromeOnly]
void init(optional Principal? principal = null, void init(optional Principal? principal = null,

View File

@ -15,6 +15,6 @@ interface XMLSerializer {
// Mozilla-specific stuff // Mozilla-specific stuff
[Throws, ChromeOnly] [Throws, ChromeOnly]
void serializeToStream(Node root, OutputStream stream, DOMString charset); void serializeToStream(Node root, OutputStream stream, DOMString? charset);
}; };