Commit 2371be8d authored by Nika Layzell's avatar Nika Layzell Committed by morgan
Browse files

Bug 1875248 - Check for network error preventing ExternalHelperAppService...

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
parent 0acdfa47
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -414,26 +414,26 @@ 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: