Backed out 1 changesets (bug 1480450) for mochitest/test_trackingprotection_bug1157081.html failures CLOSED TREE

Backed out changeset 34d3b10c54eb (bug 1480450)
This commit is contained in:
Ciure Andrei 2018-08-13 22:45:37 +03:00
parent c9f1c48f1e
commit 057ea5d560
4 changed files with 12 additions and 43 deletions

View File

@ -13115,23 +13115,20 @@ 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 || (sCBEnabled && sTPEnabled) ||
(sCBEnabled && UsePrivateBrowsing() && sTPInPBEnabled)) {
if (mUseTrackingProtection || sTPEnabled ||
(UsePrivateBrowsing() && sTPInPBEnabled)) {
*aUseTrackingProtection = true;
return NS_OK;
}

View File

@ -60,7 +60,6 @@ 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);
@ -231,13 +230,11 @@ 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 = contentBlockingEnabled && (Services.prefs.getBoolPref("privacy.trackingprotection.enabled") || Services.prefs.getBoolPref("privacy.trackingprotection.pbmode.enabled"));
this.trackingEnabled = 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");

View File

@ -104,11 +104,9 @@ function checkLoads(aWindow, aBlocked) {
}
SpecialPowers.pushPrefEnv(
{"set": [
["browser.contentblocking.enabled", true],
["privacy.trackingprotection.enabled", false],
["privacy.trackingprotection.pbmode.enabled", true],
]}, test);
{"set": [["privacy.trackingprotection.enabled", false],
["privacy.trackingprotection.pbmode.enabled", true]]},
test);
async function test() {
SimpleTest.registerCleanupFunction(UrlClassifierTestUtils.cleanupTestTrackers);
@ -132,15 +130,6 @@ 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();
}

View File

@ -56,14 +56,8 @@ var alwaysbadids = [
"badscript",
];
function checkLoads(aWindow, aWhitelisted, tpEnabled) {
function checkLoads(aWindow, aWhitelisted) {
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");
@ -115,30 +109,22 @@ async function test() {
SimpleTest.registerCleanupFunction(UrlClassifierTestUtils.cleanupTestTrackers);
await UrlClassifierTestUtils.addTestTrackers();
// 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);
// Load the test from a URL on the whitelist
await testOnWindow(contentPage1).then(function(aWindow) {
checkLoads(aWindow, true);
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, true);
aWindow.close();
});
// Load the test from a URL on the whitelist
await testOnWindow(contentPage1).then(function(aWindow) {
checkLoads(aWindow, true, true);
checkLoads(aWindow, false);
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, true);
checkLoads(aWindow, false);
aWindow.close();
});
await SpecialPowers.clearUserPref("urlclassifier.trackingWhitelistTable");