Commit 8822c440 authored by Tim Huang's avatar Tim Huang
Browse files

Bug 1731982 - Part 6: Using foreign partitioned principal when creating...

Bug 1731982 - Part 6: 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
parent 21e775c7
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -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);