forked from mirrors/gecko-dev
Bug 1899138 - Set the IsInThirdPartyContext for the loadInfo of the channel that loads worker scripts. r=asuth
To set the IsInThirdPartyContext bit to the channel's loadInfo, we duduce whether the channel is foreign by looking into the partitionKey of the worker. If the partitionKey of the OAs of the worker's principal is not empty, the worker should be foreign, so as to the channel. Differential Revision: https://phabricator.services.mozilla.com/D211757
This commit is contained in:
parent
7015137c0c
commit
d6dbe99f94
2 changed files with 22 additions and 0 deletions
|
|
@ -693,6 +693,16 @@ nsresult CompareNetwork::Initialize(nsIPrincipal* aPrincipal,
|
|||
return rv;
|
||||
}
|
||||
|
||||
// Set the IsInThirdPartyContext for the channel's loadInfo according to the
|
||||
// partitionKey of the principal. The worker is foreign if it's using
|
||||
// partitioned principal, i.e. the partitionKey is not empty. In this case,
|
||||
// we need to set the bit to the channel's loadInfo.
|
||||
if (!aPrincipal->OriginAttributesRef().mPartitionKey.IsEmpty()) {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo();
|
||||
rv = loadInfo->SetIsInThirdPartyContext(true);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
|
||||
if (httpChannel) {
|
||||
// Spec says no redirects allowed for top-level SW scripts.
|
||||
|
|
|
|||
|
|
@ -1025,6 +1025,18 @@ nsresult WorkerScriptLoader::LoadScript(
|
|||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Set the IsInThirdPartyContext for the channel's loadInfo according to the
|
||||
// partitionKey of the principal. The worker is foreign if it's using
|
||||
// partitioned principal, i.e. the partitionKey is not empty. In this case,
|
||||
// we need to set the bit to the channel's loadInfo.
|
||||
if (!principal->OriginAttributesRef().mPartitionKey.IsEmpty()) {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
|
||||
rv = loadInfo->SetIsInThirdPartyContext(true);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Associate any originating stack with the channel.
|
||||
|
|
|
|||
Loading…
Reference in a new issue