forked from mirrors/gecko-dev
Bug 1480450 - Honor browser.contentblocking.enabled in tracking protection. r=dimi!
Depends on D3131 Differential Revision: https://phabricator.services.mozilla.com/D3132 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
7b02c4debb
commit
71239f0c25
5 changed files with 44 additions and 12 deletions
|
|
@ -13115,20 +13115,23 @@ nsDocShell::GetUseTrackingProtection(bool* aUseTrackingProtection)
|
|||
{
|
||||
*aUseTrackingProtection = false;
|
||||
|
||||
static bool sCBEnabled = false;
|
||||
static bool sTPEnabled = false;
|
||||
static bool sTPInPBEnabled = false;
|
||||
static bool sPrefsInit = false;
|
||||
|
||||
if (!sPrefsInit) {
|
||||
sPrefsInit = true;
|
||||
Preferences::AddBoolVarCache(&sCBEnabled,
|
||||
"browser.contentblocking.enabled", true);
|
||||
Preferences::AddBoolVarCache(&sTPEnabled,
|
||||
"privacy.trackingprotection.enabled", false);
|
||||
Preferences::AddBoolVarCache(&sTPInPBEnabled,
|
||||
"privacy.trackingprotection.pbmode.enabled", false);
|
||||
}
|
||||
|
||||
if (mUseTrackingProtection || sTPEnabled ||
|
||||
(UsePrivateBrowsing() && sTPInPBEnabled)) {
|
||||
if (mUseTrackingProtection || (sCBEnabled && sTPEnabled) ||
|
||||
(sCBEnabled && UsePrivateBrowsing() && sTPInPBEnabled)) {
|
||||
*aUseTrackingProtection = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ var SafeBrowsing = {
|
|||
return;
|
||||
}
|
||||
|
||||
Services.prefs.addObserver("browser.contentblocking.enabled", this);
|
||||
Services.prefs.addObserver("browser.safebrowsing", this);
|
||||
Services.prefs.addObserver("privacy.trackingprotection", this);
|
||||
Services.prefs.addObserver("urlclassifier", this);
|
||||
|
|
@ -230,11 +231,13 @@ var SafeBrowsing = {
|
|||
loggingEnabled = Services.prefs.getBoolPref(PREF_DEBUG_ENABLED);
|
||||
log("reading prefs");
|
||||
|
||||
let contentBlockingEnabled = Services.prefs.getBoolPref("browser.contentblocking.enabled", true);
|
||||
|
||||
this.phishingEnabled = Services.prefs.getBoolPref("browser.safebrowsing.phishing.enabled");
|
||||
this.malwareEnabled = Services.prefs.getBoolPref("browser.safebrowsing.malware.enabled");
|
||||
this.downloadsEnabled = Services.prefs.getBoolPref("browser.safebrowsing.downloads.enabled");
|
||||
this.passwordsEnabled = Services.prefs.getBoolPref("browser.safebrowsing.passwords.enabled");
|
||||
this.trackingEnabled = Services.prefs.getBoolPref("privacy.trackingprotection.enabled") || Services.prefs.getBoolPref("privacy.trackingprotection.pbmode.enabled");
|
||||
this.trackingEnabled = contentBlockingEnabled && (Services.prefs.getBoolPref("privacy.trackingprotection.enabled") || Services.prefs.getBoolPref("privacy.trackingprotection.pbmode.enabled"));
|
||||
this.blockedEnabled = Services.prefs.getBoolPref("browser.safebrowsing.blockedURIs.enabled");
|
||||
this.trackingAnnotations = Services.prefs.getBoolPref("privacy.trackingprotection.annotate_channels");
|
||||
this.flashBlockEnabled = Services.prefs.getBoolPref("plugins.flashBlock.enabled");
|
||||
|
|
|
|||
|
|
@ -104,9 +104,11 @@ function checkLoads(aWindow, aBlocked) {
|
|||
}
|
||||
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{"set": [["privacy.trackingprotection.enabled", false],
|
||||
["privacy.trackingprotection.pbmode.enabled", true]]},
|
||||
test);
|
||||
{"set": [
|
||||
["browser.contentblocking.enabled", true],
|
||||
["privacy.trackingprotection.enabled", false],
|
||||
["privacy.trackingprotection.pbmode.enabled", true],
|
||||
]}, test);
|
||||
|
||||
async function test() {
|
||||
SimpleTest.registerCleanupFunction(UrlClassifierTestUtils.cleanupTestTrackers);
|
||||
|
|
@ -130,6 +132,15 @@ async function test() {
|
|||
checkLoads(aWindow, false);
|
||||
aWindow.close();
|
||||
});
|
||||
|
||||
// Private Browsing, without the content blocking pref (trackers should be loaded)
|
||||
await SpecialPowers.setBoolPref("privacy.trackingprotection.pbmode.enabled", true);
|
||||
await SpecialPowers.setBoolPref("browser.contentblocking.enabled", false);
|
||||
await testOnWindow(true).then(function(aWindow) {
|
||||
checkLoads(aWindow, false);
|
||||
aWindow.close();
|
||||
});
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ function checkLoads(aWindow, aBlocked) {
|
|||
SpecialPowers.pushPrefEnv(
|
||||
{"set": [["urlclassifier.trackingTable", "test-track-simple"],
|
||||
["privacy.trackingprotection.enabled", true],
|
||||
["browser.contentblocking.enabled", true],
|
||||
["browser.safebrowsing.malware.enabled", false],
|
||||
["browser.safebrowsing.phishing.enabled", false],
|
||||
["channelclassifier.allowlist_example", true]]},
|
||||
|
|
|
|||
|
|
@ -56,8 +56,14 @@ var alwaysbadids = [
|
|||
"badscript",
|
||||
];
|
||||
|
||||
function checkLoads(aWindow, aWhitelisted) {
|
||||
function checkLoads(aWindow, aWhitelisted, tpEnabled) {
|
||||
var win = aWindow.content;
|
||||
if (!tpEnabled) {
|
||||
is(win.document.getElementById("badscript").dataset.touched, "yes", "Should load tracking javascript");
|
||||
is(win.document.blockedTrackingNodeCount, 0, "Should not identify any tracking elements");
|
||||
return;
|
||||
}
|
||||
|
||||
is(win.document.getElementById("badscript").dataset.touched, "no", "Should not load tracking javascript");
|
||||
is(win.document.getElementById("goodscript").dataset.touched, aWhitelisted ? "yes" : "no", "Should load whitelisted tracking javascript");
|
||||
|
||||
|
|
@ -109,22 +115,30 @@ async function test() {
|
|||
SimpleTest.registerCleanupFunction(UrlClassifierTestUtils.cleanupTestTrackers);
|
||||
await UrlClassifierTestUtils.addTestTrackers();
|
||||
|
||||
// Load the test from a URL on the whitelist
|
||||
await testOnWindow(contentPage1).then(function(aWindow) {
|
||||
checkLoads(aWindow, true);
|
||||
// Load the test from a URL that's NOT on the whitelist with content blocking disabled
|
||||
await SpecialPowers.setBoolPref("browser.contentblocking.enabled", false);
|
||||
await testOnWindow(contentPage2).then(function(aWindow) {
|
||||
checkLoads(aWindow, false, false);
|
||||
aWindow.close();
|
||||
});
|
||||
await SpecialPowers.clearUserPref("browser.contentblocking.enabled");
|
||||
|
||||
// Load the test from a URL that's NOT on the whitelist
|
||||
await testOnWindow(contentPage2).then(function(aWindow) {
|
||||
checkLoads(aWindow, false);
|
||||
checkLoads(aWindow, false, true);
|
||||
aWindow.close();
|
||||
});
|
||||
|
||||
// Load the test from a URL on the whitelist
|
||||
await testOnWindow(contentPage1).then(function(aWindow) {
|
||||
checkLoads(aWindow, true, true);
|
||||
aWindow.close();
|
||||
});
|
||||
|
||||
// Load the test from a URL on the whitelist but without the whitelist
|
||||
await SpecialPowers.setCharPref("urlclassifier.trackingWhitelistTable", "");
|
||||
await testOnWindow(contentPage1).then(function(aWindow) {
|
||||
checkLoads(aWindow, false);
|
||||
checkLoads(aWindow, false, true);
|
||||
aWindow.close();
|
||||
});
|
||||
await SpecialPowers.clearUserPref("urlclassifier.trackingWhitelistTable");
|
||||
|
|
|
|||
Loading…
Reference in a new issue