Bug 1910886 - Reduce duplicated code between CookieService and CookieServiceChild - part 3 - Fix gtests, r=edgul

Differential Revision: https://phabricator.services.mozilla.com/D218314
This commit is contained in:
Andrea Marchesini
2024-08-09 08:37:14 +00:00
parent c655bb948a
commit d32be3189f
2 changed files with 21 additions and 11 deletions

View File

@@ -6611,19 +6611,23 @@ void Document::GetCookie(nsAString& aCookie, ErrorResult& aRv) {
return;
}
StorageAccess storageAccess = CookieAllowedForDocument(this);
if (storageAccess == StorageAccess::eDeny) {
return;
}
// GTests do not create an inner window and because of these a few security
// checks will block this method.
if (!StaticPrefs::dom_cookie_testing_enabled()) {
StorageAccess storageAccess = CookieAllowedForDocument(this);
if (storageAccess == StorageAccess::eDeny) {
return;
}
if (ShouldPartitionStorage(storageAccess) &&
!StoragePartitioningEnabled(storageAccess, CookieJarSettings())) {
return;
}
if (ShouldPartitionStorage(storageAccess) &&
!StoragePartitioningEnabled(storageAccess, CookieJarSettings())) {
return;
}
// If the document is a cookie-averse Document... return the empty string.
if (IsCookieAverse()) {
return;
// If the document is a cookie-averse Document... return the empty string.
if (IsCookieAverse()) {
return;
}
}
// not having a cookie service isn't an error