Bug 1724718 - put missing chrome/resource check from jar channels in a better place so we catch all cases, r=valentin,florian,necko-reviewers

This also re-adds the TYPE_FETCH content policy for file existence checks
from tests so they don't cause crashes.

Differential Revision: https://phabricator.services.mozilla.com/D122167
This commit is contained in:
Gijs Kruitbosch 2023-01-16 14:46:14 +00:00
parent 46a72deb4e
commit b408d18300
3 changed files with 20 additions and 3 deletions

View File

@ -50,6 +50,9 @@ var PerfTestHelpers = {
let channel = lazy.NetUtil.newChannel({
uri,
loadUsingSystemPrincipal: true,
// Avoid crashing for non-existant files. If the file not existing
// is bad, we can deal with it in the test instead.
contentPolicyType: Ci.nsIContentPolicy.TYPE_FETCH,
});
channel.asyncOpen({

View File

@ -286,9 +286,6 @@ nsresult nsJARChannel::CreateJarInput(nsIZipReaderCache* jarCache,
new nsJARInputThunk(reader, mJarURI, mJarEntry, jarCache != nullptr);
rv = input->Init();
if (NS_FAILED(rv)) {
if (rv == NS_ERROR_FILE_NOT_FOUND) {
CheckForBrokenChromeURL(mLoadInfo, mOriginalURI);
}
return rv;
}
@ -488,6 +485,9 @@ nsresult nsJARChannel::OnOpenLocalFileComplete(nsresult aResult,
MOZ_ASSERT(mIsPending);
if (NS_FAILED(aResult)) {
if (aResult == NS_ERROR_FILE_NOT_FOUND) {
CheckForBrokenChromeURL(mLoadInfo, mOriginalURI);
}
if (!aIsSyncCall) {
NotifyError(aResult);
}

View File

@ -3864,6 +3864,20 @@ void CheckForBrokenChromeURL(nsILoadInfo* aLoadInfo, nsIURI* aURI) {
nsCString spec;
aURI->GetSpec(spec);
#ifdef ANDROID
// Various toolkit files use this and are shipped on android, but
// info-pages.css and aboutLicense.css are not - bug 1808987
if (StringEndsWith(spec, "info-pages.css"_ns) ||
StringEndsWith(spec, "aboutLicense.css"_ns) ||
// Error page CSS is also missing: bug 1810039
StringEndsWith(spec, "aboutNetError.css"_ns) ||
StringEndsWith(spec, "error-pages.css"_ns) ||
// Used by an extension installation test - bug 1809650
StringBeginsWith(spec, "resource://android/assets/web_extensions/"_ns)) {
return;
}
#endif
// DTD files from gre may not exist when requested by tests.
if (StringBeginsWith(spec, "resource://gre/res/dtd/"_ns)) {
return;