Backed out 2 changesets (bug 1663192) for build bustages on nsHttpChannel.cpp. CLOSED TREE

Backed out changeset a12d9ab2562c (bug 1663192)
Backed out changeset b47fca4272fd (bug 1663192)
This commit is contained in:
Razvan Maries 2020-09-25 02:34:05 +03:00
Родитель ddc2f11b46
Коммит 2e98c304f8
8 изменённых файлов: 31 добавлений и 120 удалений

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

@ -22,7 +22,6 @@
#include "LoadInfo.h"
#include "nsServiceManagerUtils.h"
#include "nsRedirectHistoryEntry.h"
#include "mozilla/AntiTrackingUtils.h"
#include "mozilla/BasePrincipal.h"
using namespace mozilla;
@ -702,8 +701,6 @@ nsBaseChannel::AsyncOpen(nsIStreamListener* aListener) {
return rv;
}
AntiTrackingUtils::UpdateAntiTrackingInfoForChannel(this);
// Store the listener and context early so that OpenContentStream and the
// stream's AsyncWait method (called by AsyncRead) can have access to them
// via PushStreamConverter and the StreamListener methods. However, since

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

@ -1885,6 +1885,31 @@ void nsHttpChannel::SetCachedContentType() {
mCacheEntry->SetContentType(contentType);
}
void nsHttpChannel::UpdateAntiTrackingInfo() {
Unused << mLoadInfo->SetHasStoragePermission(
AntiTrackingUtils::HasStoragePermissionInParent(this));
AntiTrackingUtils::ComputeIsThirdPartyToTopWindow(this);
if (mLoadInfo->GetExternalContentPolicyType() ==
nsIContentPolicy::TYPE_DOCUMENT) {
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
Unused << mLoadInfo->GetCookieJarSettings(
getter_AddRefs(cookieJarSettings));
// Update the IsOnContentBlockingAllowList flag in the CookieJarSettings
// if this is a top level loading. For sub-document loading, this flag
// would inherit from the parent.
mozilla::net::CookieJarSettings::Cast(cookieJarSettings)
->UpdateIsOnContentBlockingAllowList(this);
// We only need to set FPD for top-level loads. FPD will automatically be
// propagated to non-top level loads via CookieJarSetting.
mozilla::net::CookieJarSettings::Cast(cookieJarSettings)
->SetPartitionKey(mURI);
}
}
nsresult nsHttpChannel::CallOnStartRequest() {
LOG(("nsHttpChannel::CallOnStartRequest [this=%p]", this));
@ -6742,7 +6767,7 @@ nsHttpChannel::AsyncOpen(nsIStreamListener* aListener) {
UpdatePrivateBrowsing();
}
AntiTrackingUtils::UpdateAntiTrackingInfoForChannel(this);
UpdateAntiTrackingInfo();
if (WaitingForTailUnblock()) {
// This channel is marked as Tail and is part of a request context

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

@ -557,6 +557,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.

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

@ -674,51 +674,3 @@ nsCString AntiTrackingUtils::GrantedReasonToString(
return "stroage access API"_ns;
}
}
/* static */
void AntiTrackingUtils::UpdateAntiTrackingInfoForChannel(nsIChannel* aChannel) {
MOZ_ASSERT(aChannel);
if (!XRE_IsParentProcess()) {
return;
}
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
Unused << loadInfo->SetHasStoragePermission(
AntiTrackingUtils::HasStoragePermissionInParent(aChannel));
AntiTrackingUtils::ComputeIsThirdPartyToTopWindow(aChannel);
// We only update the IsOnContentBlockingAllowList flag and the partition key
// for the top-level http channel.
//
// The IsOnContentBlockingAllowList is only for http. For other types of
// channels, such as 'file:', there will be no interface to modify this. So,
// we only update it in http channels.
//
// The partition key is computed based on the site, so it's no point to set it
// for channels other than http channels.
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
if (!httpChannel || loadInfo->GetExternalContentPolicyType() !=
nsIContentPolicy::TYPE_DOCUMENT) {
return;
}
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
Unused << loadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
// Update the IsOnContentBlockingAllowList flag in the CookieJarSettings
// if this is a top level loading. For sub-document loading, this flag
// would inherit from the parent.
net::CookieJarSettings::Cast(cookieJarSettings)
->UpdateIsOnContentBlockingAllowList(aChannel);
// We only need to set FPD for top-level loads. FPD will automatically be
// propagated to non-top level loads via CookieJarSetting.
nsCOMPtr<nsIURI> uri;
Unused << aChannel->GetURI(getter_AddRefs(uri));
net::CookieJarSettings::Cast(cookieJarSettings)->SetPartitionKey(uri);
}

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

@ -123,13 +123,6 @@ class AntiTrackingUtils final {
static nsCString GrantedReasonToString(
ContentBlockingNotifier::StorageAccessPermissionGrantedReason aReason);
/**
* 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.
*/
static void UpdateAntiTrackingInfoForChannel(nsIChannel* aChannel);
};
} // namespace mozilla

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

@ -36,7 +36,6 @@ support-files =
empty-altsvc.js
empty-altsvc.js^headers^
empty.html
file_localStorage.html
popup.html
redirect.sjs
server.sjs
@ -74,7 +73,6 @@ skip-if = os == "linux" && debug #bug 1627094
[browser_blockingNoOpener.js]
[browser_doublyNestedTracker.js]
[browser_existingCookiesForSubresources.js]
[browser_fileUrl.js]
[browser_firstPartyCookieRejectionHonoursAllowList.js]
[browser_hasStorageAccess.js]
[browser_imageCache4.js]

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

@ -1,38 +0,0 @@
/**
* Bug 1663192 - Testing for ensuring the top-level window in a fire url is
* treated as first-party.
*/
"use strict";
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [["network.cookie.cookieBehavior", 1]],
});
});
add_task(async function() {
let dir = getChromeDir(getResolvedURI(gTestPath));
dir.append("file_localStorage.html");
const uriString = Services.io.newFileURI(dir).spec;
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, uriString);
await SpecialPowers.spawn(tab.linkedBrowser, [], function() {
let result = content.document.getElementById("result");
is(
result.textContent,
"PASS",
"The localStorage is accessible in top-level window"
);
let loadInfo = content.docShell.currentDocumentChannel.loadInfo;
ok(
!loadInfo.isThirdPartyContextToTopWindow,
"The top-level window shouldn't be third-party"
);
});
BrowserTestUtils.removeTab(tab);
});

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

@ -1,21 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Bug 1663192 - Accessing localStorage in a file urls</title>
</head>
<script>
window.addEventListener("DOMContentLoaded", () => {
let result = document.getElementById("result");
try {
window.localStorage.setItem("foo", "bar");
result.textContent = "PASS";
} catch (e) {
result.textContent = "FAIL";
}
}, { once: true });
</script>
<body>
<a id="result"></a>
</body>
</html>