Bug 1641459 - Consider 3rd parties cookie requested by documents with a window, r=smaug

This is required for how Cookies gtests are written

Differential Revision: https://phabricator.services.mozilla.com/D77301
This commit is contained in:
Andrea Marchesini 2020-05-29 15:57:29 +00:00
Родитель 948adbdc87
Коммит a0049a050f
3 изменённых файлов: 27 добавлений и 18 удалений

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

@ -317,14 +317,15 @@ CookieService::GetCookieStringFromDocument(Document* aDocument,
// if it isn't, then we can't send a secure cookie over the connection.
bool potentiallyTurstworthy = principal->GetIsOriginPotentiallyTrustworthy();
bool thirdParty = true;
nsPIDOMWindowInner* innerWindow = aDocument->GetInnerWindow();
if (NS_WARN_IF(!innerWindow)) {
return NS_OK;
// in gtests we don't have a window, let's consider those requests as 3rd
// party.
if (innerWindow) {
thirdParty = nsContentUtils::IsThirdPartyWindowOrChannel(innerWindow,
nullptr, nullptr);
}
bool thirdParty = nsContentUtils::IsThirdPartyWindowOrChannel(
innerWindow, nullptr, nullptr);
bool stale = false;
nsTArray<Cookie*> cookieList;
@ -455,13 +456,16 @@ CookieService::SetCookieStringFromDocument(Document* aDocument,
return NS_OK;
}
bool thirdParty = true;
nsPIDOMWindowInner* innerWindow = aDocument->GetInnerWindow();
if (NS_WARN_IF(!innerWindow)) {
return NS_OK;
// in gtests we don't have a window, let's consider those requests as 3rd
// party.
if (innerWindow) {
thirdParty = nsContentUtils::IsThirdPartyWindowOrChannel(innerWindow,
nullptr, nullptr);
}
if (nsContentUtils::IsThirdPartyWindowOrChannel(innerWindow, nullptr,
nullptr) &&
if (thirdParty &&
!CookieCommons::ShouldIncludeCrossSiteCookieForDocument(cookie)) {
return NS_OK;
}

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

@ -351,14 +351,15 @@ CookieServiceChild::GetCookieStringFromDocument(Document* aDocument,
nsAutoCString pathFromURI;
principal->GetFilePath(pathFromURI);
bool thirdParty = true;
nsPIDOMWindowInner* innerWindow = aDocument->GetInnerWindow();
if (NS_WARN_IF(!innerWindow)) {
return NS_OK;
// in gtests we don't have a window, let's consider those requests as 3rd
// party.
if (innerWindow) {
thirdParty = nsContentUtils::IsThirdPartyWindowOrChannel(innerWindow,
nullptr, nullptr);
}
bool thirdParty = nsContentUtils::IsThirdPartyWindowOrChannel(
innerWindow, nullptr, nullptr);
bool isPotentiallyTrustworthy =
principal->GetIsOriginPotentiallyTrustworthy();
int64_t currentTimeInUsec = PR_Now();
@ -444,13 +445,16 @@ CookieServiceChild::SetCookieStringFromDocument(
return NS_OK;
}
bool thirdParty = true;
nsPIDOMWindowInner* innerWindow = aDocument->GetInnerWindow();
if (NS_WARN_IF(!innerWindow)) {
return NS_OK;
// in gtests we don't have a window, let's consider those requests as 3rd
// party.
if (innerWindow) {
thirdParty = nsContentUtils::IsThirdPartyWindowOrChannel(innerWindow,
nullptr, nullptr);
}
if (nsContentUtils::IsThirdPartyWindowOrChannel(innerWindow, nullptr,
nullptr) &&
if (thirdParty &&
!CookieCommons::ShouldIncludeCrossSiteCookieForDocument(cookie)) {
return NS_OK;
}

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

@ -1026,6 +1026,7 @@ TEST(TestCookie, SameSiteLax)
TEST(TestCookie, OnionSite)
{
Preferences::SetBool("dom.securecontext.whitelist_onions", true);
Preferences::SetBool("network.cookie.sameSite.laxByDefault", false);
nsresult rv;
nsCString cookie;