Bug 696603: Handle null being passed to BlobBuilder.append. r=sicking

This commit is contained in:
Kyle Huey 2011-10-24 09:38:41 -04:00
parent 2b72a53735
commit fcb45b0c7d
2 changed files with 7 additions and 1 deletions

View File

@ -372,7 +372,10 @@ nsDOMBlobBuilder::Append(const jsval& aData, JSContext* aCx)
// Is it an object?
if (JSVAL_IS_OBJECT(aData)) {
JSObject* obj = JSVAL_TO_OBJECT(aData);
NS_ASSERTION(obj, "Er, what?");
if (!obj) {
// We got passed null. Just do nothing.
return NS_OK;
}
// Is it a Blob?
nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(

View File

@ -37,6 +37,9 @@ ok(false, "NOT REACHED");
ok(true, "an empty argument to append should throw");
}
blobBuilder.append(null);
// Yay we didn't crash.
blobBuilder.append("squiggle");
let blob1 = blobBuilder.getBlob();
ok(blob1 instanceof Blob, "getBlob should produce Blobs");