Bug 1555564 - Part 2: When initiating a local storage preload from early navigation in the parent process, use the storage principal; r=baku
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 30 May 2019 12:09:42 +0000
changeset 476215 441094863251d25debebf98ad09cf02e665a6eed
parent 476214 7b3e1ab23b288e9e08c3d7a2e50d8071b826b44b
child 476216 9cd79017eae85369865c6992003d9ccfde5abef0
push id36089
push usernbeleuzu@mozilla.com
push dateThu, 30 May 2019 21:48:30 +0000
treeherdermozilla-central@e09471d13659 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1555564
milestone69.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 1555564 - Part 2: When initiating a local storage preload from early navigation in the parent process, use the storage principal; r=baku Differential Revision: https://phabricator.services.mozilla.com/D33117
dom/ipc/ContentParent.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -5389,18 +5389,23 @@ nsresult ContentParent::AboutToLoadHttpF
 
   if (principal->GetIsCodebasePrincipal()) {
     nsCOMPtr<nsILocalStorageManager> lsm =
         do_GetService("@mozilla.org/dom/localStorage-manager;1");
     if (NS_WARN_IF(!lsm)) {
       return NS_ERROR_FAILURE;
     }
 
+    nsCOMPtr<nsIPrincipal> storagePrincipal;
+    rv = ssm->GetChannelResultStoragePrincipal(
+        aChannel, getter_AddRefs(storagePrincipal));
+    NS_ENSURE_SUCCESS(rv, rv);
+
     nsCOMPtr<nsISupports> dummy;
-    rv = lsm->Preload(principal, nullptr, getter_AddRefs(dummy));
+    rv = lsm->Preload(storagePrincipal, nullptr, getter_AddRefs(dummy));
     if (NS_FAILED(rv)) {
       NS_WARNING("Failed to preload local storage!");
     }
   }
 
   return NS_OK;
 }