Bug 1637194 - P2. Set firstPartyDomain to CookieJarSetting in nsHttpChannel::AsyncOpen r=necko-reviewers,timhuang,baku,kershaw

FirstPartyDomain is only set while loading a top-level document.
We added in nsHttpChannel::AsyncOpen to ensure that the value is updated
whenever we open a channel.

Differential Revision: https://phabricator.services.mozilla.com/D75277
This commit is contained in:
Dimi Lee 2020-05-19 09:47:25 +00:00
Родитель 7cf904bbc5
Коммит ae8751a56d
3 изменённых файлов: 27 добавлений и 5 удалений

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

@ -433,6 +433,7 @@ bool DocumentLoadListener::Open(
httpBaseChannel->SetTopWindowURI(topWindowURI);
}
// TODO: Remove this in Bug 1639140
Unused << loadInfo->SetHasStoragePermission(
AntiTrackingUtils::HasStoragePermissionInParent(mChannel));

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

@ -1857,6 +1857,25 @@ void nsHttpChannel::SetCachedContentType() {
mCacheEntry->SetContentType(contentType);
}
void nsHttpChannel::UpdateAntiTrackingInfo() {
Unused << mLoadInfo->SetHasStoragePermission(
AntiTrackingUtils::HasStoragePermissionInParent(this));
AntiTrackingUtils::ComputeIsThirdPartyToTopWindow(this);
// We only need to set FPD for top-level loads. FPD will automatically be
// propagated to non-top level loads via CookieJarSetting.
if (mLoadInfo->GetExternalContentPolicyType() ==
nsIContentPolicy::TYPE_DOCUMENT) {
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
Unused << mLoadInfo->GetCookieJarSettings(
getter_AddRefs(cookieJarSettings));
mozilla::net::CookieJarSettings::Cast(cookieJarSettings)
->SetFirstPartyDomain(mURI);
}
}
nsresult nsHttpChannel::CallOnStartRequest() {
LOG(("nsHttpChannel::CallOnStartRequest [this=%p]", this));
@ -6506,11 +6525,6 @@ nsHttpChannel::AsyncOpen(nsIStreamListener* aListener) {
return NS_ERROR_NOT_AVAILABLE;
}
Unused << mLoadInfo->SetHasStoragePermission(
AntiTrackingUtils::HasStoragePermissionInParent(this));
AntiTrackingUtils::ComputeIsThirdPartyToTopWindow(this);
static bool sRCWNInited = false;
if (!sRCWNInited) {
sRCWNInited = true;
@ -6542,6 +6556,8 @@ nsHttpChannel::AsyncOpen(nsIStreamListener* aListener) {
UpdatePrivateBrowsing();
}
UpdateAntiTrackingInfo();
if (WaitingForTailUnblock()) {
// This channel is marked as Tail and is part of a request context
// that has positive number of non-tailed requestst, hence this channel

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

@ -569,6 +569,11 @@ class nsHttpChannel final : public HttpBaseChannel,
// writing a new entry. The content type is used in cache internally only.
void SetCachedContentType();
// This function updates all the fields used by anti-tracking when a channel
// is opened. We have to do this in the parent to access cross-origin info
// that is not exposed to child processes.
void UpdateAntiTrackingInfo();
private:
// this section is for main-thread-only object
// all the references need to be proxy released on main thread.