зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1637634 - Update IsOnContentBlockingAllowList in nsHttpChannel::AsyncOpen r=timhuang,necko-reviewers
This patch removes TYPE_DOCUMENT test in test_shouldclassify because the testcase creates a non-top level channel with TYPE_DOCUMENT flag (this is wong!), which triggers the assertion in UpdateIsOnContentBlockingAllowList. File a follow-up bug 1640715 to add TYPE_DOCUMENT test back. Differential Revision: https://phabricator.services.mozilla.com/D76152
This commit is contained in:
Родитель
d2c1b033d5
Коммит
ed4c44789a
|
@ -431,19 +431,22 @@ void CookieJarSettings::UpdateIsOnContentBlockingAllowList(
|
||||||
MOZ_ASSERT(bc->IsTop());
|
MOZ_ASSERT(bc->IsTop());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> uriBeingLoaded =
|
nsCOMPtr<nsIURI> uri;
|
||||||
AntiTrackingUtils::MaybeGetDocumentURIBeingLoaded(aChannel);
|
nsresult rv = aChannel->GetURI(getter_AddRefs(uri));
|
||||||
nsCOMPtr<nsIPrincipal> contentBlockingAllowListPrincipal;
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// We need to recompute the ContentBlockingAllowListPrincipal here for the
|
// We need to recompute the ContentBlockingAllowListPrincipal here for the
|
||||||
// top level channel because we might navigate from the the initial
|
// top level channel because we might navigate from the the initial
|
||||||
// about:blank page or the existing page which may have a different origin
|
// about:blank page or the existing page which may have a different origin
|
||||||
// than the URI we are going to load here. Thus, we need to recompute the
|
// than the URI we are going to load here. Thus, we need to recompute the
|
||||||
// prinicpal in order to get the correct ContentBlockingAllowListPrincipal.
|
// prinicpal in order to get the correct ContentBlockingAllowListPrincipal.
|
||||||
|
nsCOMPtr<nsIPrincipal> contentBlockingAllowListPrincipal;
|
||||||
OriginAttributes attrs;
|
OriginAttributes attrs;
|
||||||
loadInfo->GetOriginAttributes(&attrs);
|
loadInfo->GetOriginAttributes(&attrs);
|
||||||
ContentBlockingAllowList::RecomputePrincipal(
|
ContentBlockingAllowList::RecomputePrincipal(
|
||||||
uriBeingLoaded, attrs, getter_AddRefs(contentBlockingAllowListPrincipal));
|
uri, attrs, getter_AddRefs(contentBlockingAllowListPrincipal));
|
||||||
|
|
||||||
if (!contentBlockingAllowListPrincipal ||
|
if (!contentBlockingAllowListPrincipal ||
|
||||||
!contentBlockingAllowListPrincipal->GetIsContentPrincipal()) {
|
!contentBlockingAllowListPrincipal->GetIsContentPrincipal()) {
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include "DocumentLoadListener.h"
|
#include "DocumentLoadListener.h"
|
||||||
|
|
||||||
#include "mozilla/AntiTrackingUtils.h"
|
#include "mozilla/AntiTrackingUtils.h"
|
||||||
#include "mozilla/ContentBlockingAllowList.h"
|
|
||||||
#include "mozilla/LoadInfo.h"
|
#include "mozilla/LoadInfo.h"
|
||||||
#include "mozilla/MozPromiseInlines.h" // For MozPromise::FromDomPromise
|
#include "mozilla/MozPromiseInlines.h" // For MozPromise::FromDomPromise
|
||||||
#include "mozilla/StaticPrefs_fission.h"
|
#include "mozilla/StaticPrefs_fission.h"
|
||||||
|
@ -413,15 +412,6 @@ bool DocumentLoadListener::Open(
|
||||||
// If this is for the top level loading, the top window URI should be the
|
// If this is for the top level loading, the top window URI should be the
|
||||||
// URI which we are loading.
|
// URI which we are loading.
|
||||||
topWindowURI = uriBeingLoaded;
|
topWindowURI = uriBeingLoaded;
|
||||||
|
|
||||||
// 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.
|
|
||||||
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
|
|
||||||
Unused << loadInfo->GetCookieJarSettings(
|
|
||||||
getter_AddRefs(cookieJarSettings));
|
|
||||||
net::CookieJarSettings::Cast(cookieJarSettings)
|
|
||||||
->UpdateIsOnContentBlockingAllowList(mChannel);
|
|
||||||
} else if (RefPtr<WindowGlobalParent> topWindow = AntiTrackingUtils::
|
} else if (RefPtr<WindowGlobalParent> topWindow = AntiTrackingUtils::
|
||||||
GetTopWindowExcludingExtensionAccessibleContentFrames(
|
GetTopWindowExcludingExtensionAccessibleContentFrames(
|
||||||
browsingContext, uriBeingLoaded)) {
|
browsingContext, uriBeingLoaded)) {
|
||||||
|
|
|
@ -1863,14 +1863,20 @@ void nsHttpChannel::UpdateAntiTrackingInfo() {
|
||||||
|
|
||||||
AntiTrackingUtils::ComputeIsThirdPartyToTopWindow(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() ==
|
if (mLoadInfo->GetExternalContentPolicyType() ==
|
||||||
nsIContentPolicy::TYPE_DOCUMENT) {
|
nsIContentPolicy::TYPE_DOCUMENT) {
|
||||||
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
|
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
|
||||||
Unused << mLoadInfo->GetCookieJarSettings(
|
Unused << mLoadInfo->GetCookieJarSettings(
|
||||||
getter_AddRefs(cookieJarSettings));
|
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)
|
mozilla::net::CookieJarSettings::Cast(cookieJarSettings)
|
||||||
->SetFirstPartyDomain(mURI);
|
->SetFirstPartyDomain(mURI);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,16 +16,15 @@ var normalOrigin, trackingOrigin;
|
||||||
|
|
||||||
// ShouldClassify algorithm uses the following parameters:
|
// ShouldClassify algorithm uses the following parameters:
|
||||||
// 1. Ci.nsIChannel.LOAD_ BYPASS_URL_CLASSIFIER loadflags
|
// 1. Ci.nsIChannel.LOAD_ BYPASS_URL_CLASSIFIER loadflags
|
||||||
// 2. Content type
|
// 2. Content type // TODO: Bug 1640715 to test this
|
||||||
// 3. triggering principal
|
// 3. triggering principal
|
||||||
// 4. be Conservative
|
// 4. be Conservative
|
||||||
// We test are the combinations here to make sure the algorithm is correct
|
// We test are the combinations here to make sure the algorithm is correct
|
||||||
|
|
||||||
const PARAM_LOAD_BYPASS_URL_CLASSIFIER = 1 << 0;
|
const PARAM_LOAD_BYPASS_URL_CLASSIFIER = 1 << 0;
|
||||||
const PARAM_CONTENT_POLICY_TYPE_DOCUMENT = 1 << 1;
|
const PARAM_TRIGGERING_PRINCIPAL_SYSTEM = 1 << 1;
|
||||||
const PARAM_TRIGGERING_PRINCIPAL_SYSTEM = 1 << 2;
|
const PARAM_CAP_BE_CONSERVATIVE = 1 << 2;
|
||||||
const PARAM_CAP_BE_CONSERVATIVE = 1 << 3;
|
const PARAM_MAX = 1 << 3;
|
||||||
const PARAM_MAX = 1 << 4;
|
|
||||||
|
|
||||||
function getParameters(bitFlags) {
|
function getParameters(bitFlags) {
|
||||||
var params = {
|
var params = {
|
||||||
|
@ -39,10 +38,6 @@ function getParameters(bitFlags) {
|
||||||
params.loadFlags = Ci.nsIChannel.LOAD_BYPASS_URL_CLASSIFIER;
|
params.loadFlags = Ci.nsIChannel.LOAD_BYPASS_URL_CLASSIFIER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bitFlags & PARAM_CONTENT_POLICY_TYPE_DOCUMENT) {
|
|
||||||
params.contentType = Ci.nsIContentPolicy.TYPE_DOCUMENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bitFlags & PARAM_TRIGGERING_PRINCIPAL_SYSTEM) {
|
if (bitFlags & PARAM_TRIGGERING_PRINCIPAL_SYSTEM) {
|
||||||
params.system = true;
|
params.system = true;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче