Bug 1397611 Expose a websites.resistFingerprinting pref that Web Extensions can toggle r=aswan,bsilverberg
authorTom Ritter <tom@mozilla.com>
Thu, 07 Sep 2017 00:58:54 -0500
changeset 384156 3bf4a8d9d126e3cf4eba20f43bef3d1413b33c26
parent 384155 a6ffff95554772e0c69c050e6d3b6fb48ce3ec17
child 384157 943ad1c9a59a85cb2ed809b185e2cdf135057f96
push id32623
push userkwierso@gmail.com
push dateTue, 03 Oct 2017 20:25:55 +0000
treeherdermozilla-central@65a5054a1f92 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan, bsilverberg
bugs1397611
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1397611 Expose a websites.resistFingerprinting pref that Web Extensions can toggle r=aswan,bsilverberg MozReview-Commit-ID: Fh48FWKdhoD
toolkit/components/extensions/ext-privacy.js
toolkit/components/extensions/schemas/privacy.json
toolkit/components/extensions/test/xpcshell/test_ext_privacy.js
--- a/toolkit/components/extensions/ext-privacy.js
+++ b/toolkit/components/extensions/ext-privacy.js
@@ -133,16 +133,26 @@ ExtensionPreferencesManager.addSetting("
   // Values for network.http.sendRefererHeader:
   // 0=don't send any, 1=send only on clicks, 2=send on image requests as well
   // http://searchfox.org/mozilla-central/rev/61054508641ee76f9c49bcf7303ef3cfb6b410d2/modules/libpref/init/all.js#1585
   setCallback(value) {
     return {[this.prefNames[0]]: value ? 2 : 0};
   },
 });
 
+ExtensionPreferencesManager.addSetting("websites.resistFingerprinting", {
+  prefNames: [
+    "privacy.resistFingerprinting",
+  ],
+
+  setCallback(value) {
+    return {[this.prefNames[0]]: value};
+  },
+});
+
 ExtensionPreferencesManager.addSetting("websites.trackingProtectionMode", {
   prefNames: [
     "privacy.trackingprotection.enabled",
     "privacy.trackingprotection.pbmode.enabled",
   ],
 
   setCallback(value) {
     // Default to private browsing.
@@ -221,16 +231,21 @@ this.privacy = class extends ExtensionAP
             () => {
               return Preferences.get("browser.send_pings");
             }),
           referrersEnabled: getPrivacyAPI(extension,
             "websites.referrersEnabled",
             () => {
               return Preferences.get("network.http.sendRefererHeader") !== 0;
             }),
+          resistFingerprinting: getPrivacyAPI(extension,
+            "websites.resistFingerprinting",
+            () => {
+              return Preferences.get("privacy.resistFingerprinting");
+            }),
           trackingProtectionMode: getPrivacyAPI(extension,
             "websites.trackingProtectionMode",
             () => {
               if (Preferences.get("privacy.trackingprotection.enabled")) {
                 return "always";
               } else if (
                   Preferences.get("privacy.trackingprotection.pbmode.enabled")) {
                 return "private_browsing";
--- a/toolkit/components/extensions/schemas/privacy.json
+++ b/toolkit/components/extensions/schemas/privacy.json
@@ -80,16 +80,20 @@
       "hyperlinkAuditingEnabled": {
         "$ref": "types.Setting",
         "description": "If enabled, the browser sends auditing pings when requested by a website (<code>&lt;a ping&gt;</code>). The value of this preference is of type boolean, and the default value is <code>true</code>."
       },
       "referrersEnabled": {
         "$ref": "types.Setting",
         "description": "If enabled, the browser sends <code>referer</code> headers with your requests. Yes, the name of this preference doesn't match the misspelled header. No, we're not going to change it. The value of this preference is of type boolean, and the default value is <code>true</code>."
       },
+      "resistFingerprinting": {
+        "$ref": "types.Setting",
+        "description": "If enabled, the browser attempts to appear similar to other users by reporting generic information to websites. This can prevent websites from uniquely identifying users. Examples of data that is spoofed include number of CPU cores, precision of JavaScript timers, the local timezone, and disabling features such as GamePad support, and the WebSpeech and Navigator APIs. The value of this preference is of type boolean, and the default value is <code>false</code>."
+      },
       "protectedContentEnabled": {
         "$ref": "types.Setting",
         "description": "<strong>Available on Windows and ChromeOS only</strong>: If enabled, the browser provides a unique ID to plugins in order to run protected content. The value of this preference is of type boolean, and the default value is <code>true</code>.",
         "unsupported": true
       },
       "trackingProtectionMode": {
         "$ref": "types.Setting",
         "description": "Allow users to specify the mode for tracking protection. This setting's value is of type TrackingProtectionModeOption, defaulting to <code>private_browsing_only</code>."
--- a/toolkit/components/extensions/test/xpcshell/test_ext_privacy.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_privacy.js
@@ -230,16 +230,19 @@ add_task(async function test_privacy_oth
       "media.peerconnection.enabled": true,
     },
     "services.passwordSavingEnabled": {
       "signon.rememberSignons": true,
     },
     "websites.referrersEnabled": {
       "network.http.sendRefererHeader": 2,
     },
+    "websites.resistFingerprinting": {
+      "privacy.resistFingerprinting": true,
+    },
   };
 
   async function background() {
     browser.test.onMessage.addListener(async (msg, ...args) => {
       let data = args[0];
       // The second argument is the end of the api name,
       // e.g., "network.webRTCIPHandlingPolicy".
       let apiObj = args[1].split(".").reduce((o, i) => o[i], browser.privacy);
@@ -334,16 +337,25 @@ add_task(async function test_privacy_oth
     {
       "network.http.sendRefererHeader": 0,
     });
   await testSetting("websites.referrersEnabled", true,
     {
       "network.http.sendRefererHeader": 2,
     });
 
+  await testSetting("websites.resistFingerprinting", false,
+    {
+      "privacy.resistFingerprinting": false,
+    });
+  await testSetting("websites.resistFingerprinting", true,
+    {
+      "privacy.resistFingerprinting": true,
+    });
+
   await testSetting("websites.trackingProtectionMode", "always", {
     "privacy.trackingprotection.enabled": true,
     "privacy.trackingprotection.pbmode.enabled": true,
   });
   await testSetting("websites.trackingProtectionMode", "never", {
     "privacy.trackingprotection.enabled": false,
     "privacy.trackingprotection.pbmode.enabled": false,
   });