From 73f4f0146549173f51fd9f2950fd988ce646edfe Mon Sep 17 00:00:00 2001 From: Fatih Kilic Date: Thu, 23 Jan 2025 14:49:44 +0000 Subject: [PATCH] Bug 1939881: Implement RFPTargetBits and replace appropriate uses. r=tjr This is a huge patch, but it is only really refactoring of RFPTarget enum. We used to use RFPTarget as a bitset and now we ran out of bits, so now we need a workaround. Differential Revision: https://phabricator.services.mozilla.com/D233182 --- docshell/base/WindowContext.cpp | 17 ++- docshell/base/WindowContext.h | 16 +-- dom/base/ChromeUtils.cpp | 17 ++- dom/base/ChromeUtils.h | 4 +- dom/base/Document.h | 4 +- dom/bindings/Bindings.conf | 1 + dom/chrome-webidl/ChromeUtils.webidl | 3 +- dom/chrome-webidl/WindowGlobalActors.webidl | 3 +- dom/ipc/ContentChild.cpp | 2 +- dom/serviceworkers/ServiceWorkerPrivate.cpp | 10 +- dom/workers/WorkerLoadInfo.h | 2 +- dom/workers/WorkerPrivate.h | 2 +- .../remoteworkers/RemoteWorkerChild.cpp | 4 +- .../remoteworkers/RemoteWorkerTypes.ipdlh | 3 +- dom/workers/sharedworkers/SharedWorker.cpp | 4 +- dom/worklet/WorkletImpl.h | 2 +- ipc/glue/BackgroundUtils.cpp | 20 +-- mfbt/BitSet.h | 10 +- mfbt/EnumSet.h | 11 +- mfbt/tests/TestBitSet.cpp | 18 +-- netwerk/base/LoadInfo.cpp | 6 +- netwerk/base/LoadInfo.h | 4 +- netwerk/base/TRRLoadInfo.cpp | 4 +- netwerk/base/TRRLoadInfo.h | 2 +- netwerk/base/nsILoadInfo.idl | 8 +- netwerk/ipc/NeckoChannelParams.ipdlh | 5 +- .../antitracking/AntiTrackingUtils.cpp | 2 +- .../resistfingerprinting/RFPTargetIPCUtils.h | 23 ---- .../resistfingerprinting/RFPTargets.inc | 130 +++++++++--------- .../resistfingerprinting/components.conf | 6 + .../extract_rfp_targets.py | 13 +- .../components/resistfingerprinting/moz.build | 10 +- .../resistfingerprinting/nsIRFPService.idl | 5 +- .../nsIRFPTargetSetIDL.idl | 15 ++ .../resistfingerprinting/nsRFPService.cpp | 129 +++++++++-------- .../resistfingerprinting/nsRFPService.h | 21 ++- .../nsRFPTargetSetIDL.cpp | 46 +++++++ .../resistfingerprinting/nsRFPTargetSetIDL.h | 28 ++++ .../browser_fingerprintingRemoteOverrides.js | 18 +-- 39 files changed, 377 insertions(+), 251 deletions(-) delete mode 100644 toolkit/components/resistfingerprinting/RFPTargetIPCUtils.h create mode 100644 toolkit/components/resistfingerprinting/nsIRFPTargetSetIDL.idl create mode 100644 toolkit/components/resistfingerprinting/nsRFPTargetSetIDL.cpp create mode 100644 toolkit/components/resistfingerprinting/nsRFPTargetSetIDL.h diff --git a/docshell/base/WindowContext.cpp b/docshell/base/WindowContext.cpp index 1e257a2aa0b0..c2b9a8e09e58 100644 --- a/docshell/base/WindowContext.cpp +++ b/docshell/base/WindowContext.cpp @@ -14,7 +14,6 @@ #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" @@ -22,6 +21,7 @@ #include "nsIScriptError.h" #include "nsIWebProgressListener.h" #include "nsIXULRuntime.h" +#include "nsRFPTargetSetIDL.h" #include "nsRefPtrHashtable.h" #include "nsContentUtils.h" @@ -78,6 +78,19 @@ bool WindowContext::IsInBFCache() { return TopWindowContext()->GetWindowStateSaved(); } +already_AddRefed +WindowContext::GetOverriddenFingerprintingSettingsWebIDL() const { + Maybe overriddenFingerprintingSettings = + GetOverriddenFingerprintingSettings(); + if (overriddenFingerprintingSettings.isNothing()) { + return nullptr; + } + + nsCOMPtr protections = + new nsRFPTargetSetIDL(overriddenFingerprintingSettings.ref()); + return protections.forget(); +} + nsGlobalWindowInner* WindowContext::GetInnerWindow() const { return mWindowGlobalChild ? mWindowGlobalChild->GetWindowGlobal() : nullptr; } @@ -241,7 +254,7 @@ bool WindowContext::CanSet(FieldIndex, } bool WindowContext::CanSet(FieldIndex, - const Maybe& aValue, + const Maybe& aValue, ContentParent* aSource) { return CheckOnlyOwningProcessCanSet(aSource); } diff --git a/docshell/base/WindowContext.h b/docshell/base/WindowContext.h index 316d833cd609..45060bef3ba9 100644 --- a/docshell/base/WindowContext.h +++ b/docshell/base/WindowContext.h @@ -23,6 +23,7 @@ class nsGlobalWindowInner; namespace mozilla { class LogModule; +class nsRFPTargetSetIDL; namespace dom { @@ -55,7 +56,7 @@ class BrowsingContextGroup; * the Storage Access API */ \ FIELD(UsingStorageAccess, bool) \ FIELD(ShouldResistFingerprinting, bool) \ - FIELD(OverriddenFingerprintingSettings, Maybe) \ + FIELD(OverriddenFingerprintingSettings, Maybe) \ FIELD(IsSecureContext, bool) \ FIELD(IsOriginalFrameSource, bool) \ /* Mixed-Content: If the corresponding documentURI is https, \ @@ -139,15 +140,8 @@ class WindowContext : public nsISupports, public nsWrapperCache { bool UsingStorageAccess() const { return GetUsingStorageAccess(); } - Nullable GetOverriddenFingerprintingSettingsWebIDL() const { - Maybe overriddenFingerprintingSettings = - GetOverriddenFingerprintingSettings(); - - return overriddenFingerprintingSettings.isSome() - ? Nullable( - uint64_t(overriddenFingerprintingSettings.ref())) - : Nullable(); - } + already_AddRefed + GetOverriddenFingerprintingSettingsWebIDL() const; nsGlobalWindowInner* GetInnerWindow() const; Document* GetDocument() const; @@ -305,7 +299,7 @@ class WindowContext : public nsISupports, public nsWrapperCache { bool CanSet(FieldIndex, const bool& aShouldResistFingerprinting, ContentParent* aSource); bool CanSet(FieldIndex, - const Maybe& aValue, ContentParent* aSource); + const Maybe& aValue, ContentParent* aSource); bool CanSet(FieldIndex, const bool& aIsSecureContext, ContentParent* aSource); bool CanSet(FieldIndex, diff --git a/dom/base/ChromeUtils.cpp b/dom/base/ChromeUtils.cpp index c8561604fe33..3479a0638f0c 100644 --- a/dom/base/ChromeUtils.cpp +++ b/dom/base/ChromeUtils.cpp @@ -60,6 +60,7 @@ #include "mozilla/RemoteDecoderManagerChild.h" #include "mozilla/KeySystemConfig.h" #include "mozilla/WheelHandlingHelper.h" +#include "nsIRFPTargetSetIDL.h" #include "nsContentSecurityUtils.h" #include "nsString.h" #include "nsNativeTheme.h" @@ -2317,7 +2318,7 @@ void ChromeUtils::GetAllPossibleUtilityActorNames(GlobalObject& aGlobal, /* static */ bool ChromeUtils::ShouldResistFingerprinting( GlobalObject& aGlobal, JSRFPTarget aTarget, - const Nullable& aOverriddenFingerprintingSettings, + nsIRFPTargetSetIDL* aOverriddenFingerprintingSettings, const Optional& aIsPBM) { RFPTarget target; switch (aTarget) { @@ -2351,10 +2352,16 @@ bool ChromeUtils::ShouldResistFingerprinting( } } - Maybe overriddenFingerprintingSettings; - if (!aOverriddenFingerprintingSettings.IsNull()) { - overriddenFingerprintingSettings.emplace( - RFPTarget(aOverriddenFingerprintingSettings.Value())); + Maybe overriddenFingerprintingSettings; + if (aOverriddenFingerprintingSettings) { + uint64_t low, hi; + aOverriddenFingerprintingSettings->GetLow(&low); + aOverriddenFingerprintingSettings->GetHigh(&hi); + std::bitset<128> bitset; + bitset |= hi; + bitset <<= 64; + bitset |= low; + overriddenFingerprintingSettings.emplace(RFPTargetSet(bitset)); } // This global object appears to be the global window, not for individual diff --git a/dom/base/ChromeUtils.h b/dom/base/ChromeUtils.h index e8ca19088eb6..b3b9a287faeb 100644 --- a/dom/base/ChromeUtils.h +++ b/dom/base/ChromeUtils.h @@ -16,6 +16,8 @@ #include "nsIDOMProcessChild.h" #include "nsIDOMProcessParent.h" +class nsIRFPTargetSetIDL; + namespace mozilla { class ErrorResult; @@ -326,7 +328,7 @@ class ChromeUtils { static bool ShouldResistFingerprinting( GlobalObject& aGlobal, JSRFPTarget aTarget, - const Nullable& aOverriddenFingerprintingSettings, + nsIRFPTargetSetIDL* aOverriddenFingerprintingSettings, const Optional& aIsPBM); static void SanitizeTelemetryFileURL(GlobalObject& aGlobal, diff --git a/dom/base/Document.h b/dom/base/Document.h index 04b6c019d894..0a7bf1a7a9f0 100644 --- a/dom/base/Document.h +++ b/dom/base/Document.h @@ -4200,7 +4200,7 @@ class Document : public nsINode, bool ShouldResistFingerprinting(RFPTarget aTarget) const; bool IsInPrivateBrowsing() const; - const Maybe& GetOverriddenFingerprintingSettings() const { + const Maybe& GetOverriddenFingerprintingSettings() const { return mOverriddenFingerprintingSettings; } @@ -4986,7 +4986,7 @@ class Document : public nsINode, // This will only get populated if these is one that comes from the local // fingerprinting protection override pref or WebCompat. Otherwise, a value of // Nothing() indicates no overrides are present for this document. - Maybe mOverriddenFingerprintingSettings; + Maybe mOverriddenFingerprintingSettings; uint8_t mXMLDeclarationBits; diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index b4d55706dad1..6abe385ee568 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -2013,6 +2013,7 @@ addExternalIface('nsIScreen', nativeType='nsIScreen', headerFile='nsIScreen.h', notflattened=True) addExternalIface('InputStream', nativeType='nsIInputStream', notflattened=True) +addExternalIface('nsIRFPTargetSetIDL', nativeType='nsIRFPTargetSetIDL') # The TemplatedAttributes dictionary has the interface name where the template # should be generated as the key. The values are lists of dictionaries, where diff --git a/dom/chrome-webidl/ChromeUtils.webidl b/dom/chrome-webidl/ChromeUtils.webidl index ad0f8300aaf7..9b8bd9b9b2ee 100644 --- a/dom/chrome-webidl/ChromeUtils.webidl +++ b/dom/chrome-webidl/ChromeUtils.webidl @@ -7,6 +7,7 @@ interface nsIDOMProcessChild; interface nsIDOMProcessParent; interface Principal; +interface nsIRFPTargetSetIDL; /** * An optimized QueryInterface method, generated by generateQI. @@ -749,7 +750,7 @@ partial namespace ChromeUtils { sequence getAllPossibleUtilityActorNames(); boolean shouldResistFingerprinting(JSRFPTarget target, - unsigned long long? overriddenFingerprintingSettings, + nsIRFPTargetSetIDL? overriddenFingerprintingSettings, optional boolean isPBM); FileNameTypeDetails sanitizeTelemetryFileURL(UTF8String url); diff --git a/dom/chrome-webidl/WindowGlobalActors.webidl b/dom/chrome-webidl/WindowGlobalActors.webidl index 06abb9ad967b..ead070a2fec9 100644 --- a/dom/chrome-webidl/WindowGlobalActors.webidl +++ b/dom/chrome-webidl/WindowGlobalActors.webidl @@ -8,6 +8,7 @@ interface URI; interface nsIDocShell; interface RemoteTab; interface nsIDOMProcessParent; +interface nsIRFPTargetSetIDL; [Exposed=Window, ChromeOnly] interface WindowContext { @@ -43,7 +44,7 @@ interface WindowContext { // null, which means we are using default fingerprinting protection in the // context. [BinaryName="OverriddenFingerprintingSettingsWebIDL"] - readonly attribute unsigned long long? overriddenFingerprintingSettings; + readonly attribute nsIRFPTargetSetIDL? overriddenFingerprintingSettings; /** * Partially determines whether script execution is allowed in this diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 420582c3ca22..740edf183b5e 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -4647,7 +4647,7 @@ void ContentChild::ConfigureThreadPerformanceHints( cpu_set_t cpuset; CPU_ZERO(&cpuset); for (size_t i = 0; i < cpuInfo->mTotalNumCpus; i++) { - if (cpus.Test(i)) { + if (cpus.test(i)) { CPU_SET(i, &cpuset); } } diff --git a/dom/serviceworkers/ServiceWorkerPrivate.cpp b/dom/serviceworkers/ServiceWorkerPrivate.cpp index 77141b45040b..b1d947814a4a 100644 --- a/dom/serviceworkers/ServiceWorkerPrivate.cpp +++ b/dom/serviceworkers/ServiceWorkerPrivate.cpp @@ -553,8 +553,8 @@ nsresult ServiceWorkerPrivate::Initialize() { // it's a third-party service worker. So, the cookieJarSettings can directly // use the partitionKey from it. For first-party case, we can populate the // partitionKey from the principal URI. - Maybe overriddenFingerprintingSettingsArg; - Maybe overriddenFingerprintingSettings; + Maybe overriddenFingerprintingSettingsArg; + Maybe overriddenFingerprintingSettings; nsCOMPtr firstPartyURI; bool foreignByAncestorContext = false; bool isOn3PCBExceptionList = false; @@ -583,7 +583,7 @@ nsresult ServiceWorkerPrivate::Initialize() { firstPartyURI, uri); if (overriddenFingerprintingSettings.isSome()) { overriddenFingerprintingSettingsArg.emplace( - uint64_t(overriddenFingerprintingSettings.ref())); + overriddenFingerprintingSettings.ref()); } RefPtr csSingleton = @@ -626,7 +626,7 @@ nsresult ServiceWorkerPrivate::Initialize() { if (overriddenFingerprintingSettings.isSome()) { overriddenFingerprintingSettingsArg.emplace( - uint64_t(overriddenFingerprintingSettings.ref())); + overriddenFingerprintingSettings.ref()); } } } else { @@ -642,7 +642,7 @@ nsresult ServiceWorkerPrivate::Initialize() { if (overriddenFingerprintingSettings.isSome()) { overriddenFingerprintingSettingsArg.emplace( - uint64_t(overriddenFingerprintingSettings.ref())); + overriddenFingerprintingSettings.ref()); } } diff --git a/dom/workers/WorkerLoadInfo.h b/dom/workers/WorkerLoadInfo.h index 43fd5e798536..ef5f76120b0c 100644 --- a/dom/workers/WorkerLoadInfo.h +++ b/dom/workers/WorkerLoadInfo.h @@ -146,7 +146,7 @@ struct WorkerLoadInfoData { bool mUsingStorageAccess; bool mServiceWorkersTestingInWindow; bool mShouldResistFingerprinting; - Maybe mOverriddenFingerprintingSettings; + Maybe mOverriddenFingerprintingSettings; OriginAttributes mOriginAttributes; bool mIsThirdPartyContext; bool mIsOn3PCBExceptionList; diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h index cbca67b06977..43c2da5d104f 100644 --- a/dom/workers/WorkerPrivate.h +++ b/dom/workers/WorkerPrivate.h @@ -1028,7 +1028,7 @@ class WorkerPrivate final bool ShouldResistFingerprinting(RFPTarget aTarget) const; - const Maybe& GetOverriddenFingerprintingSettings() const { + const Maybe& GetOverriddenFingerprintingSettings() const { return mLoadInfo.mOverriddenFingerprintingSettings; } diff --git a/dom/workers/remoteworkers/RemoteWorkerChild.cpp b/dom/workers/remoteworkers/RemoteWorkerChild.cpp index f1c02a9a4bc1..5eb3695d1e5c 100644 --- a/dom/workers/remoteworkers/RemoteWorkerChild.cpp +++ b/dom/workers/remoteworkers/RemoteWorkerChild.cpp @@ -280,10 +280,10 @@ nsresult RemoteWorkerChild::ExecWorkerOnMainThread( info.mOriginAttributes = BasePrincipal::Cast(principal)->OriginAttributesRef(); info.mShouldResistFingerprinting = aData.shouldResistFingerprinting(); - Maybe overriddenFingerprintingSettings; + Maybe overriddenFingerprintingSettings; if (aData.overriddenFingerprintingSettings().isSome()) { overriddenFingerprintingSettings.emplace( - RFPTarget(aData.overriddenFingerprintingSettings().ref())); + aData.overriddenFingerprintingSettings().ref()); } info.mOverriddenFingerprintingSettings = overriddenFingerprintingSettings; net::CookieJarSettings::Deserialize(aData.cookieJarSettings(), diff --git a/dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh b/dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh index fe5d13ef1dba..777f5da34e91 100644 --- a/dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh +++ b/dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh @@ -19,6 +19,7 @@ using struct mozilla::void_t from "mozilla/ipc/IPCCore.h"; using mozilla::dom::WorkerOptions from "mozilla/dom/WorkerBinding.h"; using mozilla::StorageAccess from "mozilla/StorageAccess.h"; using mozilla::OriginTrials from "mozilla/OriginTrialsIPCUtils.h"; +using mozilla::RFPTargetSet from "nsRFPService.h"; namespace mozilla { namespace dom { @@ -85,7 +86,7 @@ struct RemoteWorkerData bool shouldResistFingerprinting; - uint64_t? overriddenFingerprintingSettings; + RFPTargetSet? overriddenFingerprintingSettings; bool isOn3PCBExceptionList; diff --git a/dom/workers/sharedworkers/SharedWorker.cpp b/dom/workers/sharedworkers/SharedWorker.cpp index 775cb6e0c903..276f6b2a4577 100644 --- a/dom/workers/sharedworkers/SharedWorker.cpp +++ b/dom/workers/sharedworkers/SharedWorker.cpp @@ -253,10 +253,10 @@ already_AddRefed SharedWorker::Constructor( return nullptr; } - Maybe overriddenFingerprintingSettingsArg; + Maybe overriddenFingerprintingSettingsArg; if (loadInfo.mOverriddenFingerprintingSettings.isSome()) { overriddenFingerprintingSettingsArg.emplace( - uint64_t(loadInfo.mOverriddenFingerprintingSettings.ref())); + loadInfo.mOverriddenFingerprintingSettings.ref()); } RemoteWorkerData remoteWorkerData( diff --git a/dom/worklet/WorkletImpl.h b/dom/worklet/WorkletImpl.h index 85dff0b8df9a..76fa2b23a476 100644 --- a/dom/worklet/WorkletImpl.h +++ b/dom/worklet/WorkletImpl.h @@ -128,7 +128,7 @@ class WorkletImpl { // This will only get populated if these is one that comes from the local // granular override pref or WebCompat. Otherwise, a value of Nothing() // indicates no granular overrides are present for this workerlet. - Maybe mOverriddenFingerprintingSettings; + Maybe mOverriddenFingerprintingSettings; const OriginTrials mTrials; }; diff --git a/ipc/glue/BackgroundUtils.cpp b/ipc/glue/BackgroundUtils.cpp index b799748ddb8f..0f3f2976e219 100644 --- a/ipc/glue/BackgroundUtils.cpp +++ b/ipc/glue/BackgroundUtils.cpp @@ -545,13 +545,13 @@ nsresult LoadInfoToLoadInfoArgs(nsILoadInfo* aLoadInfo, redirectChain, interceptionInfo->FromThirdParty())); } - Maybe overriddenFingerprintingSettingsArg; - Maybe overriddenFingerprintingSettings = + Maybe overriddenFingerprintingSettingsArg; + Maybe overriddenFingerprintingSettings = aLoadInfo->GetOverriddenFingerprintingSettings(); if (overriddenFingerprintingSettings) { overriddenFingerprintingSettingsArg = - Some(uint64_t(overriddenFingerprintingSettings.ref())); + Some(overriddenFingerprintingSettings.ref()); } *outLoadInfoArgs = LoadInfoArgs( @@ -790,10 +790,10 @@ nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& loadInfoArgs, CookieJarSettings::Deserialize(loadInfoArgs.cookieJarSettings(), getter_AddRefs(cookieJarSettings)); - Maybe overriddenFingerprintingSettings; + Maybe overriddenFingerprintingSettings; if (loadInfoArgs.overriddenFingerprintingSettings().isSome()) { overriddenFingerprintingSettings.emplace( - RFPTarget(loadInfoArgs.overriddenFingerprintingSettings().ref())); + loadInfoArgs.overriddenFingerprintingSettings().ref()); } nsCOMPtr cspToInherit; @@ -955,13 +955,13 @@ void LoadInfoToParentLoadInfoForwarder( aLoadInfo->GetIsThirdPartyContextToTopWindow()); } - Maybe overriddenFingerprintingSettingsArg; - Maybe overriddenFingerprintingSettings = + Maybe overriddenFingerprintingSettingsArg; + Maybe overriddenFingerprintingSettings = aLoadInfo->GetOverriddenFingerprintingSettings(); if (overriddenFingerprintingSettings) { overriddenFingerprintingSettingsArg = - Some(uint64_t(overriddenFingerprintingSettings.ref())); + Some(overriddenFingerprintingSettings.ref()); } *aForwarderArgsOut = ParentLoadInfoForwarderArgs( @@ -1081,11 +1081,11 @@ nsresult MergeParentLoadInfoForwarder( rv = aLoadInfo->SetIsMetaRefresh(aForwarderArgs.isMetaRefresh()); NS_ENSURE_SUCCESS(rv, rv); - const Maybe overriddenFingerprintingSettings = + const Maybe overriddenFingerprintingSettings = aForwarderArgs.overriddenFingerprintingSettings(); if (overriddenFingerprintingSettings.isSome()) { aLoadInfo->SetOverriddenFingerprintingSettings( - RFPTarget(overriddenFingerprintingSettings.ref())); + overriddenFingerprintingSettings.ref()); } static_cast(aLoadInfo)->ClearIsThirdPartyContextToTopWindow(); diff --git a/mfbt/BitSet.h b/mfbt/BitSet.h index 7c1ac33efdd6..7d8354e44527 100644 --- a/mfbt/BitSet.h +++ b/mfbt/BitSet.h @@ -56,7 +56,7 @@ class BitSet { return *this; } - MOZ_IMPLICIT operator bool() const { return mBitSet.Test(mPos); } + MOZ_IMPLICIT operator bool() const { return mBitSet.test(mPos); } private: BitSet& mBitSet; @@ -76,9 +76,9 @@ class BitSet { PodCopy(mStorage.begin(), aStorage.Elements(), kNumWords); } - static constexpr size_t Size() { return N; } + static constexpr size_t size() { return N; } - constexpr bool Test(size_t aPos) const { + constexpr bool test(size_t aPos) const { MOZ_ASSERT(aPos < N); return mStorage[aPos / kBitsPerWord] & (Word(1) << (aPos % kBitsPerWord)); } @@ -94,7 +94,7 @@ class BitSet { explicit constexpr operator bool() { return !IsEmpty(); } - constexpr bool operator[](size_t aPos) const { return Test(aPos); } + constexpr bool operator[](size_t aPos) const { return test(aPos); } Reference operator[](size_t aPos) { MOZ_ASSERT(aPos < N); @@ -193,7 +193,7 @@ class BitSet { return wordIndex * kBitsPerWord + pos; } - size_t FindLast() const { return FindPrev(Size() - 1); } + size_t FindLast() const { return FindPrev(size() - 1); } // Return the position of the previous bit set starting from |aFromPos| // inclusive, or SIZE_MAX if none. diff --git a/mfbt/EnumSet.h b/mfbt/EnumSet.h index 15b149ccf26b..c9bc82d1da73 100644 --- a/mfbt/EnumSet.h +++ b/mfbt/EnumSet.h @@ -52,6 +52,8 @@ class EnumSet { } } + constexpr explicit EnumSet(Serialized aValue) : mBitField(aValue) {} + #ifdef DEBUG constexpr EnumSet(const EnumSet& aEnumSet) : mBitField(aEnumSet.mBitField) {} @@ -321,7 +323,12 @@ class EnumSet { } constexpr bool HasBitAt(size_t aPos) const { - return static_cast(mBitField & BitAt(aPos)); + if constexpr (std::is_unsigned_v) { + return mBitField & BitAt(aPos); + } else { + // for std::bitset and mozilla::BitSet + return mBitField.test(aPos); + } } constexpr void IncVersion() { @@ -334,7 +341,7 @@ class EnumSet { if constexpr (std::is_unsigned_v) { return sizeof(Serialized) * 8; } else { - return Serialized::Size(); + return Serialized().size(); } } diff --git a/mfbt/tests/TestBitSet.cpp b/mfbt/tests/TestBitSet.cpp index 6eb38819b7b9..9c2f9d5d8efe 100644 --- a/mfbt/tests/TestBitSet.cpp +++ b/mfbt/tests/TestBitSet.cpp @@ -67,28 +67,28 @@ class BitSetSuite { void testSetBit() { TestBitSet bitset; - MOZ_RELEASE_ASSERT(!bitset.Test(3)); + MOZ_RELEASE_ASSERT(!bitset.test(3)); MOZ_RELEASE_ASSERT(!bitset[3]); - MOZ_RELEASE_ASSERT(!bitset.Test(kBitsPerWord + 1)); + MOZ_RELEASE_ASSERT(!bitset.test(kBitsPerWord + 1)); MOZ_RELEASE_ASSERT(!bitset[kBitsPerWord + 1]); bitset[3] = true; - MOZ_RELEASE_ASSERT(bitset.Test(3)); + MOZ_RELEASE_ASSERT(bitset.test(3)); MOZ_RELEASE_ASSERT(bitset[3]); bitset[kBitsPerWord + 1] = true; - MOZ_RELEASE_ASSERT(bitset.Test(3)); + MOZ_RELEASE_ASSERT(bitset.test(3)); MOZ_RELEASE_ASSERT(bitset[3]); - MOZ_RELEASE_ASSERT(bitset.Test(kBitsPerWord + 1)); + MOZ_RELEASE_ASSERT(bitset.test(kBitsPerWord + 1)); MOZ_RELEASE_ASSERT(bitset[kBitsPerWord + 1]); bitset.ResetAll(); - for (size_t i = 0; i < decltype(bitset)::Size(); i++) { + for (size_t i = 0; i < decltype(bitset)::size(); i++) { MOZ_RELEASE_ASSERT(!bitset[i]); } bitset.SetAll(); - for (size_t i = 0; i < decltype(bitset)::Size(); i++) { + for (size_t i = 0; i < decltype(bitset)::size(); i++) { MOZ_RELEASE_ASSERT(bitset[i]); } @@ -96,14 +96,14 @@ class BitSetSuite { MOZ_RELEASE_ASSERT(bitset.Storage()[1] == 3); bitset.ResetAll(); - for (size_t i = 0; i < decltype(bitset)::Size(); i++) { + for (size_t i = 0; i < decltype(bitset)::size(); i++) { MOZ_RELEASE_ASSERT(!bitset[i]); } } void testFindBits() { TestBitSet bitset; - size_t size = bitset.Size(); + size_t size = bitset.size(); MOZ_RELEASE_ASSERT(bitset.IsEmpty()); MOZ_RELEASE_ASSERT(bitset.FindFirst() == SIZE_MAX); MOZ_RELEASE_ASSERT(bitset.FindLast() == SIZE_MAX); diff --git a/netwerk/base/LoadInfo.cpp b/netwerk/base/LoadInfo.cpp index ad29fd59ce22..1ec2c6419320 100644 --- a/netwerk/base/LoadInfo.cpp +++ b/netwerk/base/LoadInfo.cpp @@ -739,7 +739,7 @@ LoadInfo::LoadInfo( bool aIsSameDocumentNavigation, bool aAllowDeprecatedSystemRequests, bool aIsInDevToolsContext, bool aParserCreatedScript, nsILoadInfo::StoragePermissionState aStoragePermission, - const Maybe& aOverriddenFingerprintingSettings, + const Maybe& aOverriddenFingerprintingSettings, bool aIsMetaRefresh, uint32_t aRequestBlockingReason, nsINode* aLoadingContext, nsILoadInfo::CrossOriginEmbedderPolicy aLoadingEmbedderPolicy, @@ -1227,7 +1227,7 @@ LoadInfo::SetStoragePermission( return NS_OK; } -const Maybe& LoadInfo::GetOverriddenFingerprintingSettings() { +const Maybe& LoadInfo::GetOverriddenFingerprintingSettings() { #ifdef DEBUG RefPtr browsingContext; GetTargetBrowsingContext(getter_AddRefs(browsingContext)); @@ -1241,7 +1241,7 @@ const Maybe& LoadInfo::GetOverriddenFingerprintingSettings() { return mOverriddenFingerprintingSettings; } -void LoadInfo::SetOverriddenFingerprintingSettings(RFPTarget aTargets) { +void LoadInfo::SetOverriddenFingerprintingSettings(RFPTargetSet aTargets) { mOverriddenFingerprintingSettings.reset(); mOverriddenFingerprintingSettings.emplace(aTargets); } diff --git a/netwerk/base/LoadInfo.h b/netwerk/base/LoadInfo.h index f60239c50e74..93cc8d3630f7 100644 --- a/netwerk/base/LoadInfo.h +++ b/netwerk/base/LoadInfo.h @@ -253,7 +253,7 @@ class LoadInfo final : public nsILoadInfo { bool aIsSameDocumentNavigation, bool aAllowDeprecatedSystemRequests, bool aIsInDevToolsContext, bool aParserCreatedScript, nsILoadInfo::StoragePermissionState aStoragePermission, - const Maybe& aOverriddenFingerprintingSettings, + const Maybe& aOverriddenFingerprintingSettings, bool aIsMetaRefresh, uint32_t aRequestBlockingReason, nsINode* aLoadingContext, nsILoadInfo::CrossOriginEmbedderPolicy aLoadingEmbedderPolicy, @@ -381,7 +381,7 @@ class LoadInfo final : public nsILoadInfo { bool mParserCreatedScript = false; nsILoadInfo::StoragePermissionState mStoragePermission = nsILoadInfo::NoStoragePermission; - Maybe mOverriddenFingerprintingSettings; + Maybe mOverriddenFingerprintingSettings; #ifdef DEBUG // A boolean used to ensure the mOverriddenFingerprintingSettings is set // before use it. diff --git a/netwerk/base/TRRLoadInfo.cpp b/netwerk/base/TRRLoadInfo.cpp index f5b5b7888e61..d1650595f8cf 100644 --- a/netwerk/base/TRRLoadInfo.cpp +++ b/netwerk/base/TRRLoadInfo.cpp @@ -208,11 +208,11 @@ TRRLoadInfo::SetStoragePermission( return NS_ERROR_NOT_IMPLEMENTED; } -const Maybe& TRRLoadInfo::GetOverriddenFingerprintingSettings() { +const Maybe& TRRLoadInfo::GetOverriddenFingerprintingSettings() { return mOverriddenFingerprintingSettings; } -void TRRLoadInfo::SetOverriddenFingerprintingSettings(RFPTarget aTargets) {} +void TRRLoadInfo::SetOverriddenFingerprintingSettings(RFPTargetSet aTargets) {} NS_IMETHODIMP TRRLoadInfo::GetIsMetaRefresh(bool* aResult) { diff --git a/netwerk/base/TRRLoadInfo.h b/netwerk/base/TRRLoadInfo.h index 2e08abe1007b..25f588c96f4e 100644 --- a/netwerk/base/TRRLoadInfo.h +++ b/netwerk/base/TRRLoadInfo.h @@ -45,7 +45,7 @@ class TRRLoadInfo final : public nsILoadInfo { Maybe mReservedClientInfo; Maybe mInitialClientInfo; Maybe mController; - Maybe mOverriddenFingerprintingSettings; + Maybe mOverriddenFingerprintingSettings; }; } // namespace net diff --git a/netwerk/base/nsILoadInfo.idl b/netwerk/base/nsILoadInfo.idl index 02235ecd351c..774ec045c0b1 100644 --- a/netwerk/base/nsILoadInfo.idl +++ b/netwerk/base/nsILoadInfo.idl @@ -53,8 +53,8 @@ native OriginAttributes(mozilla::OriginAttributes); [ref] native const_MaybeClientInfoRef(const mozilla::Maybe); [ref] native const_ServiceWorkerDescriptorRef(const mozilla::dom::ServiceWorkerDescriptor); [ref] native const_MaybeServiceWorkerDescriptorRef(const mozilla::Maybe); -[ref] native const_MaybeRFPTarget(const mozilla::Maybe); - native RFPTarget(mozilla::RFPTarget); +[ref] native const_MaybeRFPTargetSet(const mozilla::Maybe); + native RFPTargetSet(mozilla::RFPTargetSet); [ptr] native PerformanceStoragePtr(mozilla::dom::PerformanceStorage); native LoadTainting(mozilla::LoadTainting); native CSPRef(already_AddRefed); @@ -651,13 +651,13 @@ interface nsILoadInfo : nsISupports * The RFPTarget defined in the RFPTargets.inc. */ [noscript, nostdcall, notxpcom] - const_MaybeRFPTarget GetOverriddenFingerprintingSettings(); + const_MaybeRFPTargetSet GetOverriddenFingerprintingSettings(); /** * Set the granular overrides of fingerprinting protections for the channel. */ [noscript, nostdcall, notxpcom] - void SetOverriddenFingerprintingSettings(in RFPTarget aTargets); + void SetOverriddenFingerprintingSettings(in RFPTargetSet aTargets); /** * True if the load was triggered by a meta refresh. diff --git a/netwerk/ipc/NeckoChannelParams.ipdlh b/netwerk/ipc/NeckoChannelParams.ipdlh index 66382beedfbc..0924673e59d4 100644 --- a/netwerk/ipc/NeckoChannelParams.ipdlh +++ b/netwerk/ipc/NeckoChannelParams.ipdlh @@ -44,6 +44,7 @@ using mozilla::dom::FeaturePolicyInfo from "mozilla/dom/FeaturePolicy.h"; using nsILoadInfo::HTTPSUpgradeTelemetryType from "nsILoadInfo.h"; using nsILoadInfo::SchemelessInputType from "nsILoadInfo.h"; using mozilla::dom::UserNavigationInvolvement from "mozilla/dom/UserNavigationInvolvement.h"; +using mozilla::RFPTargetSet from "nsRFPService.h"; namespace mozilla { namespace net { @@ -195,7 +196,7 @@ struct LoadInfoArgs uint32_t requestBlockingReason; CSPInfo? cspToInheritInfo; StoragePermissionState storagePermission; - uint64_t? overriddenFingerprintingSettings; + RFPTargetSet? overriddenFingerprintingSettings; bool isMetaRefresh; CrossOriginEmbedderPolicy loadingEmbedderPolicy; bool originTrialCoepCredentiallessEnabledForTopLevel; @@ -286,7 +287,7 @@ struct ParentLoadInfoForwarderArgs StoragePermissionState storagePermission; - uint64_t? overriddenFingerprintingSettings; + RFPTargetSet? overriddenFingerprintingSettings; bool isMetaRefresh; diff --git a/toolkit/components/antitracking/AntiTrackingUtils.cpp b/toolkit/components/antitracking/AntiTrackingUtils.cpp index 592716d4d08f..11a9c26f48e0 100644 --- a/toolkit/components/antitracking/AntiTrackingUtils.cpp +++ b/toolkit/components/antitracking/AntiTrackingUtils.cpp @@ -1111,7 +1111,7 @@ void AntiTrackingUtils::UpdateAntiTrackingInfoForChannel(nsIChannel* aChannel) { // Note that we need to put this after computing the IsThirdPartyToTopWindow // flag because it will be used when getting the granular fingerprinting // protections. - Maybe overriddenFingerprintingSettings = + Maybe overriddenFingerprintingSettings = nsRFPService::GetOverriddenFingerprintingSettingsForChannel(aChannel); if (overriddenFingerprintingSettings) { diff --git a/toolkit/components/resistfingerprinting/RFPTargetIPCUtils.h b/toolkit/components/resistfingerprinting/RFPTargetIPCUtils.h deleted file mode 100644 index 414aa949054d..000000000000 --- a/toolkit/components/resistfingerprinting/RFPTargetIPCUtils.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- 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 https://mozilla.org/MPL/2.0/. */ - -#ifndef __RFPTargetIPCUtils_h__ -#define __RFPTargetIPCUtils_h__ - -#include "ipc/EnumSerializer.h" - -#include "nsRFPService.h" - -namespace IPC { - -template <> -struct ParamTraits - : BitFlagsEnumSerializer {}; - -} // namespace IPC - -#endif // __RFPTargetIPCUtils_h__ diff --git a/toolkit/components/resistfingerprinting/RFPTargets.inc b/toolkit/components/resistfingerprinting/RFPTargets.inc index a6e499e79ebd..bc327e7cbcd6 100644 --- a/toolkit/components/resistfingerprinting/RFPTargets.inc +++ b/toolkit/components/resistfingerprinting/RFPTargets.inc @@ -5,95 +5,95 @@ // Names should not be re-used. -ITEM_VALUE(TouchEvents, 1llu << 0) -ITEM_VALUE(PointerEvents, 1llu << 1) -ITEM_VALUE(KeyboardEvents, 1llu << 2) -ITEM_VALUE(ScreenOrientation, 1llu << 3) +ITEM_VALUE(TouchEvents, 1) +ITEM_VALUE(PointerEvents, 2) +ITEM_VALUE(KeyboardEvents, 3) +ITEM_VALUE(ScreenOrientation, 4) // SpeechSynthesis part of the Web Speech API -ITEM_VALUE(SpeechSynthesis, 1llu << 4) +ITEM_VALUE(SpeechSynthesis, 5) // `prefers-color-scheme` CSS media feature -ITEM_VALUE(CSSPrefersColorScheme, 1llu << 5) +ITEM_VALUE(CSSPrefersColorScheme, 6) // `prefers-reduced-motion` CSS media feature -ITEM_VALUE(CSSPrefersReducedMotion, 1llu << 6) +ITEM_VALUE(CSSPrefersReducedMotion, 7) // `prefers-contrast` CSS media feature -ITEM_VALUE(CSSPrefersContrast, 1llu << 7) +ITEM_VALUE(CSSPrefersContrast, 8) // Add random noises to image data extracted from canvas. -ITEM_VALUE(CanvasRandomization, 1llu << 8) +ITEM_VALUE(CanvasRandomization, 9) // Canvas targets: For unusual combinations of these, see comments // in IsImageExtractionAllowed -ITEM_VALUE(CanvasImageExtractionPrompt, 1llu << 9) -ITEM_VALUE(CanvasExtractionFromThirdPartiesIsBlocked, 1llu << 10) -ITEM_VALUE(CanvasExtractionBeforeUserInputIsBlocked, 1llu << 11) +ITEM_VALUE(CanvasImageExtractionPrompt, 10) +ITEM_VALUE(CanvasExtractionFromThirdPartiesIsBlocked, 11) +ITEM_VALUE(CanvasExtractionBeforeUserInputIsBlocked, 12) -ITEM_VALUE(JSLocale, 1llu << 12) +ITEM_VALUE(JSLocale, 13) // Various "client identification" values of the navigator object -ITEM_VALUE(NavigatorAppVersion, 1llu << 13) -ITEM_VALUE(NavigatorBuildID, 1llu << 14) -ITEM_VALUE(NavigatorHWConcurrency, 1llu << 15) -ITEM_VALUE(NavigatorOscpu, 1llu << 16) -ITEM_VALUE(NavigatorPlatform, 1llu << 17) -ITEM_VALUE(NavigatorUserAgent, 1llu << 18) -ITEM_VALUE(PointerId, 1llu << 19) -ITEM_VALUE(StreamVideoFacingMode, 1llu << 20) -ITEM_VALUE(JSDateTimeUTC, 1llu << 21) -ITEM_VALUE(JSMathFdlibm, 1llu << 22) -ITEM_VALUE(Gamepad, 1llu << 23) -ITEM_VALUE(HttpUserAgent, 1llu << 24) -ITEM_VALUE(WindowOuterSize, 1llu << 25) -ITEM_VALUE(WindowScreenXY, 1llu << 26) -ITEM_VALUE(WindowInnerScreenXY, 1llu << 27) -ITEM_VALUE(ScreenPixelDepth, 1llu << 28) -ITEM_VALUE(ScreenRect, 1llu << 29) -ITEM_VALUE(ScreenAvailRect, 1llu << 30) +ITEM_VALUE(NavigatorAppVersion, 14) +ITEM_VALUE(NavigatorBuildID, 15) +ITEM_VALUE(NavigatorHWConcurrency, 16) +ITEM_VALUE(NavigatorOscpu, 17) +ITEM_VALUE(NavigatorPlatform, 18) +ITEM_VALUE(NavigatorUserAgent, 19) +ITEM_VALUE(PointerId, 20) +ITEM_VALUE(StreamVideoFacingMode, 21) +ITEM_VALUE(JSDateTimeUTC, 22) +ITEM_VALUE(JSMathFdlibm, 23) +ITEM_VALUE(Gamepad, 24) +ITEM_VALUE(HttpUserAgent, 25) +ITEM_VALUE(WindowOuterSize, 26) +ITEM_VALUE(WindowScreenXY, 27) +ITEM_VALUE(WindowInnerScreenXY, 28) +ITEM_VALUE(ScreenPixelDepth, 29) +ITEM_VALUE(ScreenRect, 30) +ITEM_VALUE(ScreenAvailRect, 31) // HTMLVideoElement // mozParsedFrames, mozDecodedFrames, mozPresentedFrames, mozPaintedFrames -ITEM_VALUE(VideoElementMozFrames, 1llu << 31) +ITEM_VALUE(VideoElementMozFrames, 32) // mozFrameDelay -ITEM_VALUE(VideoElementMozFrameDelay, 1llu << 32) +ITEM_VALUE(VideoElementMozFrameDelay, 33) // getVideoPlaybackQuality() -ITEM_VALUE(VideoElementPlaybackQuality, 1llu << 33) +ITEM_VALUE(VideoElementPlaybackQuality, 34) // See also Reduce Timer Precision (RTP) Caller Type -ITEM_VALUE(ReduceTimerPrecision, 1llu << 34) +ITEM_VALUE(ReduceTimerPrecision, 35) // Hide keyboard and pointer WidgetEvents -ITEM_VALUE(WidgetEvents, 1llu << 35) -ITEM_VALUE(MediaDevices, 1llu << 36) -ITEM_VALUE(MediaCapabilities, 1llu << 37) -ITEM_VALUE(AudioSampleRate, 1llu << 38) -ITEM_VALUE(NavigatorConnection, 1llu << 39) -ITEM_VALUE(WindowDevicePixelRatio, 1llu << 40) -ITEM_VALUE(MouseEventScreenPoint, 1llu << 41) +ITEM_VALUE(WidgetEvents, 36) +ITEM_VALUE(MediaDevices, 37) +ITEM_VALUE(MediaCapabilities, 38) +ITEM_VALUE(AudioSampleRate, 39) +ITEM_VALUE(NavigatorConnection, 40) +ITEM_VALUE(WindowDevicePixelRatio, 41) +ITEM_VALUE(MouseEventScreenPoint, 42) // Visibility level of font families available to CSS font-matching -ITEM_VALUE(FontVisibilityBaseSystem, 1llu << 42) -ITEM_VALUE(FontVisibilityLangPack, 1llu << 43) -ITEM_VALUE(DeviceSensors, 1llu << 44) -ITEM_VALUE(FrameRate, 1llu << 45) -ITEM_VALUE(RoundWindowSize, 1llu << 46) -ITEM_VALUE(UseStandinsForNativeColors, 1llu << 47) -ITEM_VALUE(AudioContext, 1llu << 48) -ITEM_VALUE(MediaError, 1llu << 49) -ITEM_VALUE(DOMStyleOsxFontSmoothing, 1llu << 50) +ITEM_VALUE(FontVisibilityBaseSystem, 43) +ITEM_VALUE(FontVisibilityLangPack, 44) +ITEM_VALUE(DeviceSensors, 45) +ITEM_VALUE(FrameRate, 46) +ITEM_VALUE(RoundWindowSize, 47) +ITEM_VALUE(UseStandinsForNativeColors, 48) +ITEM_VALUE(AudioContext, 49) +ITEM_VALUE(MediaError, 50) +ITEM_VALUE(DOMStyleOsxFontSmoothing, 51) // `device-height`/`device-width` CSS media features -ITEM_VALUE(CSSDeviceSize, 1llu << 51) +ITEM_VALUE(CSSDeviceSize, 52) // `color`/`color-gamut` CSS media features -ITEM_VALUE(CSSColorInfo, 1llu << 52) +ITEM_VALUE(CSSColorInfo, 53) // `resolution` CSS media feature -ITEM_VALUE(CSSResolution, 1llu << 53) +ITEM_VALUE(CSSResolution, 54) // `prefers-reduced-transparency` CSS media feature -ITEM_VALUE(CSSPrefersReducedTransparency, 1llu << 54) +ITEM_VALUE(CSSPrefersReducedTransparency, 55) // `inverted-colors` CSS media feature -ITEM_VALUE(CSSInvertedColors, 1llu << 55) +ITEM_VALUE(CSSInvertedColors, 56) // `video-dynamic-range` CSS media feature -ITEM_VALUE(CSSVideoDynamicRange, 1llu << 56) -ITEM_VALUE(CSSPointerCapabilities, 1llu << 57) +ITEM_VALUE(CSSVideoDynamicRange, 57) +ITEM_VALUE(CSSPointerCapabilities, 58) // WebGL -ITEM_VALUE(WebGLRenderCapability, 1llu << 58) -ITEM_VALUE(WebGLRenderInfo, 1llu << 59) -ITEM_VALUE(SiteSpecificZoom, 1llu << 60) +ITEM_VALUE(WebGLRenderCapability, 59) +ITEM_VALUE(WebGLRenderInfo, 60) +ITEM_VALUE(SiteSpecificZoom, 61) // Are font visibility restrictions applied when resolving a CSS ? // (This may block the fonts selected in Preferences from actually being used.) -ITEM_VALUE(FontVisibilityRestrictGenerics, 1llu << 61) -ITEM_VALUE(WebVTT, 1llu << 62) +ITEM_VALUE(FontVisibilityRestrictGenerics, 62) +ITEM_VALUE(WebVTT, 63) // !!! Don't forget to update kDefaultFingerprintingProtections in nsRFPService.cpp // if necessary. @@ -103,7 +103,7 @@ ITEM_VALUE(WebVTT, 1llu << 62) * (This saves us more computation and casting later.) This document will still * need to check whether an individual target is allowed, but the initial * question of "Does this document have any RFP applied to it ever?" can still - * be precomputed. This enum value will always be included in RFPLite, so when a + * be precomputed. This enum value will always be included in FPP, so when a * document asks if they might have RFP enabled, it will return true. (Putting * this value in the overrides pref is undefined behavior and may do anything.) */ @@ -119,4 +119,4 @@ ITEM_VALUE(IsAlwaysEnabledForPrecompute, 0) * +AllTargets,-CSSPrefersColorScheme * -AllTargets,+Gamepad */ -ITEM_VALUE(AllTargets, 0xFFFFFFFF'FFFFFFFF) +ITEM_VALUE(AllTargets, 127) diff --git a/toolkit/components/resistfingerprinting/components.conf b/toolkit/components/resistfingerprinting/components.conf index d7a5f715780c..25ace328c3d0 100644 --- a/toolkit/components/resistfingerprinting/components.conf +++ b/toolkit/components/resistfingerprinting/components.conf @@ -41,4 +41,10 @@ Classes = [ 'constructor': 'UserCharacteristicsPageService', 'processes': ProcessSelector.MAIN_PROCESS_ONLY, }, + { + 'cid': '{6c072f47-f25c-484f-add8-051b07789593}', + 'type': 'mozilla::nsRFPTargetSetIDL', + 'interfaces': ['nsIRFPTargetSetIDL'], + 'headers': ['/toolkit/components/resistfingerprinting/nsRFPTargetSetIDL.h'], + }, ] diff --git a/toolkit/components/resistfingerprinting/extract_rfp_targets.py b/toolkit/components/resistfingerprinting/extract_rfp_targets.py index 34295f5f5007..8018da9be244 100644 --- a/toolkit/components/resistfingerprinting/extract_rfp_targets.py +++ b/toolkit/components/resistfingerprinting/extract_rfp_targets.py @@ -38,8 +38,7 @@ def parse_targets(path): targets = {} for match in pattern.finditer(contents): target = match.group(1) - value = match.group(2).replace("llu", "").replace("'", "") - value = value.split(" << ") + value = match.group(2) targets[target] = value return targets @@ -49,15 +48,7 @@ def write_targets(output, targets): output.write("export const Targets = {\n") for target, value in targets.items(): target_w_padding = f'\t"{target}":'.ljust(45) - if len(value) == 2: - # value is in the format 1 << n = ["1", "n"] - output.write( - f"{target_w_padding} BigInt({value[0]}) << BigInt({value[1]}),\n" - ) - else: - # value is in the format 0xFFFF... = ["0xffff"] - output.write(f'{target_w_padding} BigInt("{value[0]}"),\n') - + output.write(f"{target_w_padding} {value},\n") output.write("}\n") diff --git a/toolkit/components/resistfingerprinting/moz.build b/toolkit/components/resistfingerprinting/moz.build index 6958abe37f59..ec8b14800ae5 100644 --- a/toolkit/components/resistfingerprinting/moz.build +++ b/toolkit/components/resistfingerprinting/moz.build @@ -13,6 +13,7 @@ JAR_MANIFESTS += ["jar.mn"] UNIFIED_SOURCES += [ "nsRFPService.cpp", + "nsRFPTargetSetIDL.cpp", "RelativeTimeline.cpp", ] # Because nsUserCharacteristics doesn't `use namespace mozilla` (because we're going to wind @@ -31,10 +32,14 @@ SPHINX_TREES["resistfingerprinting"] = "docs" FINAL_LIBRARY = "xul" -EXPORTS += ["nsRFPService.h", "nsUserCharacteristics.h", "RFPTargets.inc"] +EXPORTS += [ + "nsRFPService.h", + "nsRFPTargetSetIDL.h", + "nsUserCharacteristics.h", + "RFPTargets.inc", +] EXPORTS.mozilla += [ "RelativeTimeline.h", - "RFPTargetIPCUtils.h", ] EXPORTS.mozilla.gtest += ["nsUserCharacteristics.h"] @@ -54,6 +59,7 @@ XPCOM_MANIFESTS += [ XPIDL_SOURCES += [ "nsIFingerprintingWebCompatService.idl", "nsIRFPService.idl", + "nsIRFPTargetSetIDL.idl", "nsIUserCharacteristicsPageService.idl", ] diff --git a/toolkit/components/resistfingerprinting/nsIRFPService.idl b/toolkit/components/resistfingerprinting/nsIRFPService.idl index 75ffe15b2e24..519db785c739 100644 --- a/toolkit/components/resistfingerprinting/nsIRFPService.idl +++ b/toolkit/components/resistfingerprinting/nsIRFPService.idl @@ -4,6 +4,7 @@ #include "nsISupports.idl" #include "nsIFingerprintingWebCompatService.idl" +#include "nsIRFPTargetSetIDL.idl" interface nsIPrincipal; interface nsIChannel; @@ -32,7 +33,7 @@ interface nsIRFPService : nsISupports * scope. 0 if the overridden scope doesn't exist. * */ - uint64_t getFingerprintingOverrides(in ACString aDomainKey); + nsIRFPTargetSetIDL getFingerprintingOverrides(in ACString aDomainKey); /** * Clean all overrides. This is for testing purpose. @@ -42,7 +43,7 @@ interface nsIRFPService : nsISupports /** * The bitfield of the default enabled RFP Targets. */ - readonly attribute uint64_t enabledFingerprintingProtections; + readonly attribute nsIRFPTargetSetIDL enabledFingerprintingProtections; /** * Clean all fingerprinting randomization keys. diff --git a/toolkit/components/resistfingerprinting/nsIRFPTargetSetIDL.idl b/toolkit/components/resistfingerprinting/nsIRFPTargetSetIDL.idl new file mode 100644 index 000000000000..e19e7ff5918c --- /dev/null +++ b/toolkit/components/resistfingerprinting/nsIRFPTargetSetIDL.idl @@ -0,0 +1,15 @@ +/* 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/. */ + +#include "nsISupports.idl" + +/** + * Used to represent active RFPTargets. + * We used to use uint64_t, but we ran out of bits. + */ +[scriptable, uuid(6c072f47-f25c-484f-add8-051b07789593)] +interface nsIRFPTargetSetIDL : nsISupports { + attribute uint64_t low; + attribute uint64_t high; +}; diff --git a/toolkit/components/resistfingerprinting/nsRFPService.cpp b/toolkit/components/resistfingerprinting/nsRFPService.cpp index 930041916eb4..a59aa98c5477 100644 --- a/toolkit/components/resistfingerprinting/nsRFPService.cpp +++ b/toolkit/components/resistfingerprinting/nsRFPService.cpp @@ -77,6 +77,7 @@ #include "nsTStringRepr.h" #include "nsUserCharacteristics.h" #include "nsXPCOM.h" +#include "nsRFPTargetSetIDL.h" #include "nsICookieJarSettings.h" #include "nsICryptoHash.h" @@ -128,22 +129,22 @@ static constexpr uint32_t kVideoDroppedRatio = 1; // Fingerprinting protections that are enabled by default. This can be // overridden using the privacy.fingerprintingProtection.overrides pref. +// NOLINTBEGIN(bugprone-macro-parentheses) #if defined(MOZ_WIDGET_ANDROID) -// NOLINTNEXTLINE(bugprone-macro-parentheses) -# define ANDROID_DEFAULT(name) RFPTarget::name | +# define ANDROID_DEFAULT(name) RFPTarget::name, # define DESKTOP_DEFAULT(name) #else # define ANDROID_DEFAULT(name) -// NOLINTNEXTLINE(bugprone-macro-parentheses) -# define DESKTOP_DEFAULT(name) RFPTarget::name | +# define DESKTOP_DEFAULT(name) RFPTarget::name, #endif -const RFPTarget kDefaultFingerprintingProtections = +MOZ_RUNINIT const RFPTargetSet kDefaultFingerprintingProtections = { #include "RFPTargetsDefault.inc" - static_cast(0); +}; #undef ANDROID_DEFAULT #undef DESKTOP_DEFAULT +// NOLINTEND(bugprone-macro-parentheses) static constexpr uint32_t kSuspiciousFingerprintingActivityThreshold = 1; @@ -158,7 +159,9 @@ static StaticRefPtr sRFPService; static bool sInitialized = false; // Actually enabled fingerprinting protections. -static Atomic sEnabledFingerprintingProtections; +static StaticMutex sEnabledFingerprintingProtectionsMutex; +MOZ_CONSTINIT static RFPTargetSet sEnabledFingerprintingProtections + MOZ_GUARDED_BY(sEnabledFingerprintingProtectionsMutex); /* static */ already_AddRefed nsRFPService::GetOrCreate() { @@ -299,7 +302,7 @@ bool IsJSContextCurrentlyChromePrivileged() { /* static */ bool nsRFPService::IsRFPEnabledFor( bool aIsPrivateMode, RFPTarget aTarget, - const Maybe& aOverriddenFingerprintingSettings, + const Maybe& aOverriddenFingerprintingSettings, bool aSkipChromePrincipalCheck /* = false */) { MOZ_ASSERT(aTarget != RFPTarget::AllTargets); @@ -331,10 +334,11 @@ bool nsRFPService::IsRFPEnabledFor( } if (aOverriddenFingerprintingSettings) { - return bool(aOverriddenFingerprintingSettings.ref() & aTarget); + return aOverriddenFingerprintingSettings.ref().contains(aTarget); } - return bool(sEnabledFingerprintingProtections & aTarget); + StaticMutexAutoLock lock(sEnabledFingerprintingProtectionsMutex); + return sEnabledFingerprintingProtections.contains(aTarget); } return false; @@ -350,9 +354,10 @@ void nsRFPService::UpdateFPPOverrideList() { return; } - RFPTarget enabled = CreateOverridesFromText( + RFPTargetSet enabled = CreateOverridesFromText( targetOverrides, kDefaultFingerprintingProtections); + StaticMutexAutoLock lock(sEnabledFingerprintingProtectionsMutex); sEnabledFingerprintingProtections = enabled; } @@ -2080,44 +2085,51 @@ nsresult nsRFPService::CreateOverrideDomainKey( } /* static */ -RFPTarget nsRFPService::CreateOverridesFromText(const nsString& aOverridesText, - RFPTarget aBaseOverrides) { - RFPTarget result = aBaseOverrides; +RFPTargetSet nsRFPService::CreateOverridesFromText( + const nsString& aOverridesText, RFPTargetSet aBaseOverrides) { + RFPTargetSet result = aBaseOverrides; for (const nsAString& each : aOverridesText.Split(',')) { Maybe mappedValue = nsRFPService::TextToRFPTarget(Substring(each, 1, each.Length() - 1)); - if (mappedValue.isSome()) { - RFPTarget target = mappedValue.value(); - if (target == RFPTarget::IsAlwaysEnabledForPrecompute) { - MOZ_LOG(gResistFingerprintingLog, LogLevel::Warning, - ("RFPTarget::%s is not a valid value", - NS_ConvertUTF16toUTF8(each).get())); - } else if (each[0] == '+') { - result |= target; - MOZ_LOG(gResistFingerprintingLog, LogLevel::Warning, - ("Mapped value %s (0x%" PRIx64 - "), to an addition, now we have 0x%" PRIx64, - NS_ConvertUTF16toUTF8(each).get(), uint64_t(target), - uint64_t(result))); - } else if (each[0] == '-') { - result &= ~target; - MOZ_LOG(gResistFingerprintingLog, LogLevel::Warning, - ("Mapped value %s (0x%" PRIx64 - ") to a subtraction, now we have 0x%" PRIx64, - NS_ConvertUTF16toUTF8(each).get(), uint64_t(target), - uint64_t(result))); - } else { - MOZ_LOG(gResistFingerprintingLog, LogLevel::Warning, - ("Mapped value %s (0x%" PRIx64 - ") to an RFPTarget Enum, but the first " - "character wasn't + or -", - NS_ConvertUTF16toUTF8(each).get(), uint64_t(target))); - } - } else { + if (mappedValue.isNothing()) { MOZ_LOG(gResistFingerprintingLog, LogLevel::Warning, ("Could not map the value %s to an RFPTarget Enum", NS_ConvertUTF16toUTF8(each).get())); + continue; + } + RFPTarget target = mappedValue.value(); + RFPTargetSet targetSet = RFPTargetSet(target); + if (target == RFPTarget::AllTargets) { + std::bitset<128> allTargets; + allTargets.set(); + targetSet = RFPTargetSet(allTargets); + } + if (target == RFPTarget::IsAlwaysEnabledForPrecompute) { + MOZ_LOG(gResistFingerprintingLog, LogLevel::Warning, + ("RFPTarget::%s is not a valid value", + NS_ConvertUTF16toUTF8(each).get())); + } else if (each[0] == '+') { + result += targetSet; + MOZ_LOG( + gResistFingerprintingLog, LogLevel::Warning, + ("Mapped value %s (0x%" PRIx64 "), to an addition, now we have %s", + NS_ConvertUTF16toUTF8(each).get(), static_cast(target), + result.serialize().to_string().c_str())); + } else if (each[0] == '-') { + result -= targetSet; + MOZ_LOG( + gResistFingerprintingLog, LogLevel::Warning, + ("Mapped value %s (0x%" PRIx64 ") to a subtraction, now we have %s", + NS_ConvertUTF16toUTF8(each).get(), static_cast(target), + result.serialize().to_string().c_str())); + } else { + MOZ_LOG( + gResistFingerprintingLog, LogLevel::Warning, + ("Mapped value %s (0x%" PRIx64 + ") to an RFPTarget Enum, but the first " + "character wasn't + or -", + NS_ConvertUTF16toUTF8(each).get(), static_cast(target))); } } @@ -2144,7 +2156,8 @@ nsRFPService::SetFingerprintingOverrides( rv = fpOverride->GetOverrides(overridesText); NS_ENSURE_SUCCESS(rv, rv); - RFPTarget targets = nsRFPService::CreateOverridesFromText( + StaticMutexAutoLock lock(sEnabledFingerprintingProtectionsMutex); + RFPTargetSet targets = nsRFPService::CreateOverridesFromText( NS_ConvertUTF8toUTF16(overridesText), mFingerprintingOverrides.Contains(domainKey) ? mFingerprintingOverrides.Get(domainKey) @@ -2167,25 +2180,32 @@ nsRFPService::SetFingerprintingOverrides( } NS_IMETHODIMP -nsRFPService::GetEnabledFingerprintingProtections(uint64_t* aProtections) { - RFPTarget enabled = sEnabledFingerprintingProtections; +nsRFPService::GetEnabledFingerprintingProtections( + nsIRFPTargetSetIDL** aProtections) { + StaticMutexAutoLock lock(sEnabledFingerprintingProtectionsMutex); + RFPTargetSet enabled = sEnabledFingerprintingProtections; + + nsCOMPtr protections = new nsRFPTargetSetIDL(enabled); + protections.forget(aProtections); - *aProtections = uint64_t(enabled); return NS_OK; } NS_IMETHODIMP nsRFPService::GetFingerprintingOverrides(const nsACString& aDomainKey, - uint64_t* aOverrides) { + nsIRFPTargetSetIDL** aOverrides) { MOZ_ASSERT(XRE_IsParentProcess()); - Maybe overrides = mFingerprintingOverrides.MaybeGet(aDomainKey); + Maybe overrides = mFingerprintingOverrides.MaybeGet(aDomainKey); if (!overrides) { return NS_ERROR_FAILURE; } - *aOverrides = uint64_t(overrides.ref()); + nsCOMPtr protections = + new nsRFPTargetSetIDL(overrides.ref()); + protections.forget(aOverrides); + return NS_OK; } @@ -2197,7 +2217,7 @@ nsRFPService::CleanAllOverrides() { } /* static */ -Maybe nsRFPService::GetOverriddenFingerprintingSettingsForChannel( +Maybe nsRFPService::GetOverriddenFingerprintingSettingsForChannel( nsIChannel* aChannel) { MOZ_ASSERT(aChannel); MOZ_ASSERT(XRE_IsParentProcess()); @@ -2329,7 +2349,7 @@ Maybe nsRFPService::GetOverriddenFingerprintingSettingsForChannel( } /* static */ -Maybe nsRFPService::GetOverriddenFingerprintingSettingsForURI( +Maybe nsRFPService::GetOverriddenFingerprintingSettingsForURI( nsIURI* aFirstPartyURI, nsIURI* aThirdPartyURI) { MOZ_ASSERT(aFirstPartyURI); MOZ_ASSERT(XRE_IsParentProcess()); @@ -2345,7 +2365,8 @@ Maybe nsRFPService::GetOverriddenFingerprintingSettingsForURI( // scope. // First, we get the overrides that applies to every context. - Maybe result = service->mFingerprintingOverrides.MaybeGet("*"_ns); + Maybe result = + service->mFingerprintingOverrides.MaybeGet("*"_ns); RefPtr eTLDService = nsEffectiveTLDService::GetInstance(); @@ -2373,7 +2394,7 @@ Maybe nsRFPService::GetOverriddenFingerprintingSettingsForURI( key.Append(FP_OVERRIDES_DOMAIN_KEY_DELIMITER); key.Append("*"); - Maybe fpOverrides = + Maybe fpOverrides = service->mFingerprintingOverrides.MaybeGet(key); if (fpOverrides) { result = fpOverrides; @@ -2408,7 +2429,7 @@ Maybe nsRFPService::GetOverriddenFingerprintingSettingsForURI( key.Assign(firstPartyDomain); key.Append(FP_OVERRIDES_DOMAIN_KEY_DELIMITER); key.Append("*"); - Maybe fpOverrides = + Maybe fpOverrides = service->mFingerprintingOverrides.MaybeGet(key); if (fpOverrides) { result = fpOverrides; diff --git a/toolkit/components/resistfingerprinting/nsRFPService.h b/toolkit/components/resistfingerprinting/nsRFPService.h index ad30667dd00d..2eb3ec5afe7c 100644 --- a/toolkit/components/resistfingerprinting/nsRFPService.h +++ b/toolkit/components/resistfingerprinting/nsRFPService.h @@ -8,6 +8,7 @@ #include #include +#include #include "ErrorList.h" #include "PLDHashTable.h" #include "mozilla/BasicEvents.h" @@ -202,7 +203,12 @@ enum class RFPTarget : uint64_t { #undef ITEM_VALUE -MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RFPTarget); +using RFPTargetSet = EnumSet>; + +template <> +struct MaxEnumValue { + static constexpr unsigned int value = 127; +}; // ============================================================================ @@ -221,7 +227,7 @@ class nsRFPService final : public nsIObserver, public nsIRFPService { static bool IsRFPEnabledFor( bool aIsPrivateMode, RFPTarget aTarget, - const Maybe& aOverriddenFingerprintingSettings, + const Maybe& aOverriddenFingerprintingSettings, bool aSkipChromePrincipalCheck = false); static bool IsSystemPrincipalOrAboutFingerprintingProtection(JSContext*, @@ -349,7 +355,7 @@ class nsRFPService final : public nsIObserver, public nsIRFPService { // overrides to replace default enabled RFPTargets for the context of the // channel. The method will return Nothing() to indicate using the default // RFPTargets - static Maybe GetOverriddenFingerprintingSettingsForChannel( + static Maybe GetOverriddenFingerprintingSettingsForChannel( nsIChannel* aChannel); // The method for getting the granular fingerprinting protection override of @@ -357,7 +363,7 @@ class nsRFPService final : public nsIObserver, public nsIRFPService { // overrides if there is one defined for the context of the first-party URI // and third-party URI. Otherwise, it will return Nothing() to indicate using // the default RFPTargets. - static Maybe GetOverriddenFingerprintingSettingsForURI( + static Maybe GetOverriddenFingerprintingSettingsForURI( nsIURI* aFirstPartyURI, nsIURI* aThirdPartyURI); // -------------------------------------------------------------------------- @@ -474,7 +480,7 @@ class nsRFPService final : public nsIObserver, public nsIRFPService { nsTHashMap mBrowsingSessionKeys; nsCOMPtr mWebCompatService; - nsTHashMap mFingerprintingOverrides; + nsTHashMap mFingerprintingOverrides; // A helper function to create the domain key for the fingerprinting // overrides. The key can be in the following five formats. @@ -493,8 +499,9 @@ class nsRFPService final : public nsIObserver, public nsIRFPService { // overrides text and the based overrides bitfield. The function will parse // the text and update the based overrides bitfield accordingly. Then, it will // return the updated bitfield. - static RFPTarget CreateOverridesFromText( - const nsString& aOverridesText, RFPTarget aBaseOverrides = RFPTarget(0)); + static RFPTargetSet CreateOverridesFromText( + const nsString& aOverridesText, + RFPTargetSet aBaseOverrides = RFPTargetSet()); }; } // namespace mozilla diff --git a/toolkit/components/resistfingerprinting/nsRFPTargetSetIDL.cpp b/toolkit/components/resistfingerprinting/nsRFPTargetSetIDL.cpp new file mode 100644 index 000000000000..ac3685245d41 --- /dev/null +++ b/toolkit/components/resistfingerprinting/nsRFPTargetSetIDL.cpp @@ -0,0 +1,46 @@ +/* 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/. */ + +#include "nsRFPTargetSetIDL.h" + +namespace mozilla { + +NS_IMPL_ISUPPORTS(nsRFPTargetSetIDL, nsIRFPTargetSetIDL) + +NS_IMETHODIMP +nsRFPTargetSetIDL::GetLow(uint64_t* aLow) { + std::bitset<128> bitset = mBits.serialize(); + std::bitset<128> mask = std::bitset<128>(0xFFFFFFFFFFFFFFFF); + *aLow = (bitset & mask).to_ullong(); + return NS_OK; +} + +NS_IMETHODIMP +nsRFPTargetSetIDL::GetHigh(uint64_t* aHigh) { + std::bitset<128> bitset = mBits.serialize(); + std::bitset<128> mask = std::bitset<128>(0xFFFFFFFFFFFFFFFF); + *aHigh = ((bitset >> 64) & mask).to_ullong(); + return NS_OK; +} + +NS_IMETHODIMP +nsRFPTargetSetIDL::SetLow(uint64_t aLow) { + std::bitset<128> bitset = mBits.serialize(); + bitset |= aLow; + mBits.deserialize(bitset); + return NS_OK; +} + +NS_IMETHODIMP +nsRFPTargetSetIDL::SetHigh(uint64_t aHigh) { + std::bitset<128> bitset = mBits.serialize(); + std::bitset<128> mask = std::bitset<128>(0xFFFFFFFFFFFFFFFF); + uint64_t low = (bitset & mask).to_ullong(); + bitset = aHigh; + bitset <<= 64; + bitset |= low; + return NS_OK; +} + +} // namespace mozilla diff --git a/toolkit/components/resistfingerprinting/nsRFPTargetSetIDL.h b/toolkit/components/resistfingerprinting/nsRFPTargetSetIDL.h new file mode 100644 index 000000000000..ac933b677280 --- /dev/null +++ b/toolkit/components/resistfingerprinting/nsRFPTargetSetIDL.h @@ -0,0 +1,28 @@ +/* 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 https://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_RFPTargetSetIDL_h__ +#define mozilla_RFPTargetSetIDL_h__ + +#include "nsIRFPTargetSetIDL.h" +#include "nsRFPService.h" + +namespace mozilla { + +class nsRFPTargetSetIDL final : public nsIRFPTargetSetIDL { + NS_DECL_ISUPPORTS + NS_DECL_NSIRFPTARGETSETIDL + + public: + nsRFPTargetSetIDL() = default; + explicit nsRFPTargetSetIDL(RFPTargetSet& aBits) : mBits(aBits) {}; + + private: + ~nsRFPTargetSetIDL() = default; + + RFPTargetSet mBits; +}; +} // namespace mozilla + +#endif // mozilla_RFPTargetSetIDL_h__ diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingRemoteOverrides.js b/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingRemoteOverrides.js index 64efa270d7f0..1699b8728c1d 100644 --- a/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingRemoteOverrides.js +++ b/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingRemoteOverrides.js @@ -13,12 +13,12 @@ const COLLECTION_NAME = "fingerprinting-protection-overrides"; // The javascript bitwise operator only support 32bits. So, we only test // RFPTargets that is under low 32 bits. const TARGET_DEFAULT = extractLow32Bits( - Services.rfp.enabledFingerprintingProtections + Services.rfp.enabledFingerprintingProtections.low ); -const TARGET_PointerEvents = 0x00000002; -const TARGET_CanvasRandomization = 0x000000100; -const TARGET_WindowOuterSize = 0x002000000; -const TARGET_Gamepad = 0x00800000; +const TARGET_PointerEvents = 1 << 2; +const TARGET_CanvasRandomization = 1 << 9; +const TARGET_WindowOuterSize = 1 << 26; +const TARGET_Gamepad = 1 << 24; const TEST_PAGE = getRootDirectory(gTestPath).replace( @@ -309,7 +309,7 @@ add_task(async function test_remote_settings() { // Get the addition and subtraction flags for the domain. try { let overrides = extractLow32Bits( - Services.rfp.getFingerprintingOverrides(expect.domain) + Services.rfp.getFingerprintingOverrides(expect.domain).low ); // Verify if the flags are matching to expected values. @@ -354,7 +354,7 @@ add_task(async function test_remote_settings_pref() { for (let expect of test.expects) { try { // Check for the existance of RFP overrides - Services.rfp.getFingerprintingOverrides(expect.domain); + Services.rfp.getFingerprintingOverrides(expect.domain).low; ok( false, "This line should never run as the override should not exist and the previous line would throw an exception" @@ -392,7 +392,7 @@ add_task(async function test_pref() { try { // Get the addition and subtraction flags for the domain. let overrides = extractLow32Bits( - Services.rfp.getFingerprintingOverrides(expect.domain) + Services.rfp.getFingerprintingOverrides(expect.domain).low ); // Verify if the flags are matching to expected values. @@ -447,7 +447,7 @@ add_task(async function test_pref_override_remote_settings() { // Get the addition and subtraction flags for the domain. let overrides = extractLow32Bits( - Services.rfp.getFingerprintingOverrides("example.org") + Services.rfp.getFingerprintingOverrides("example.org").low ); // Verify if the flags are matching to the pref settings.