Bug 1472618 - Make navigator.platform return "Win32", even on Win64 OS. r?peterv
navigator.platform returns "Win64" in 64-bit Firefox and IE, but "Win32" in 64-bit Chrome and Edge. "Win32" appears to be the de facto platform value for Windows. This change doesn't hide the OS architecture from web content because navigator.userAgent still mentions "Win64; x64" in 64-bit Firefox, Chrome, Edge, and IE.
MozReview-Commit-ID: CplYnGDQgTe
--- a/browser/components/resistfingerprinting/test/browser/browser_navigator.js
+++ b/browser/components/resistfingerprinting/test/browser/browser_navigator.js
@@ -19,17 +19,17 @@ const SPOOFED_APPVERSION = {
linux: "5.0 (X11)",
win: "5.0 (Windows)",
macosx: "5.0 (Macintosh)",
android: "5.0 (Android 6.0)",
other: "5.0 (X11)",
};
const SPOOFED_PLATFORM = {
linux: "Linux x86_64",
- win: "Win64",
+ win: "Win32",
macosx: "MacIntel",
android: "Linux armv7l",
other: "Linux x86_64",
};
const SPOOFED_OSCPU = {
linux: "Linux x86_64",
win: "Windows NT 6.1; Win64; x64",
macosx: "Intel Mac OS X 10.13",
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1544,19 +1544,17 @@ Navigator::GetPlatform(nsAString& aPlatf
nsresult rv;
nsCOMPtr<nsIHttpProtocolHandler>
service(do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &rv));
NS_ENSURE_SUCCESS(rv, rv);
// Sorry for the #if platform ugliness, but Communicator is likewise
// hardcoded and we are seeking backward compatibility here (bug 47080).
-#if defined(_WIN64)
- aPlatform.AssignLiteral("Win64");
-#elif defined(WIN32)
+#if defined(WIN32)
aPlatform.AssignLiteral("Win32");
#elif defined(XP_MACOSX) && defined(__ppc__)
aPlatform.AssignLiteral("MacPPC");
#elif defined(XP_MACOSX) && defined(__i386__)
aPlatform.AssignLiteral("MacIntel");
#elif defined(XP_MACOSX) && defined(__x86_64__)
aPlatform.AssignLiteral("MacIntel");
#else
--- a/toolkit/components/resistfingerprinting/nsRFPService.h
+++ b/toolkit/components/resistfingerprinting/nsRFPService.h
@@ -20,17 +20,17 @@
// We decided to give different spoofed values according to the platform. The
// reason is that it is easy to detect the real platform. So there is no benefit
// for hiding the platform: it only brings breakages, like keyboard shortcuts won't
// work in MAC OS if we spoof it as a window platform.
#ifdef XP_WIN
#define SPOOFED_UA_OS "Windows NT 6.1; Win64; x64"
#define SPOOFED_APPVERSION "5.0 (Windows)"
#define SPOOFED_OSCPU "Windows NT 6.1; Win64; x64"
-#define SPOOFED_PLATFORM "Win64"
+#define SPOOFED_PLATFORM "Win32"
#elif defined(XP_MACOSX)
#define SPOOFED_UA_OS "Macintosh; Intel Mac OS X 10.13"
#define SPOOFED_APPVERSION "5.0 (Macintosh)"
#define SPOOFED_OSCPU "Intel Mac OS X 10.13"
#define SPOOFED_PLATFORM "MacIntel"
#elif defined(MOZ_WIDGET_ANDROID)
#define SPOOFED_UA_OS "Android 6.0; Mobile"
#define SPOOFED_APPVERSION "5.0 (Android 6.0)"