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);
let ostream = {
data: "",
write: function(buf, count) { this.data += buf; return count; }
};
serializer.serializeToStream(parser.parseFromString(t.input, t.type), ostream, "UTF-8");
is(ostream.data, t.expected, "serializeToStream test for " + t.type);
for (let charset of [null, "UTF-8"]) {
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") {
// 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"].
createInstance(Ci.nsIStringInputStream);
istream.setData(t.input, -1);
is(serializer.serializeToString(parser.parseFromStream(istream, null, array.length, t.type)),
t.expected, "parseFromStream test for " + t.type);
createInstance(Ci.nsIStringInputStream);
for (let charset of [null, "UTF-8"]) {
istream.setData(t.input, -1);
is(serializer.serializeToString(parser.parseFromStream(istream, charset, t.input.length, t.type)),
t.expected, "parseFromStream test for " + t.type + ", charset=" + charset);
}
}
throws(function() {
parser.parseFromString("<xml></xml>", "foo/bar");

View File

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

View File

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