Bug 1583076 - Pass LoadInfo back for the current channel when confirming redirects. r=ckerschb
☠☠ backed out by abe671277b51 ☠ ☠
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 25 Sep 2019 04:50:58 +0000
changeset 494872 97e4bfbc5578f4ea5d7a1751c039260a7d2395f2
parent 494871 6ccf5880c324342748d2a8c35370179065dcffe5
child 494873 e3e31e1dfc13dc2af566788e1dd781f59478cb73
push id114131
push userdluca@mozilla.com
push dateThu, 26 Sep 2019 09:47:34 +0000
treeherdermozilla-inbound@1dc1a755079a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb
bugs1583076
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1583076 - Pass LoadInfo back for the current channel when confirming redirects. r=ckerschb We previously used the initial LoadInfo from when the DocumentChannel was created, but need the one from the most recent channel in the parent. Differential Revision: https://phabricator.services.mozilla.com/D46741
netwerk/ipc/DocumentChannelChild.cpp
netwerk/ipc/DocumentChannelChild.h
netwerk/ipc/DocumentChannelParent.cpp
netwerk/ipc/PDocumentChannel.ipdl
--- a/netwerk/ipc/DocumentChannelChild.cpp
+++ b/netwerk/ipc/DocumentChannelChild.cpp
@@ -250,22 +250,18 @@ IPCResult DocumentChannelChild::RecvRedi
     const uint32_t& aRegistrarId, nsIURI* aURI, const uint32_t& aNewLoadFlags,
     const Maybe<ReplacementChannelConfigInit>& aInit,
     const Maybe<LoadInfoArgs>& aLoadInfo,
     nsTArray<DocumentChannelRedirect>&& aRedirects, const uint64_t& aChannelId,
     nsIURI* aOriginalURI, const uint32_t& aRedirectMode,
     const uint32_t& aRedirectFlags, const Maybe<uint32_t>& aContentDisposition,
     const Maybe<nsString>& aContentDispositionFilename,
     RedirectToRealChannelResolver&& aResolve) {
-  nsCOMPtr<nsILoadInfo> originalLoadInfo;
   RefPtr<dom::Document> loadingDocument;
-  GetLoadInfo(getter_AddRefs(originalLoadInfo));
-  if (originalLoadInfo) {
-    originalLoadInfo->GetLoadingDocument(getter_AddRefs(loadingDocument));
-  }
+  mLoadInfo->GetLoadingDocument(getter_AddRefs(loadingDocument));
 
   nsCOMPtr<nsILoadInfo> loadInfo;
   nsresult rv = LoadInfoArgsToLoadInfo(aLoadInfo, loadingDocument,
                                        getter_AddRefs(loadInfo));
   if (NS_FAILED(rv)) {
     MOZ_DIAGNOSTIC_ASSERT(false, "LoadInfoArgsToLoadInfo failed");
     return IPC_OK();
   }
@@ -399,31 +395,38 @@ DocumentChannelChild::OnRedirectVerifyCa
   if (CanSend()) {
     Send__delete__(this);
   }
 
   return NS_OK;
 }
 
 IPCResult DocumentChannelChild::RecvConfirmRedirect(
-    nsIURI* aNewUri, ConfirmRedirectResolver&& aResolve) {
+    const LoadInfoArgs& aLoadInfo, nsIURI* aNewUri,
+    ConfirmRedirectResolver&& aResolve) {
   // This is effectively the same as AsyncOnChannelRedirect, except since we're
   // not propagating the redirect into this process, we don't have an nsIChannel
   // for the redirection and we have to do the checks manually.
   // This just checks CSP thus far, hopefully there's not much else needed.
+  RefPtr<dom::Document> loadingDocument;
+  mLoadInfo->GetLoadingDocument(getter_AddRefs(loadingDocument));
+  nsCOMPtr<nsILoadInfo> loadInfo;
+  MOZ_ALWAYS_SUCCEEDS(LoadInfoArgsToLoadInfo(Some(aLoadInfo), loadingDocument,
+                                             getter_AddRefs(loadInfo)));
+
   nsCOMPtr<nsIURI> originalUri;
   nsresult rv = GetOriginalURI(getter_AddRefs(originalUri));
   if (NS_FAILED(rv)) {
     aResolve(Tuple<const nsresult&, const Maybe<nsresult>&>(NS_BINDING_FAILED,
                                                             Some(rv)));
     return IPC_OK();
   }
 
   Maybe<nsresult> cancelCode;
-  rv = CSPService::ConsultCSPForRedirect(originalUri, aNewUri, mLoadInfo,
+  rv = CSPService::ConsultCSPForRedirect(originalUri, aNewUri, loadInfo,
                                          cancelCode);
   aResolve(Tuple<const nsresult&, const Maybe<nsresult>&>(rv, cancelCode));
   return IPC_OK();
 }
 
 IPCResult DocumentChannelChild::RecvNotifyChannelClassifierProtectionDisabled(
     const uint32_t& aAcceptedReason) {
   UrlClassifierCommon::NotifyChannelClassifierProtectionDisabled(
--- a/netwerk/ipc/DocumentChannelChild.h
+++ b/netwerk/ipc/DocumentChannelChild.h
@@ -77,17 +77,18 @@ class DocumentChannelChild final : publi
 
   mozilla::ipc::IPCResult RecvSetClassifierMatchedInfo(
       const nsCString& aList, const nsCString& aProvider,
       const nsCString& aFullHash);
   mozilla::ipc::IPCResult RecvSetClassifierMatchedTrackingInfo(
       const nsCString& aLists, const nsCString& aFullHash);
 
   mozilla::ipc::IPCResult RecvConfirmRedirect(
-      nsIURI* aNewUri, ConfirmRedirectResolver&& aResolve);
+      const LoadInfoArgs& aLoadInfo, nsIURI* aNewUri,
+      ConfirmRedirectResolver&& aResolve);
 
   void DoFailedAsyncOpen(const nsresult& aStatusCode);
 
   const nsTArray<DocumentChannelRedirect>& GetRedirectChain() const {
     return mRedirects;
   }
 
   friend class NeckoTargetChannelEvent<DocumentChannelChild>;
--- a/netwerk/ipc/DocumentChannelParent.cpp
+++ b/netwerk/ipc/DocumentChannelParent.cpp
@@ -796,34 +796,41 @@ DocumentChannelParent::AsyncOnChannelRed
   if (!CanSend()) {
     return NS_BINDING_ABORTED;
   }
 
   // Currently the CSP code expects to run in the content
   // process so that it can send events. Send a message to
   // our content process to ask CSP if we should allow this
   // redirect, and wait for confirmation.
+  nsCOMPtr<nsILoadInfo> loadInfo = aOldChannel->LoadInfo();
+  Maybe<LoadInfoArgs> loadInfoArgs;
+  MOZ_ALWAYS_SUCCEEDS(ipc::LoadInfoToLoadInfoArgs(loadInfo, &loadInfoArgs));
+  MOZ_ASSERT(loadInfoArgs.isSome());
+
   nsCOMPtr<nsIURI> newUri;
   nsresult rv = aNewChannel->GetURI(getter_AddRefs(newUri));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIAsyncVerifyRedirectCallback> callback(aCallback);
   nsCOMPtr<nsIChannel> oldChannel(aOldChannel);
-  SendConfirmRedirect(newUri)->Then(
-      GetCurrentThreadSerialEventTarget(), __func__,
-      [callback, oldChannel](const Tuple<nsresult, Maybe<nsresult>>& aResult) {
-        if (Get<1>(aResult)) {
-          oldChannel->Cancel(*Get<1>(aResult));
-        }
-        callback->OnRedirectVerifyCallback(Get<0>(aResult));
-      },
-      [callback, oldChannel](const mozilla::ipc::ResponseRejectReason) {
-        oldChannel->Cancel(NS_ERROR_DOM_BAD_URI);
-        callback->OnRedirectVerifyCallback(NS_BINDING_ABORTED);
-      });
+  SendConfirmRedirect(*loadInfoArgs, newUri)
+      ->Then(
+          GetCurrentThreadSerialEventTarget(), __func__,
+          [callback,
+           oldChannel](const Tuple<nsresult, Maybe<nsresult>>& aResult) {
+            if (Get<1>(aResult)) {
+              oldChannel->Cancel(*Get<1>(aResult));
+            }
+            callback->OnRedirectVerifyCallback(Get<0>(aResult));
+          },
+          [callback, oldChannel](const mozilla::ipc::ResponseRejectReason) {
+            oldChannel->Cancel(NS_ERROR_DOM_BAD_URI);
+            callback->OnRedirectVerifyCallback(NS_BINDING_ABORTED);
+          });
 
   // Clear out our nsIParentChannel functions, since a normal parent
   // channel would actually redirect and not have those values on the new one.
   // We expect the URI classifier to run on the redirected channel with
   // the new URI and set these again.
   mIParentChannelFunctions.Clear();
   return NS_OK;
 }
--- a/netwerk/ipc/PDocumentChannel.ipdl
+++ b/netwerk/ipc/PDocumentChannel.ipdl
@@ -70,17 +70,17 @@ child:
                               DocumentChannelRedirect[] aRedirects,
                               uint64_t aChannelId,
                               nsIURI aOriginalURI,
                               uint32_t aRedirectMode,
                               uint32_t aRedirectFlags,
                               uint32_t? aContentDisposition,
                               nsString? aContentDispositionFilename) returns(nsresult rv);
 
-  async ConfirmRedirect(nsIURI aNewURI) returns(nsresult rv, nsresult? cancelCode);
+  async ConfirmRedirect(LoadInfoArgs aLoadInfo, nsIURI aNewURI) returns(nsresult rv, nsresult? cancelCode);
 
   // Tell child to delete channel (all IPDL deletes must be done from child to
   // avoid races: see bug 591708).
   async DeleteSelf();
 
 };
 
 } // namespace net