Bug 1824222 - Add OverriddenFingerprintingSettings to WindowContext. r=nika,tjr

This patch adds a field called OverriddenFingerprintingSettings to
WindowContext. The OverriddenFingerprintingSettings represents the
granular overrides of fingerprinting protections due to WebCompat for
the given context. The value can be Nothing() if there is no overrides
defined for the context.

Differential Revision: https://phabricator.services.mozilla.com/D188758
This commit is contained in:
Tim Huang 2023-10-17 22:02:29 +00:00
Родитель 5081de9795
Коммит e2cb3b6fc1
7 изменённых файлов: 58 добавлений и 0 удалений

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

@ -13,6 +13,7 @@
#include "mozilla/dom/Document.h"
#include "mozilla/dom/UserActivationIPCUtils.h"
#include "mozilla/PermissionDelegateIPCUtils.h"
#include "mozilla/RFPTargetIPCUtils.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/ClearOnShutdown.h"
@ -240,6 +241,12 @@ bool WindowContext::CanSet(FieldIndex<IDX_ShouldResistFingerprinting>,
return CheckOnlyOwningProcessCanSet(aSource);
}
bool WindowContext::CanSet(FieldIndex<IDX_OverriddenFingerprintingSettings>,
const Maybe<RFPTarget>& aValue,
ContentParent* aSource) {
return CheckOnlyOwningProcessCanSet(aSource);
}
bool WindowContext::CanSet(FieldIndex<IDX_IsSecureContext>,
const bool& aIsSecureContext,
ContentParent* aSource) {

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

@ -55,6 +55,7 @@ class BrowsingContextGroup;
* the Storage Access API */ \
FIELD(UsingStorageAccess, bool) \
FIELD(ShouldResistFingerprinting, bool) \
FIELD(OverriddenFingerprintingSettings, Maybe<RFPTarget>) \
FIELD(IsSecureContext, bool) \
FIELD(IsOriginalFrameSource, bool) \
/* Mixed-Content: If the corresponding documentURI is https, \
@ -135,6 +136,16 @@ class WindowContext : public nsISupports, public nsWrapperCache {
return GetShouldResistFingerprinting();
}
Nullable<uint64_t> GetOverriddenFingerprintingSettingsWebIDL() const {
Maybe<RFPTarget> overriddenFingerprintingSettings =
GetOverriddenFingerprintingSettings();
return overriddenFingerprintingSettings.isSome()
? Nullable<uint64_t>(
uint64_t(overriddenFingerprintingSettings.ref()))
: Nullable<uint64_t>();
}
nsGlobalWindowInner* GetInnerWindow() const;
Document* GetDocument() const;
Document* GetExtantDoc() const;
@ -273,6 +284,8 @@ class WindowContext : public nsISupports, public nsWrapperCache {
const bool& aUsingStorageAccess, ContentParent* aSource);
bool CanSet(FieldIndex<IDX_ShouldResistFingerprinting>,
const bool& aShouldResistFingerprinting, ContentParent* aSource);
bool CanSet(FieldIndex<IDX_OverriddenFingerprintingSettings>,
const Maybe<RFPTarget>& aValue, ContentParent* aSource);
bool CanSet(FieldIndex<IDX_IsSecureContext>, const bool& aIsSecureContext,
ContentParent* aSource);
bool CanSet(FieldIndex<IDX_IsOriginalFrameSource>,

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

@ -34,6 +34,14 @@ interface WindowContext {
readonly attribute boolean shouldResistFingerprinting;
// The granular fingerprinting protection overrides for the context. We will
// use the granular overrides to decide which fingerprinting protection we
// want to enable in the context due to the WebCompat reason. The value can be
// null, which means we are using default fingerprinting protection in the
// context.
[BinaryName="OverriddenFingerprintingSettingsWebIDL"]
readonly attribute unsigned long long? overriddenFingerprintingSettings;
/**
* Partially determines whether script execution is allowed in this
* BrowsingContext. Script execution will be permitted only if this

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

@ -109,6 +109,8 @@ WindowGlobalInit WindowGlobalActor::WindowInitializer(
nsContentUtils::IsThirdPartyTrackingResourceWindow(aWindow);
fields.Get<Indexes::IDX_ShouldResistFingerprinting>() =
doc->ShouldResistFingerprinting(RFPTarget::IsAlwaysEnabledForPrecompute);
fields.Get<Indexes::IDX_OverriddenFingerprintingSettings>() =
doc->GetOverriddenFingerprintingSettings();
fields.Get<Indexes::IDX_IsSecureContext>() = aWindow->IsSecureContext();
// Initialze permission fields

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

@ -215,6 +215,10 @@ void WindowGlobalChild::OnNewDocument(Document* aDocument) {
if (auto policy = aDocument->GetEmbedderPolicy()) {
txn.SetEmbedderPolicy(*policy);
}
txn.SetShouldResistFingerprinting(aDocument->ShouldResistFingerprinting(
RFPTarget::IsAlwaysEnabledForPrecompute));
txn.SetOverriddenFingerprintingSettings(
aDocument->GetOverriddenFingerprintingSettings());
if (nsCOMPtr<nsIChannel> channel = aDocument->GetChannel()) {
nsCOMPtr<nsILoadInfo> loadInfo(channel->LoadInfo());

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

@ -0,0 +1,23 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __RFPTargetIPCUtils_h__
#define __RFPTargetIPCUtils_h__
#include "ipc/EnumSerializer.h"
#include "nsRFPService.h"
namespace IPC {
template <>
struct ParamTraits<mozilla::RFPTarget>
: BitFlagsEnumSerializer<mozilla::RFPTarget,
mozilla::RFPTarget::AllTargets> {};
} // namespace IPC
#endif // __RFPTargetIPCUtils_h__

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

@ -21,6 +21,7 @@ FINAL_LIBRARY = "xul"
EXPORTS += ["nsRFPService.h", "RFPTargets.inc"]
EXPORTS.mozilla += [
"RelativeTimeline.h",
"RFPTargetIPCUtils.h",
]
EXTRA_JS_MODULES += [