Bug 1875248 - Check for network error preventing ExternalHelperAppService before DONT_RETARGET, r=smaug

This reverts the change from 30cde47f9364e5c7da78fd08fa8ab21737d22399,
and instead re-orders the NS_ERROR_FILE_NOT_FOUND check before
DONT_RETARGET.

Testing suggests that a-download-click-404.html behaviour isn't
impacted, and this improves the handling of this edge-case when doing
process switching.

Differential Revision: https://phabricator.services.mozilla.com/D202007
This commit is contained in:
Nika Layzell 2024-03-22 20:11:35 +00:00
Родитель 2360123230
Коммит cf0bdb2667
1 изменённых файлов: 11 добавлений и 11 удалений

Просмотреть файл

@ -435,28 +435,28 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest* request) {
NS_ASSERTION(!m_targetStreamListener,
"If we found a listener, why are we not using it?");
if (mFlags & nsIURILoader::DONT_RETARGET) {
LOG(
(" External handling forced or (listener not interested and no "
"stream converter exists), and retargeting disallowed -> aborting"));
return NS_ERROR_WONT_HANDLE_CONTENT;
}
// Before dispatching to the external helper app service, check for an HTTP
// error page. If we got one, we don't want to handle it with a helper app,
// really.
// The WPT a-download-click-404.html requires us to silently handle this
// without displaying an error page, so we just return early here.
// See bug 1604308 for discussion around what the ideal behaviour is.
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(request));
if (httpChannel) {
bool requestSucceeded;
rv = httpChannel->GetRequestSucceeded(&requestSucceeded);
if (NS_FAILED(rv) || !requestSucceeded) {
return NS_OK;
LOG(
(" Returning NS_ERROR_FILE_NOT_FOUND from "
"nsDocumentOpenInfo::DispatchContent due to failed HTTP response"));
return NS_ERROR_FILE_NOT_FOUND;
}
}
if (mFlags & nsIURILoader::DONT_RETARGET) {
LOG(
(" External handling forced or (listener not interested and no "
"stream converter exists), and retargeting disallowed -> aborting"));
return NS_ERROR_WONT_HANDLE_CONTENT;
}
// Fifth step:
//
// All attempts to dispatch this content have failed. Just pass it off to