Bug 1731982 - Part 7: Ignoring the partitionKey when verify loadingPrincipal with clientInfo. r=asuth,necko-reviewers

Given that we use the partitioned Principal in the third-party context
and the loading principal won't have it, we should ignore the
partitionKey when doing the verfication.

Differential Revision: https://phabricator.services.mozilla.com/D127841
This commit is contained in:
Tim Huang 2021-11-25 13:11:32 +00:00
Родитель 45bfad05fe
Коммит e05ade8128
1 изменённых файлов: 13 добавлений и 5 удалений

Просмотреть файл

@ -340,13 +340,21 @@ void AssertLoadingPrincipalAndClientInfoMatch(
return;
}
// Fall back to a slower origin equality test to support null principals.
nsAutoCString loadingOrigin;
MOZ_ALWAYS_SUCCEEDS(aLoadingPrincipal->GetOrigin(loadingOrigin));
nsAutoCString loadingOriginNoSuffix;
MOZ_ALWAYS_SUCCEEDS(
aLoadingPrincipal->GetOriginNoSuffix(loadingOriginNoSuffix));
nsAutoCString clientOrigin;
MOZ_ALWAYS_SUCCEEDS(clientPrincipal->GetOrigin(clientOrigin));
nsAutoCString clientOriginNoSuffix;
MOZ_ALWAYS_SUCCEEDS(
clientPrincipal->GetOriginNoSuffix(clientOriginNoSuffix));
MOZ_DIAGNOSTIC_ASSERT(loadingOrigin == clientOrigin);
// The client principal will have the partitionKey set if it's in a third
// party context, but the loading principal won't. So, we ignore he
// partitionKey when doing the verification here.
MOZ_DIAGNOSTIC_ASSERT(loadingOriginNoSuffix == clientOriginNoSuffix);
MOZ_DIAGNOSTIC_ASSERT(
aLoadingPrincipal->OriginAttributesRef().EqualsIgnoringPartitionKey(
clientPrincipal->OriginAttributesRef()));
}
#endif
}