Bug 1539208 - Propagate the result of mListener in InterceptedHttpChannel::OnStartRequest and ::OnStopRequest r=perry,ttung,kershaw a=pascalc
authorEden Chuang <echuang@mozilla.com>
Wed, 24 Apr 2019 08:49:36 +0000
changeset 526461 224c70ce5efff2b014309e448dcc43a759e43441
parent 526460 7f749a11b5cf2fa0ffa9ed03084f9201d94f5d95
child 526462 11d3470f983ebc901d3fb15fb0cc779951f4221b
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersperry, ttung, kershaw, pascalc
bugs1539208
milestone67.0
Bug 1539208 - Propagate the result of mListener in InterceptedHttpChannel::OnStartRequest and ::OnStopRequest r=perry,ttung,kershaw a=pascalc 1. Propagate the mListener's result in InterceptedHttpChannel::OnStartRequest() and ::OnStopRequest(). 2. remove unnecessary assertion in FetchDriver::OnStartRequest(). Differential Revision: https://phabricator.services.mozilla.com/D28477
dom/fetch/FetchDriver.cpp
netwerk/protocol/http/InterceptedHttpChannel.cpp
--- a/dom/fetch/FetchDriver.cpp
+++ b/dom/fetch/FetchDriver.cpp
@@ -1042,17 +1042,19 @@ FetchDriver::OnStartRequest(nsIRequest* 
   // interception case.
   mRequest->MaybeIncreaseResponseTainting(loadInfo->GetTainting());
 
   // Resolves fetch() promise which may trigger code running in a worker.  Make
   // sure the Response is fully initialized before calling this.
   mResponse = BeginAndGetFilteredResponse(response, foundOpaqueRedirect);
   if (NS_WARN_IF(!mResponse)) {
     // Fail to generate a paddingInfo for opaque response.
-    MOZ_DIAGNOSTIC_ASSERT(mResponse->Type() == ResponseType::Opaque);
+    MOZ_DIAGNOSTIC_ASSERT(mRequest->GetResponseTainting() ==
+                              LoadTainting::Opaque &&
+                          !foundOpaqueRedirect);
     FailWithNetworkError(NS_ERROR_UNEXPECTED);
     return NS_ERROR_UNEXPECTED;
   }
 
   // From "Main Fetch" step 19: SRI-part1.
   if (ShouldCheckSRI(mRequest, mResponse) && mSRIMetadata.IsEmpty()) {
     nsIConsoleReportCollector* reporter = nullptr;
     if (mObserver) {
--- a/netwerk/protocol/http/InterceptedHttpChannel.cpp
+++ b/netwerk/protocol/http/InterceptedHttpChannel.cpp
@@ -1015,17 +1015,17 @@ InterceptedHttpChannel::OnStartRequest(n
     GetCallback(mProgressSink);
   }
 
   if (mPump && mLoadFlags & LOAD_CALL_CONTENT_SNIFFERS) {
     mPump->PeekStream(CallTypeSniffers, static_cast<nsIChannel*>(this));
   }
 
   if (mListener) {
-    mListener->OnStartRequest(this);
+    return mListener->OnStartRequest(this);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 InterceptedHttpChannel::OnStopRequest(nsIRequest* aRequest, nsresult aStatus) {
   MOZ_ASSERT(NS_IsMainThread());
 
@@ -1041,25 +1041,26 @@ InterceptedHttpChannel::OnStopRequest(ns
   // to the ReleaseListeners() call below.
   MaybeCallStatusAndProgress();
 
   mIsPending = false;
 
   // Register entry to the PerformanceStorage resource timing
   MaybeReportTimingData();
 
+  nsresult rv = NS_OK;
   if (mListener) {
-    mListener->OnStopRequest(this, mStatus);
+    rv = mListener->OnStopRequest(this, mStatus);
   }
 
   gHttpHandler->OnStopRequest(this);
 
   ReleaseListeners();
 
-  return NS_OK;
+  return rv;
 }
 
 NS_IMETHODIMP
 InterceptedHttpChannel::OnDataAvailable(nsIRequest* aRequest,
                                         nsIInputStream* aInputStream,
                                         uint64_t aOffset, uint32_t aCount) {
   // Any thread if the channel has been retargeted.