Bug 1472618 - Make navigator.platform return "Win32", even on Win64 OS. r?peterv draft
authorChris Peterson <cpeterson@mozilla.com>
Mon, 02 Jul 2018 11:02:23 -0700
changeset 813421 6d6815796914d994133d9006b2d9411788006df8
parent 813360 7d20e7fae1039720f92db1a3a72bc2c7424b5f98
push id114894
push usercpeterson@mozilla.com
push dateTue, 03 Jul 2018 05:29:02 +0000
reviewerspeterv
bugs1472618
milestone63.0a1
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
browser/components/resistfingerprinting/test/browser/browser_navigator.js
dom/base/Navigator.cpp
toolkit/components/resistfingerprinting/nsRFPService.h
--- 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)"