ported from UXP: [DOM] Clean up ReportLoadError and normalize error messages. (22830d18)

This commit is contained in:
2024-05-22 15:39:41 +08:00
parent a433921f87
commit e63613265e
+12 -16
View File
@@ -2242,10 +2242,10 @@ void ReportLoadError(ErrorResult& aRv, nsresult aLoadResult,
MOZ_ASSERT(!aRv.Failed());
switch (aLoadResult) {
case NS_ERROR_FILE_NOT_FOUND:
case NS_ERROR_NOT_AVAILABLE:
case NS_ERROR_CORRUPTED_CONTENT:
aLoadResult = NS_ERROR_DOM_NETWORK_ERR;
case NS_ERROR_DOM_SECURITY_ERR:
case NS_ERROR_DOM_SYNTAX_ERR:
case NS_ERROR_DOM_NETWORK_ERR:
// These are OK, pass them through immediately.
break;
case NS_ERROR_MALFORMED_URI:
@@ -2261,10 +2261,6 @@ void ReportLoadError(ErrorResult& aRv, nsresult aLoadResult,
// for this case, because that will make it impossible for consumers to
// realize that our error was NS_BINDING_ABORTED.
aRv.Throw(aLoadResult);
return;
case NS_ERROR_DOM_SECURITY_ERR:
case NS_ERROR_DOM_SYNTAX_ERR:
break;
case NS_ERROR_DOM_BAD_URI:
@@ -2272,15 +2268,15 @@ void ReportLoadError(ErrorResult& aRv, nsresult aLoadResult,
aLoadResult = NS_ERROR_DOM_SECURITY_ERR;
break;
case NS_ERROR_FILE_NOT_FOUND:
case NS_ERROR_NOT_AVAILABLE:
case NS_ERROR_CORRUPTED_CONTENT:
// For lack of anything better, go ahead and throw a NetworkError here.
// We don't want to throw a JS exception, because for toplevel script
// loads that would get squelched.
default:
// For lack of anything better, go ahead and throw a NetworkError here.
// We don't want to throw a JS exception, because for toplevel script
// loads that would get squelched.
aRv.ThrowDOMException(NS_ERROR_DOM_NETWORK_ERR,
nsPrintfCString("Failed to load worker script at %s (nsresult = 0x%x)",
NS_ConvertUTF16toUTF8(aScriptURL).get(),
aLoadResult));
return;
aLoadResult = NS_ERROR_DOM_NETWORK_ERR;
break;
}
aRv.ThrowDOMException(aLoadResult,