[tbb-commits] [Git][tpo/applications/mullvad-browser][mullvad-browser-115.11.0esr-13.5-1] 5 commits: fixup! Bug 40175: Add origin attributes to about:reader top-level requests

richard (@richard) git at gitlab.torproject.org
Thu May 30 11:45:22 UTC 2024



richard pushed to branch mullvad-browser-115.11.0esr-13.5-1 at The Tor Project / Applications / Mullvad Browser


Commits:
f34bff1e by Pier Angelo Vendrame at 2024-05-30T11:44:22+00:00
fixup! Bug 40175: Add origin attributes to about:reader top-level requests

Revert "Bug 40175: Add origin attributes to about:reader top-level requests"

This reverts commit 2718a926fd331a0df2ad8cc90c6c9633f3630243.

- - - - -
7684ec07 by Pier Angelo Vendrame at 2024-05-30T11:44:22+00:00
fixup! Bug 41116: Normalize system fonts.

Revert "fixup! Bug 41116: Normalize system fonts."

This reverts commit 2c1a8f5261873f3c2435b9de1f83c07d5933748e.

- - - - -
aff5ec0f by Pier Angelo Vendrame at 2024-05-30T11:44:22+00:00
fixup! Bug 41116: Normalize system fonts.

Revert "Bug 41116: Normalize system fonts."

This reverts commit df3f350e810ebe79c0823a124e6a555baf812f55.

- - - - -
6ebf41c3 by Pier Angelo Vendrame at 2024-05-30T11:44:23+00:00
Bug 1787790: Normalize system fonts with RFP on. r=emilio

System fonts can leak any user customization of system fonts, or user's
locale (e.g., en-US and ja Windows have different system fonts).
Also, Linux distributions/desktop environments set default fonts in
different ways.

Customization can be detected either with font metrics, the font allowed
list is not enabled or the font is included in it, or with
getComputedStyle, that leaks the name of the font that Firefox tries to
apply.

This patch try to prevent these leaks by using a generic "sans-serif"
for all system fonts, except on macOS, where it uses "-apple-system",
and on Android, where these fonts always use Roboto.

Differential Revision: https://phabricator.services.mozilla.com/D163576

- - - - -
1b026291 by cypherpunks1 at 2024-05-30T11:44:23+00:00
Bug 1892046 - Add origin attributes to about:reader requests. r=reader-mode-reviewers,cmkm

Differential Revision: https://phabricator.services.mozilla.com/D207759
- - - - -


5 changed files:

- gfx/thebes/gfxPlatformFontList.cpp
- layout/base/nsLayoutUtils.cpp
- layout/reftests/font-matching/reftest.list
- + layout/reftests/font-matching/system-font-rfp-ref.html
- + layout/reftests/font-matching/system-font-rfp.html


Changes:

=====================================
gfx/thebes/gfxPlatformFontList.cpp
=====================================
@@ -1973,19 +1973,17 @@ static void GetSystemUIFontFamilies(const nsPresContext* aPresContext,
   nsFont systemFont;
   gfxFontStyle fontStyle;
   nsAutoString systemFontName;
-  if (aPresContext && aPresContext->Document()
-                 ? aPresContext->Document()->ShouldResistFingerprinting(
-                       RFPTarget::Unknown)
-                 : nsContentUtils::ShouldResistFingerprinting(
-                       "aPresContext not available", RFPTarget::Unknown)) {
-#ifdef XP_MACOSX
+  if (aPresContext ? aPresContext->Document()->ShouldResistFingerprinting(
+                         RFPTarget::Unknown)
+                   : nsContentUtils::ShouldResistFingerprinting(
+                         "aPresContext not available", RFPTarget::Unknown)) {
+#if defined(XP_MACOSX) || defined(MOZ_WIDGET_UIKIT)
     *aFamilies.AppendElement() = "-apple-system"_ns;
     return;
 #elif !defined(MOZ_WIDGET_ANDROID)
     *aFamilies.AppendElement() = "sans-serif"_ns;
     return;
 #endif
-    // Android uses already fixed fonts.
   }
   if (!LookAndFeel::GetFont(StyleSystemFont::Menu, systemFontName, fontStyle)) {
     return;


=====================================
layout/base/nsLayoutUtils.cpp
=====================================
@@ -9680,7 +9680,7 @@ already_AddRefed<nsFontMetrics> nsLayoutUtils::GetMetricsFor(
 
 static void GetSpoofedSystemFontForRFP(LookAndFeel::FontID aFontID,
                                        gfxFontStyle& aStyle, nsAString& aName) {
-#if defined(XP_MACOSX)
+#if defined(XP_MACOSX) || defined(MOZ_WIDGET_UIKIT)
   aName = u"-apple-system"_ns;
   // Values taken from a macOS 10.15 system.
   switch (aFontID) {
@@ -9690,7 +9690,8 @@ static void GetSpoofedSystemFontForRFP(LookAndFeel::FontID aFontID,
       break;
     case LookAndFeel::FontID::SmallCaption:
       aStyle.weight = gfxFontStyle::FontWeight::BOLD;
-      // fall-through
+      // fall-through for font-size
+      [[fallthrough]];
     case LookAndFeel::FontID::MessageBox:
     case LookAndFeel::FontID::StatusBar:
       aStyle.size = 11;
@@ -9704,14 +9705,13 @@ static void GetSpoofedSystemFontForRFP(LookAndFeel::FontID aFontID,
   // languages, so we fallback to sans-serif to fall back to the user's
   // default sans-serif. Size is 12px for all system fonts (tried in an en-US
   // system).
-  // Several Android systems reported Roboto 12px, so similar to what Windows
-  // does.
   aName = u"sans-serif"_ns;
   aStyle.size = 12;
 #elif defined(MOZ_WIDGET_ANDROID)
+  // Keep consistency with nsLookAndFeel::NativeGetFont.
   aName = u"Roboto"_ns;
   aStyle.size = 12;
-#else
+#elif defined(MOZ_WIDGET_GTK)
   // On Linux, there is not a default. For example, GNOME on Debian uses
   // Cantarell, 14.667px. Ubuntu Mate uses the Ubuntu font, but also 14.667px.
   // Fedora with KDE uses Noto Sans, 13.3333px, but it uses Noto Sans on
@@ -9721,6 +9721,8 @@ static void GetSpoofedSystemFontForRFP(LookAndFeel::FontID aFontID,
   // UI font-size.
   aName = u"sans-serif"_ns;
   aStyle.size = 15;
+#else
+#  error "Unknown platform"
 #endif
 }
 


=====================================
layout/reftests/font-matching/reftest.list
=====================================
@@ -195,3 +195,6 @@ pref(ui.font.menu,"serif") test-pref(ui.font.menu.weight,"800") != system-font-p
 
 # Reset default prefs.
 defaults
+
+# Bug 1787790 - Normalize system fonts when using RFP
+test-pref(privacy.resistFingerprinting,true) == system-font-rfp.html system-font-rfp-ref.html


=====================================
layout/reftests/font-matching/system-font-rfp-ref.html
=====================================
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<style>
+body {
+  font-family: -apple-system, sans-serif;
+  font-size: 12px;
+}
+
+.android {
+  font-family: Roboto;
+}
+
+.linux {
+  font-size: 15px;
+}
+
+.mac {
+  .caption, .menu {
+    font-size: 13px;
+  }
+  .message-box, .status-bar {
+    font-size: 11px;
+  }
+  .small-caption {
+    font-size: 11px;
+    font-weight: 700;
+  }
+}
+</style>
+<div class="caption">Caption</div>
+<div class="icon">Icon</div>
+<div class="menu">Menu</div>
+<div class="message-box">Message box</div>
+<div class="small-caption">Small caption</div>
+<div class="status-bar">Status bar</div>
+<script>
+if (navigator.platform.startsWith("Mac")) {
+  document.querySelector("body").className = "mac";
+} else if (navigator.userAgent.includes("Android")) {
+  document.querySelector("body").className = "android";
+} else if (navigator.platform.startsWith("Linux")) {
+  document.querySelector("body").className = "linux";
+}
+</script>


=====================================
layout/reftests/font-matching/system-font-rfp.html
=====================================
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<div style="font: caption">Caption</div>
+<div style="font: icon">Icon</div>
+<div style="font: menu">Menu</div>
+<div style="font: message-box">Message box</div>
+<div style="font: small-caption">Small caption</div>
+<div style="font: status-bar">Status bar</div>



View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/compare/2cfc1d0d97375c2b7a55bf8faa9f1eb58d0ad51c...1b0262915361cd6bbbc5269ee097c5e379111381

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/compare/2cfc1d0d97375c2b7a55bf8faa9f1eb58d0ad51c...1b0262915361cd6bbbc5269ee097c5e379111381
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20240530/354268f1/attachment-0001.htm>


More information about the tbb-commits mailing list