Bug 1397611 Expose a websites.resistFingerprinting pref that Web Extensions can toggle draft
authorTom Ritter <tom@mozilla.com>
Thu, 07 Sep 2017 00:58:54 -0500
changeset 660875 62b8323af8e18fb72185771e1eaa8d86f8d82ccb
parent 659873 c959327c6b75cd4930a6ea087583c38b805e7524
child 730409 58d179816ed36089800da4f39fcfe791089f4698
push id78584
push userbmo:tom@mozilla.com
push dateThu, 07 Sep 2017 18:58:11 +0000
bugs1397611
milestone57.0a1
Bug 1397611 Expose a websites.resistFingerprinting pref that Web Extensions can toggle 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,
   });