diff --git a/toolkit/components/extensions/test/xpcshell/test_locale_converter.js b/toolkit/components/extensions/test/xpcshell/test_locale_converter.js index e296a66127ba..c8b1ee92bab7 100644 --- a/toolkit/components/extensions/test/xpcshell/test_locale_converter.js +++ b/toolkit/components/extensions/test/xpcshell/test_locale_converter.js @@ -123,3 +123,11 @@ add_task(function* testInvalidUUID() { convService.asyncConvertData(FROM_TYPE, TO_TYPE, listener, uri); }, expectInvalidContextException); }); + + +// Test that an empty stream does not throw an NS_ERROR_ILLEGAL_VALUE. +add_task(function* testEmptyStream() { + let stream = StringStream(""); + let resultStream = convService.convert(stream, FROM_TYPE, TO_TYPE, URI); + equal(resultStream.data, ""); +}); diff --git a/toolkit/components/utils/simpleServices.js b/toolkit/components/utils/simpleServices.js index a3befe188938..b58c4d4962c1 100644 --- a/toolkit/components/utils/simpleServices.js +++ b/toolkit/components/utils/simpleServices.js @@ -225,7 +225,10 @@ AddonLocalizationConverter.prototype = { this.checkTypes(aFromType, aToType); let addonId = this.getAddonId(aContext); - let string = NetUtil.readInputStreamToString(aStream, aStream.available()); + let string = ( + aStream.available() ? + NetUtil.readInputStreamToString(aStream, aStream.available()): "" + ); return this.convertToStream(addonId, string); },