From 295b677d78b93d09b1cff09aba87eaeccdce5431 Mon Sep 17 00:00:00 2001
From: Pier Angelo Vendrame <pierov@torproject.org>
Date: Wed, 31 Jan 2024 21:52:30 +0000
Subject: [PATCH] Bug 1875313 - Use en-US as a fallback when spoof English is
 enabled in ICUUtils. r=timhuang,tjr

Differential Revision: https://phabricator.services.mozilla.com/D198967
---
 intl/unicharutil/util/ICUUtils.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/intl/unicharutil/util/ICUUtils.cpp b/intl/unicharutil/util/ICUUtils.cpp
index 4ee3bf5f15c27..20a4f9498505e 100644
--- a/intl/unicharutil/util/ICUUtils.cpp
+++ b/intl/unicharutil/util/ICUUtils.cpp
@@ -47,8 +47,13 @@ void ICUUtils::LanguageTagIterForContent::GetNext(nsACString& aBCP47LangTag) {
 
   if (mCurrentFallbackIndex < 2) {
     mCurrentFallbackIndex = 2;
-    // Else take the app's locale:
-
+    // Else take the app's locale (or en-US, if spoof English applies):
+    const bool spoofLocale = nsContentUtils::SpoofLocaleEnglish() &&
+                             !mContent->OwnerDoc()->AllowsL10n();
+    if (spoofLocale) {
+      aBCP47LangTag.AssignLiteral("en-US");
+      return;
+    }
     nsAutoCString appLocale;
     LocaleService::GetInstance()->GetAppLocaleAsBCP47(aBCP47LangTag);
     return;
-- 
GitLab