Commit 97a444cc authored by Emma Zuehlcke's avatar Emma Zuehlcke
Browse files

Bug 1597541 - Added pref and disabled nsContentBlocker by default. r=Ehsan

Differential Revision: https://phabricator.services.mozilla.com/D53975

--HG--
extra : moz-landing-system : lando
parent 07d61b0b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1100,7 +1100,9 @@ function makePreview(row) {
      }
    }

    if (Services.prefs.getBoolPref("extensions.contentblocker.enabled")) {
      makeBlockImage(url);
    }

    imageContainer.removeChild(oldImage);
    imageContainer.appendChild(newImage);
+10 −0
Original line number Diff line number Diff line
@@ -76,6 +76,11 @@ function onLoad() {
         "color of img2 should be red");
      ok(img2.matches(":-moz-broken"), "should match ':-moz-broken' selector");

      // If nsContentBlocker is disabled, skip remaining checks
      if(!SpecialPowers.Services.prefs.getBoolPref("extensions.contentblocker.enabled")) {
        return Promise.reject(true);
      }

      // Now prepare for the next test, deny image.
      return new Promise(resolve => {
          SpecialPowers.pushPrefEnv({"set": [["permissions.default.image", 2]]}, resolve)
@@ -97,6 +102,11 @@ function onLoad() {

      SimpleTest.finish();
    }).catch((e) => {
      // Expected early return
      if(e === true) {
        SimpleTest.finish();
        return;
      }
      ok(false, "throwing " + e);
    });
  };
+13 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include "mozilla/ArrayUtils.h"
#include "nsContentUtils.h"
#include "nsNetUtil.h"
#include "mozilla/StaticPrefs_extensions.h"

// Possible behavior pref values
// Those map to the nsIPermissionManager values where possible
@@ -86,6 +87,10 @@ nsContentBlocker::nsContentBlocker() {
}

nsresult nsContentBlocker::Init() {
  if (!StaticPrefs::extensions_contentblocker_enabled_AtStartup()) {
    return NS_OK;
  }

  mPermissionManager = nsPermissionManager::GetInstance();
  if (!mPermissionManager) {
    return NS_ERROR_NULL_POINTER;
@@ -156,6 +161,10 @@ void nsContentBlocker::PrefChanged(nsIPrefBranch* aPrefBranch,
NS_IMETHODIMP
nsContentBlocker::ShouldLoad(nsIURI* aContentLocation, nsILoadInfo* aLoadInfo,
                             const nsACString& aMimeGuess, int16_t* aDecision) {
  if (!StaticPrefs::extensions_contentblocker_enabled_AtStartup()) {
    *aDecision = nsIContentPolicy::ACCEPT;
    return NS_OK;
  }
  uint32_t contentType = aLoadInfo->GetExternalContentPolicyType();
  nsCOMPtr<nsIPrincipal> loadingPrincipal = aLoadInfo->LoadingPrincipal();
  nsCOMPtr<nsIURI> requestingLocation;
@@ -213,6 +222,10 @@ nsContentBlocker::ShouldProcess(nsIURI* aContentLocation,
                                nsILoadInfo* aLoadInfo,
                                const nsACString& aMimeGuess,
                                int16_t* aDecision) {
  if (!StaticPrefs::extensions_contentblocker_enabled_AtStartup()) {
    *aDecision = nsIContentPolicy::ACCEPT;
    return NS_OK;
  }
  uint32_t contentType = aLoadInfo->GetExternalContentPolicyType();
  nsCOMPtr<nsISupports> requestingContext = aLoadInfo->GetLoadingContext();
  nsCOMPtr<nsIPrincipal> loadingPrincipal = aLoadInfo->LoadingPrincipal();
+6 −0
Original line number Diff line number Diff line
@@ -2853,6 +2853,12 @@
  value: false
  mirror: always

# This pref enables/disables nsContentBlocker
- name: extensions.contentblocker.enabled
  type: bool
  value: false
  mirror: once

#---------------------------------------------------------------------------
# Prefs starting with "findbar."
#---------------------------------------------------------------------------