diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
commit | a90a5cba08fdf6c0ceb95101c275108a152a3aed (patch) | |
tree | 532507288f3defd7f4dcf1af49698bcb76034855 /toolkit/components/resistfingerprinting | |
parent | Adding debian version 126.0.1-1. (diff) | |
download | firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/resistfingerprinting')
8 files changed, 762 insertions, 155 deletions
diff --git a/toolkit/components/resistfingerprinting/FingerprintingWebCompatService.sys.mjs b/toolkit/components/resistfingerprinting/FingerprintingWebCompatService.sys.mjs index 56f6435e47..676f06ea68 100644 --- a/toolkit/components/resistfingerprinting/FingerprintingWebCompatService.sys.mjs +++ b/toolkit/components/resistfingerprinting/FingerprintingWebCompatService.sys.mjs @@ -49,6 +49,8 @@ const SCHEMA = `{ const COLLECTION_NAME = "fingerprinting-protection-overrides"; const PREF_GRANULAR_OVERRIDES = "privacy.fingerprintingProtection.granularOverrides"; +const PREF_REMOTE_OVERRIDES_ENABLED = + "privacy.fingerprintingProtection.remoteOverrides.enabled"; XPCOMUtils.defineLazyPreferenceGetter( lazy, @@ -56,6 +58,12 @@ XPCOMUtils.defineLazyPreferenceGetter( PREF_GRANULAR_OVERRIDES ); +XPCOMUtils.defineLazyPreferenceGetter( + lazy, + "remoteOverridesEnabled", + PREF_REMOTE_OVERRIDES_ENABLED +); + /** * The object represents a fingerprinting override. */ @@ -195,6 +203,12 @@ export class FingerprintingWebCompatService { #onRemoteUpdate(entries) { lazy.logConsole.debug("onUpdateEntries", { entries }); + + if (!lazy.remoteOverridesEnabled) { + lazy.logConsole.debug("Abort remote overrides"); + return; + } + // Clear all overrides before we update the overrides. this.#remoteOverrides.clear(); diff --git a/toolkit/components/resistfingerprinting/metrics.yaml b/toolkit/components/resistfingerprinting/metrics.yaml index 51b251508c..b5150defd3 100644 --- a/toolkit/components/resistfingerprinting/metrics.yaml +++ b/toolkit/components/resistfingerprinting/metrics.yaml @@ -528,3 +528,527 @@ characteristics: expires: never data_sensitivity: - interaction + + prefs_browser_display_use_document_fonts: # browser.display.use_document_fonts + type: boolean + description: > + Allow pages to choose their own fonts. + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_default_western: # font.default.x-western + type: string + description: > + The value of the font.default.x-western pref + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_default_default_group: # font.default.<default language group> + type: string + description: > + The value of the font.default.<default language group> pref + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_default_modified: + type: quantity + unit: int + description: > + The number of other modified font.default prefs. + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_name_serif_western: # font.name.serif.x-western + type: string + description: > + The value of the font.name.serif.x-western pref + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_name_serif_default_group: # font.name.serif.<default language group> + type: string + description: > + The value of the font.name.serif.<default language group> pref + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_name_serif_modified: + type: quantity + unit: int + description: > + The number of other modified font.name.serif prefs. + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_name_sans_serif_western: # font.name.sans-serif.x-western + type: string + description: > + The value of the font.name.sans-serif.x-western pref + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_name_sans_serif_default_group: # font.name.sans-serif.<default language group> + type: string + description: > + The value of the font.name.sans-serif.<default language group> pref + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_name_sans_serif_modified: + type: quantity + unit: int + description: > + The number of other modified font.name.sans-serif prefs. + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_name_monospace_western: # font.name.monospace.x-western + type: string + description: > + The value of the font.name.monospace.x-western pref + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_name_monospace_default_group: # font.name.monospace.<default language group> + type: string + description: > + The value of the font.name.monospace.<default language group> pref + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_name_monospace_modified: + type: quantity + unit: int + description: > + The number of other modified font.name.monospace prefs. + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_size_variable_western: # font.size.variable.x-western + type: string + description: > + The value of the font.size.variable.x-western pref + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_size_variable_default_group: # font.size.variable.<default language group> + type: string + description: > + The value of the font.size.variable.<default language group> pref + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_size_variable_modified: + type: quantity + unit: int + description: > + The number of other modified font.size.variable prefs. + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_size_monospace_western: # font.size.monospace.x-western + type: string + description: > + The value of the font.size.monospace.x-western pref + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_size_monospace_default_group: # font.size.monospace.<default language group> + type: string + description: > + The value of the font.size.monospace.<default language group> pref + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_size_monospace_modified: + type: quantity + unit: int + description: > + The number of other modified font.size.monospace prefs. + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_minimum_size_western: # font.minimum-size.x-western + type: string + description: > + The value of the font.minimum-size.x-western pref + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_minimum_size_default_group: # font.minimum-size.<default language group> + type: string + description: > + The value of the font.minimum-size.<default language group> pref + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_minimum_size_modified: + type: quantity + unit: int + description: > + The number of other modified font.minimum-size prefs. + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_name_list_serif_modified: + type: quantity + unit: int + description: > + The number of modified font.name-list.serif. prefs. + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_name_list_sans_serif_modified: + type: quantity + unit: int + description: > + The number of modified font.name-list.sans-serif. prefs. + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_name_list_monospace_modified: + type: quantity + unit: int + description: > + The number of modified font.name-list.monospace. prefs. + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_name_list_cursive_modified: + type: quantity + unit: int + description: > + The number of modified font.name-list.cursive. prefs. + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_name_list_cursive_modified: + type: quantity + unit: int + description: > + The number of modified font.name-list.cursive. prefs. + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_name_list_emoji_modified: + type: quantity + unit: int + description: > + The number of modified font.name-list.cursive. prefs. + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + font_name_list_emoji_modified: + type: boolean + description: > + Whether the pref font.name-list.emoji was modified. + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1887658#c4 + expires: never + data_sensitivity: + - interaction + + prefs_network_cookie_cookiebehavior: # network.cookie.cookieBehavior + type: quantity + unit: int + description: > + Value of the network.cookie.cookieBehavior pref. + lifetime: application + send_in_pings: + - user-characteristics + notification_emails: + - tom@mozilla.com + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1892474 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1852340#c16 + expires: never + data_sensitivity: + - interaction diff --git a/toolkit/components/resistfingerprinting/nsRFPService.cpp b/toolkit/components/resistfingerprinting/nsRFPService.cpp index f39deb3283..34c34a2496 100644 --- a/toolkit/components/resistfingerprinting/nsRFPService.cpp +++ b/toolkit/components/resistfingerprinting/nsRFPService.cpp @@ -100,6 +100,8 @@ static mozilla::LazyLogModule gResistFingerprintingLog( static mozilla::LazyLogModule gFingerprinterDetection("FingerprinterDetection"); +static mozilla::LazyLogModule gTimestamps("Timestamps"); + #define RESIST_FINGERPRINTINGPROTECTION_OVERRIDE_PREF \ "privacy.fingerprintingProtection.overrides" #define GLEAN_DATA_SUBMISSION_PREF "datareporting.healthreport.uploadEnabled" @@ -410,7 +412,7 @@ sec_per_extra_frame = 1 / (extra_frames_per_frame * 60) // 833.33 min_per_extra_frame = sec_per_extra_frame / 60 // 13.89 ``` We expect an extra frame every ~14 minutes, which is enough to be smooth. -16.67 would be ~1.4 minutes, which is OK, but is more noticable. +16.67 would be ~1.4 minutes, which is OK, but is more noticeable. Put another way, if this is the only unacceptable hitch you have across 14 minutes, I'm impressed, and we might revisit this. */ @@ -631,14 +633,13 @@ double nsRFPService::ReduceTimePrecisionImpl(double aTime, TimeScale aTimeScale, nsAutoCString type; TypeToText(aType, type); MOZ_LOG( - gResistFingerprintingLog, LogLevel::Error, + gTimestamps, LogLevel::Error, ("About to assert. aTime=%lli<%lli aContextMixin=%" PRId64 " aType=%s", timeAsInt, kFeb282008, aContextMixin, type.get())); - MOZ_ASSERT( - false, - "ReduceTimePrecisionImpl was given a relative time " - "with an empty context mix-in (or your clock is 10+ years off.) " - "Run this with MOZ_LOG=nsResistFingerprinting:1 to get more details."); + MOZ_ASSERT(false, + "ReduceTimePrecisionImpl was given a relative time " + "with an empty context mix-in (or your clock is 10+ years off.) " + "Run this with MOZ_LOG=Timestamps:1 to get more details."); } // Cast the resolution (in microseconds) to an int. @@ -673,7 +674,7 @@ double nsRFPService::ReduceTimePrecisionImpl(double aTime, TimeScale aTimeScale, double ret = double(clampedAndJittered) / (1000000.0 / double(aTimeScale)); MOZ_LOG( - gResistFingerprintingLog, LogLevel::Verbose, + gTimestamps, LogLevel::Verbose, ("Given: (%.*f, Scaled: %.*f, Converted: %lli), Rounding %s with (%lli, " "Originally %.*f), " "Intermediate: (%lli), Clamped: (%lli) Jitter: (%i Context: %" PRId64 diff --git a/toolkit/components/resistfingerprinting/nsUserCharacteristics.cpp b/toolkit/components/resistfingerprinting/nsUserCharacteristics.cpp index 86de7d61a7..9e3c6c1aaf 100644 --- a/toolkit/components/resistfingerprinting/nsUserCharacteristics.cpp +++ b/toolkit/components/resistfingerprinting/nsUserCharacteristics.cpp @@ -18,9 +18,11 @@ #include "mozilla/Components.h" #include "mozilla/dom/Promise-inl.h" +#include "mozilla/StaticPrefs_browser.h" #include "mozilla/StaticPrefs_dom.h" #include "mozilla/StaticPrefs_general.h" #include "mozilla/StaticPrefs_media.h" +#include "mozilla/StaticPrefs_network.h" #include "mozilla/StaticPrefs_widget.h" #include "mozilla/LookAndFeel.h" @@ -171,6 +173,122 @@ void PopulatePrefs() { glean::characteristics::prefs_block_popups.Set( StaticPrefs::dom_disable_open_during_load()); + + glean::characteristics::prefs_browser_display_use_document_fonts.Set( + mozilla::StaticPrefs::browser_display_use_document_fonts()); + + glean::characteristics::prefs_network_cookie_cookiebehavior.Set( + StaticPrefs::network_cookie_cookieBehavior()); +} + +template <typename StringMetric, typename QuantityMetric> +static void CollectFontPrefValue(nsIPrefBranch* aPrefBranch, + const nsACString& aDefaultLanguageGroup, + const char* aStartingAt, + StringMetric& aWesternMetric, + StringMetric& aDefaultGroupMetric, + QuantityMetric& aModifiedMetric) { + nsTArray<nsCString> prefNames; + if (NS_WARN_IF( + NS_FAILED(aPrefBranch->GetChildList(aStartingAt, prefNames)))) { + return; + } + + nsCString westernPref(aStartingAt); + westernPref.Append("x-western"); + nsCString defaultGroupPref(aStartingAt); + defaultGroupPref.Append(aDefaultLanguageGroup); + + nsAutoCString westernPrefValue; + Preferences::GetCString(westernPref.get(), westernPrefValue); + aWesternMetric.Set(westernPrefValue); + + nsAutoCString defaultGroupPrefValue; + if (!westernPref.Equals(defaultGroupPref)) { + Preferences::GetCString(defaultGroupPref.get(), defaultGroupPrefValue); + } + aDefaultGroupMetric.Set(defaultGroupPrefValue); + + uint32_t modifiedCount = 0; + for (const auto& prefName : prefNames) { + if (!prefName.Equals(westernPref) && !prefName.Equals(defaultGroupPref)) { + if (Preferences::HasUserValue(prefName.get())) { + modifiedCount++; + } + } + } + aModifiedMetric.Set(modifiedCount); +} + +template <typename QuantityMetric> +static void CollectFontPrefModified(nsIPrefBranch* aPrefBranch, + const char* aStartingAt, + QuantityMetric& aModifiedMetric) { + nsTArray<nsCString> prefNames; + if (NS_WARN_IF( + NS_FAILED(aPrefBranch->GetChildList(aStartingAt, prefNames)))) { + return; + } + + uint32_t modifiedCount = 0; + for (const auto& prefName : prefNames) { + if (Preferences::HasUserValue(prefName.get())) { + modifiedCount++; + } + } + aModifiedMetric.Set(modifiedCount); +} + +void PopulateFontPrefs() { + nsIPrefBranch* prefRootBranch = Preferences::GetRootBranch(); + if (!prefRootBranch) { + return; + } + + nsCString defaultLanguageGroup; + Preferences::GetLocalizedCString("font.language.group", defaultLanguageGroup); + +#define FONT_PREF(PREF_NAME, METRIC_NAME) \ + CollectFontPrefValue(prefRootBranch, defaultLanguageGroup, PREF_NAME, \ + glean::characteristics::METRIC_NAME##_western, \ + glean::characteristics::METRIC_NAME##_default_group, \ + glean::characteristics::METRIC_NAME##_modified) + + // The following preferences can be modified using the advanced font options + // on the about:preferences page. Every preference has a sub-branch per + // script, so for example font.default.x-western or font.default.x-cyrillic + // etc. For all of the 7 main preferences, we collect: + // - The value for the x-western branch (if user modified) + // - The value for the current default language group (~ script) based + // on the localized version of Firefox being used. (Only when not x-western) + // - How many /other/ script that are not x-western or the default have been + // modified. + + FONT_PREF("font.default.", font_default); + FONT_PREF("font.name.serif.", font_name_serif); + FONT_PREF("font.name.sans-serif.", font_name_sans_serif); + FONT_PREF("font.name.monospace.", font_name_monospace); + FONT_PREF("font.size.variable.", font_size_variable); + FONT_PREF("font.size.monospace.", font_size_monospace); + FONT_PREF("font.minimum-size.", font_minimum_size); + +#undef FONT_PREF + + CollectFontPrefModified( + prefRootBranch, "font.name-list.serif.", + glean::characteristics::font_name_list_serif_modified); + CollectFontPrefModified( + prefRootBranch, "font.name-list.sans-serif.", + glean::characteristics::font_name_list_sans_serif_modified); + CollectFontPrefModified( + prefRootBranch, "font.name-list.monospace.", + glean::characteristics::font_name_list_monospace_modified); + CollectFontPrefModified( + prefRootBranch, "font.name-list.cursive.", + glean::characteristics::font_name_list_cursive_modified); + // Exceptionally this pref has no variants per-script. + glean::characteristics::font_name_list_emoji_modified.Set( + Preferences::HasUserValue("font.name-list.emoji")); } // ================================================================== @@ -178,7 +296,7 @@ void PopulatePrefs() { // metric is set, this variable should be incremented. It'll be a lot. It's // okay. We're going to need it to know (including during development) what is // the source of the data we are looking at. -const int kSubmissionSchema = 1; +const int kSubmissionSchema = 2; const auto* const kLastVersionPref = "toolkit.telemetry.user_characteristics_ping.last_version_sent"; @@ -304,6 +422,7 @@ void nsUserCharacteristics::PopulateDataAndEventuallySubmit( PopulateCSSProperties(); PopulateScreenProperties(); PopulatePrefs(); + PopulateFontPrefs(); glean::characteristics::target_frame_rate.Set( gfxPlatform::TargetFrameRate()); diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization.js b/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization.js index e526f7fff1..8d78fb29eb 100644 --- a/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization.js +++ b/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization.js @@ -39,29 +39,7 @@ var TEST_CASES = [ return [imageData.data, imageDataSecond.data]; }, - isDataRandomized(name, data1, data2, isCompareOriginal) { - let diffCnt = countDifferencesInUint8Arrays(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - - // The Canvas randomization adds at most 512 bits noise to the image data. - // We compare the image data arrays to see if they are different and the - // difference is within the range. - - // If we are compare two randomized arrays, the difference can be doubled. - let expected = isCompareOriginal - ? NUM_RANDOMIZED_CANVAS_BITS - : NUM_RANDOMIZED_CANVAS_BITS * 2; - - // The number of difference bits should never bigger than the expected - // number. It could be zero if the randomization is disabled. - Assert.lessOrEqual( - diffCnt, - expected, - "The number of noise bits is expected." - ); - - return diffCnt <= expected && diffCnt > 0; - }, + isDataRandomized: isDataRandomizedFuzzy, }, { name: "CanvasRenderingContext2D.getImageData().", @@ -88,29 +66,7 @@ var TEST_CASES = [ return [imageData.data, imageDataSecond.data]; }, - isDataRandomized(name, data1, data2, isCompareOriginal) { - let diffCnt = countDifferencesInUint8Arrays(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - - // The Canvas randomization adds at most 512 bits noise to the image data. - // We compare the image data arrays to see if they are different and the - // difference is within the range. - - // If we are compare two randomized arrays, the difference can be doubled. - let expected = isCompareOriginal - ? NUM_RANDOMIZED_CANVAS_BITS - : NUM_RANDOMIZED_CANVAS_BITS * 2; - - // The number of difference bits should never bigger than the expected - // number. It could be zero if the randomization is disabled. - Assert.lessOrEqual( - diffCnt, - expected, - "The number of noise bits is expected." - ); - - return diffCnt <= expected && diffCnt > 0; - }, + isDataRandomized: isDataRandomizedFuzzy, }, { name: "HTMLCanvasElement.toDataURL() with a 2d context", @@ -137,9 +93,7 @@ var TEST_CASES = [ return [dataURL, dataURLSecond]; }, - isDataRandomized(name, data1, data2) { - return data1 !== data2; - }, + isDataRandomized: isDataRandomizedNotEqual, }, { name: "HTMLCanvasElement.toDataURL() with a webgl context", @@ -170,9 +124,7 @@ var TEST_CASES = [ return [dataURL, dataURLSecond]; }, - isDataRandomized(name, data1, data2) { - return data1 !== data2; - }, + isDataRandomized: isDataRandomizedNotEqual, }, { name: "HTMLCanvasElement.toDataURL() with a bitmaprenderer context", @@ -208,9 +160,7 @@ var TEST_CASES = [ return [dataURL, dataURLSecond]; }, - isDataRandomized(name, data1, data2) { - return data1 !== data2; - }, + isDataRandomized: isDataRandomizedNotEqual, }, { name: "HTMLCanvasElement.toBlob() with a 2d context", @@ -253,11 +203,7 @@ var TEST_CASES = [ return [data, dataSecond]; }, - isDataRandomized(name, data1, data2) { - let diffCnt = countDifferencesInArrayBuffers(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - return diffCnt > 0; - }, + isDataRandomized: isDataRandomizedGreaterThanZero, }, { name: "HTMLCanvasElement.toBlob() with a webgl context", @@ -298,11 +244,7 @@ var TEST_CASES = [ return [data, data]; }, - isDataRandomized(name, data1, data2) { - let diffCnt = countDifferencesInArrayBuffers(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - return diffCnt > 0; - }, + isDataRandomized: isDataRandomizedGreaterThanZero, }, { name: "HTMLCanvasElement.toBlob() with a bitmaprenderer context", @@ -354,11 +296,7 @@ var TEST_CASES = [ return [data, dataSecond]; }, - isDataRandomized(name, data1, data2) { - let diffCnt = countDifferencesInArrayBuffers(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - return diffCnt > 0; - }, + isDataRandomized: isDataRandomizedGreaterThanZero, }, { name: "OffscreenCanvas.convertToBlob() with a 2d context", @@ -382,11 +320,7 @@ var TEST_CASES = [ return [data, dataSecond]; }, - isDataRandomized(name, data1, data2) { - let diffCnt = countDifferencesInArrayBuffers(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - return diffCnt > 0; - }, + isDataRandomized: isDataRandomizedGreaterThanZero, }, { name: "OffscreenCanvas.convertToBlob() with a webgl context", @@ -416,11 +350,7 @@ var TEST_CASES = [ return [data, dataSecond]; }, - isDataRandomized(name, data1, data2) { - let diffCnt = countDifferencesInArrayBuffers(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - return diffCnt > 0; - }, + isDataRandomized: isDataRandomizedGreaterThanZero, }, { name: "OffscreenCanvas.convertToBlob() with a bitmaprenderer context", @@ -450,11 +380,7 @@ var TEST_CASES = [ return [data, dataSecond]; }, - isDataRandomized(name, data1, data2) { - let diffCnt = countDifferencesInArrayBuffers(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - return diffCnt > 0; - }, + isDataRandomized: isDataRandomizedGreaterThanZero, }, { name: "CanvasRenderingContext2D.getImageData() with a offscreen canvas", @@ -477,29 +403,7 @@ var TEST_CASES = [ return [imageData.data, imageDataSecond.data]; }, - isDataRandomized(name, data1, data2, isCompareOriginal) { - let diffCnt = countDifferencesInUint8Arrays(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - - // The Canvas randomization adds at most 512 bits noise to the image data. - // We compare the image data arrays to see if they are different and the - // difference is within the range. - - // If we are compare two randomized arrays, the difference can be doubled. - let expected = isCompareOriginal - ? NUM_RANDOMIZED_CANVAS_BITS - : NUM_RANDOMIZED_CANVAS_BITS * 2; - - // The number of difference bits should never bigger than the expected - // number. It could be zero if the randomization is disabled. - Assert.lessOrEqual( - diffCnt, - expected, - "The number of noise bits is expected." - ); - - return diffCnt <= expected && diffCnt > 0; - }, + isDataRandomized: isDataRandomizedFuzzy, }, ]; diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js b/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js index 723d7382f8..4bf0f34811 100644 --- a/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js +++ b/toolkit/components/resistfingerprinting/tests/browser/browser_canvas_randomization_worker.js @@ -35,29 +35,7 @@ var TEST_CASES = [ return [imageData.data, imageDataSecond.data]; }, - isDataRandomized(name, data1, data2, isCompareOriginal) { - let diffCnt = countDifferencesInUint8Arrays(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - - // The Canvas randomization adds at most 512 bits noise to the image data. - // We compare the image data arrays to see if they are different and the - // difference is within the range. - - // If we are compare two randomized arrays, the difference can be doubled. - let expected = isCompareOriginal - ? NUM_RANDOMIZED_CANVAS_BITS - : NUM_RANDOMIZED_CANVAS_BITS * 2; - - // The number of difference bits should never bigger than the expected - // number. It could be zero if the randomization is disabled. - Assert.lessOrEqual( - diffCnt, - expected, - "The number of noise bits is expected." - ); - - return diffCnt <= expected && diffCnt > 0; - }, + isDataRandomized: isDataRandomizedFuzzy, }, { name: "OffscreenCanvas.convertToBlob() with a 2d context", @@ -94,11 +72,7 @@ var TEST_CASES = [ return [data, dataSecond]; }, - isDataRandomized(name, data1, data2) { - let diffCnt = countDifferencesInArrayBuffers(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - return diffCnt > 0; - }, + isDataRandomized: isDataRandomizedGreaterThanZero, }, { name: "OffscreenCanvas.convertToBlob() with a webgl context", @@ -140,11 +114,7 @@ var TEST_CASES = [ return [data, dataSecond]; }, - isDataRandomized(name, data1, data2) { - let diffCnt = countDifferencesInArrayBuffers(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - return diffCnt > 0; - }, + isDataRandomized: isDataRandomizedGreaterThanZero, }, { name: "OffscreenCanvas.convertToBlob() with a bitmaprenderer context", @@ -187,11 +157,7 @@ var TEST_CASES = [ return [data, dataSecond]; }, - isDataRandomized(name, data1, data2) { - let diffCnt = countDifferencesInArrayBuffers(data1, data2); - info(`For ${name} there are ${diffCnt} bits are different.`); - return diffCnt > 0; - }, + isDataRandomized: isDataRandomizedGreaterThanZero, }, ]; diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingRemoteOverrides.js b/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingRemoteOverrides.js index ac4722fd84..64efa270d7 100644 --- a/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingRemoteOverrides.js +++ b/toolkit/components/resistfingerprinting/tests/browser/browser_fingerprintingRemoteOverrides.js @@ -323,6 +323,51 @@ add_task(async function test_remote_settings() { db.clear(); }); +add_task(async function test_remote_settings_pref() { + // Add initial empty record. + let db = RemoteSettings(COLLECTION_NAME).db; + await db.importChanges({}, Date.now(), []); + + for (let test of TEST_CASES) { + info(`Testing with entry ${JSON.stringify(test.entires)}`); + + // Disable remote overrides + await SpecialPowers.pushPrefEnv({ + set: [ + ["privacy.fingerprintingProtection.remoteOverrides.enabled", false], + ], + }); + + // Create a promise for waiting the overrides get updated. + let promise = promiseObserver("fpp-test:set-overrides-finishes"); + + // Trigger the fingerprinting overrides update by a remote settings sync. + await RemoteSettings(COLLECTION_NAME).emit("sync", { + data: { + current: test.entires, + }, + }); + await promise; + + ok(true, "Got overrides update"); + + for (let expect of test.expects) { + try { + // Check for the existance of RFP overrides + Services.rfp.getFingerprintingOverrides(expect.domain); + ok( + false, + "This line should never run as the override should not exist and the previous line would throw an exception" + ); + } catch (e) { + ok(true, "Received an exception as expected"); + } + } + } + + db.clear(); +}); + add_task(async function test_pref() { for (let test of TEST_CASES) { info(`Testing with entry ${JSON.stringify(test.entires)}`); diff --git a/toolkit/components/resistfingerprinting/tests/browser/head.js b/toolkit/components/resistfingerprinting/tests/browser/head.js index e2fddaecc6..2a1b52f1c0 100644 --- a/toolkit/components/resistfingerprinting/tests/browser/head.js +++ b/toolkit/components/resistfingerprinting/tests/browser/head.js @@ -52,6 +52,40 @@ function countDifferencesInArrayBuffers(buffer1, buffer2) { return differences; } +function isDataRandomizedFuzzy(name, data1, data2, isCompareOriginal) { + let diffCnt = countDifferencesInUint8Arrays(data1, data2); + info(`For ${name} there are ${diffCnt} bits are different.`); + + // The Canvas randomization adds at most 512 bits noise to the image data. + // We compare the image data arrays to see if they are different and the + // difference is within the range. + + // If we are compare two randomized arrays, the difference can be doubled. + let expected = isCompareOriginal + ? NUM_RANDOMIZED_CANVAS_BITS + : NUM_RANDOMIZED_CANVAS_BITS * 2; + + // The number of difference bits should never bigger than the expected + // number. It could be zero if the randomization is disabled. + Assert.lessOrEqual( + diffCnt, + expected, + "The number of noise bits is expected." + ); + + return diffCnt <= expected && diffCnt > 0; +} + +function isDataRandomizedNotEqual(name, data1, data2) { + return data1 !== data2; +} + +function isDataRandomizedGreaterThanZero(name, data1, data2) { + let diffCnt = countDifferencesInArrayBuffers(data1, data2); + info(`For ${name} there are ${diffCnt} bits are different.`); + return diffCnt > 0; +} + function promiseObserver(topic) { return new Promise(resolve => { let obs = (aSubject, aTopic) => { |