Bug 1928309 - Adjust the User-Agent string on iOS. r=cpeterson,necko-reviewers,valentin

This makes the UA "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X;
rv:134.0) Gecko/134.0 Firefox/134.0" instead of "Mozilla/5.0 (X11; Linux
x86_64; rv:134.0) Gecko/134.0 Firefox/134.0"

Differential Revision: https://phabricator.services.mozilla.com/D227454
This commit is contained in:
Mike Hommey 2024-11-07 07:45:09 +00:00
parent 8c7be88ead
commit efe75a31b9

View File

@ -449,7 +449,7 @@ nsresult nsHttpHandler::Init() {
mRequestContextService = RequestContextService::GetOrCreate();
#if defined(ANDROID)
#if defined(ANDROID) || defined(XP_IOS)
mProductSub.AssignLiteral(MOZILLA_UAVERSION);
#else
mProductSub.AssignLiteral(LEGACY_UA_GECKO_TRAIL);
@ -965,6 +965,8 @@ void nsHttpHandler::InitUserAgentComponents() {
"Windows"
#elif defined(XP_MACOSX)
"Macintosh"
#elif defined(XP_IOS)
"iPhone"
#elif defined(XP_UNIX)
// We historically have always had X11 here,
// and there seems little a webpage can sensibly do
@ -1024,6 +1026,12 @@ void nsHttpHandler::InitUserAgentComponents() {
}
#endif // ANDROID
#if defined(XP_IOS)
// Freeze the iOS version to 18.0, use an underscore separator to avoid
// detection as macOS.
mCompatDevice.AssignLiteral("CPU iPhone OS 18_0 like Mac OS X");
#endif
// Gather OS/CPU.
#if defined(XP_WIN)
@ -1053,6 +1061,8 @@ void nsHttpHandler::InitUserAgentComponents() {
mOscpu.AssignLiteral("Intel Mac OS X 10.15");
#elif defined(ANDROID)
mOscpu.AssignLiteral("Linux armv81");
#elif defined(XP_IOS)
mOscpu.AssignLiteral("iPhone");
#else
mOscpu.AssignLiteral("Linux x86_64");
#endif