Bug 1384330 - Part 1: Blocking the mozAddonManager when pref 'privacy.resistFingerprinting.block_mozAddonManager' is true. r=arthuredelstein,mossop
authorTim Huang <tihuang@mozilla.com>
Thu, 14 Sep 2017 15:11:21 +0800
changeset 430889 bb14bbb30c4150b69d541d4c9f32762721a9ccc2
parent 430888 0806dedfeae9b2af24698cb9d004bd0e5e46ba23
child 430890 2189a968511ee8f51eb2deb046bd7914a76a693b
push id7775
push userryanvm@gmail.com
push dateTue, 19 Sep 2017 01:22:09 +0000
treeherdermozilla-beta@a0f805dbe65d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarthuredelstein, mossop
bugs1384330
milestone57.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 1384330 - Part 1: Blocking the mozAddonManager when pref 'privacy.resistFingerprinting.block_mozAddonManager' is true. r=arthuredelstein,mossop This patch adds a hidden pref 'privacy.resistFingerprinting.block_mozAddonManager', which is false by default. When this is true, the navigator.mozAddonManager will be blocked even the website is AMO. The purpose of this pref is for Tor browser can disable navigator.mozAddonManager through this. MozReview-Commit-ID: Lf37gHXETCz
toolkit/mozapps/extensions/AddonManagerWebAPI.cpp
--- a/toolkit/mozapps/extensions/AddonManagerWebAPI.cpp
+++ b/toolkit/mozapps/extensions/AddonManagerWebAPI.cpp
@@ -15,16 +15,22 @@
 #include "nsIDocShell.h"
 #include "nsIScriptObjectPrincipal.h"
 
 namespace mozilla {
 using namespace mozilla::dom;
 
 static bool
 IsValidHost(const nsACString& host) {
+  // This hidden pref allows users to disable mozAddonManager entirely if they want
+  // for fingerprinting resistance. Someone like Tor browser will use this pref.
+  if (Preferences::GetBool("privacy.resistFingerprinting.block_mozAddonManager")) {
+    return false;
+  }
+
   // This is ugly, but Preferences.h doesn't have support
   // for default prefs or locked prefs
   nsCOMPtr<nsIPrefService> prefService (do_GetService(NS_PREFSERVICE_CONTRACTID));
   nsCOMPtr<nsIPrefBranch> prefs;
   if (prefService) {
     prefService->GetDefaultBranch(nullptr, getter_AddRefs(prefs));
     bool isEnabled;
     if (NS_SUCCEEDED(prefs->GetBoolPref("xpinstall.enabled", &isEnabled)) && !isEnabled) {