Bug 1731982 - Part 5: Using foreign partitioned principal when creating clientSource in ServiceWorkerManager. r=asuth

Currently, the ServiceWorkerManager creates a content prinipcal based
on the regular originAttributes when dispatch the fetch event. This
patch changes to use the foreign partitioned originAttributs.

Note that we don't add tests for this because the change doesn't change
the behavior. And we don't enable partitioned third-party Service Worker.
So, the existing test cases is enough for this.

Differential Revision: https://phabricator.services.mozilla.com/D127632
This commit is contained in:
Tim Huang 2021-11-25 13:11:31 +00:00
parent 2997f5f4a1
commit e65d0db962

View File

@ -61,6 +61,7 @@
#include "mozilla/PermissionManager.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/StaticPrefs_extensions.h"
#include "mozilla/StoragePrincipalHelper.h"
#include "mozilla/Unused.h"
#include "mozilla/EnumSet.h"
@ -2042,8 +2043,13 @@ void ServiceWorkerManager::DispatchFetchEvent(nsIInterceptedChannel* aChannel,
}
// non-subresource request means the URI contains the principal
nsCOMPtr<nsIPrincipal> principal = BasePrincipal::CreateContentPrincipal(
uri, loadInfo->GetOriginAttributes());
OriginAttributes attrs = loadInfo->GetOriginAttributes();
StoragePrincipalHelper::GetOriginAttributes(
internalChannel, attrs,
StoragePrincipalHelper::eForeignPartitionedPrincipal);
nsCOMPtr<nsIPrincipal> principal =
BasePrincipal::CreateContentPrincipal(uri, attrs);
RefPtr<ServiceWorkerRegistrationInfo> registration =
GetServiceWorkerRegistrationInfo(principal, uri);