Bug 1483378 - Part 4: Enable hiding the "reject trackers" menu item based on a preference; r=johannh

This commit is contained in:
Ehsan Akhgari 2018-08-16 13:10:21 -04:00
Родитель 225319893d
Коммит 8e069da931
6 изменённых файлов: 37 добавлений и 2 удалений

Просмотреть файл

@ -1488,6 +1488,7 @@ pref("browser.ping-centre.production.endpoint", "https://tiles.services.mozilla.
pref("media.gmp-provider.enabled", true); pref("media.gmp-provider.enabled", true);
pref("browser.contentblocking.enabled", true); pref("browser.contentblocking.enabled", true);
pref("browser.contentblocking.cookies-site-data.ui.reject-trackers.enabled", true);
pref("browser.contentblocking.cookies-site-data.ui.reject-trackers.recommended", true); pref("browser.contentblocking.cookies-site-data.ui.reject-trackers.recommended", true);
#ifdef NIGHTLY_BUILD #ifdef NIGHTLY_BUILD
pref("browser.contentblocking.ui.enabled", true); pref("browser.contentblocking.ui.enabled", true);

Просмотреть файл

@ -29,6 +29,9 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingCookiesAndSiteDataUi
XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingCookiesAndSiteDataRejectTrackersRecommended", XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingCookiesAndSiteDataRejectTrackersRecommended",
"browser.contentblocking.cookies-site-data.ui.reject-trackers.recommended"); "browser.contentblocking.cookies-site-data.ui.reject-trackers.recommended");
XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingCookiesAndSiteDataRejectTrackersEnabled",
"browser.contentblocking.cookies-site-data.ui.reject-trackers.enabled");
XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingEnabled", XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingEnabled",
"browser.contentblocking.enabled"); "browser.contentblocking.enabled");
@ -531,6 +534,10 @@ var gPrivacyPane = {
if (contentBlockingCookiesAndSiteDataRejectTrackersRecommended) { if (contentBlockingCookiesAndSiteDataRejectTrackersRecommended) {
document.l10n.setAttributes(blockCookiesFromTrackers, "sitedata-block-trackers-option-recommended"); document.l10n.setAttributes(blockCookiesFromTrackers, "sitedata-block-trackers-option-recommended");
} }
// Allow hiding the Reject Trackers option based on a pref
if (!contentBlockingCookiesAndSiteDataRejectTrackersEnabled) {
blockCookiesFromTrackers.remove();
}
} }
}, },

Просмотреть файл

@ -71,6 +71,7 @@ run-if = nightly_build
[browser_privacypane_1.js] [browser_privacypane_1.js]
[browser_privacypane_2.js] [browser_privacypane_2.js]
[browser_privacypane_3.js] [browser_privacypane_3.js]
[browser_privacypane_4.js]
[browser_privacypane_5.js] [browser_privacypane_5.js]
[browser_sanitizeOnShutdown_prefLocked.js] [browser_sanitizeOnShutdown_prefLocked.js]
[browser_searchShowSuggestionsFirst.js] [browser_searchShowSuggestionsFirst.js]

Просмотреть файл

@ -8,7 +8,8 @@ if (jar) {
Services.scriptloader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this); Services.scriptloader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
SpecialPowers.pushPrefEnv({"set": SpecialPowers.pushPrefEnv({"set":
[["browser.contentblocking.cookies-site-data.ui.enabled", true]] [["browser.contentblocking.cookies-site-data.ui.enabled", true],
["browser.contentblocking.cookies-site-data.ui.reject-trackers.enabled", true]]
}); });
run_test_subset([ run_test_subset([

Просмотреть файл

@ -0,0 +1,21 @@
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
let tmpdir = extractJarToTmp(jar);
rootDir = "file://" + tmpdir.path + "/";
}
/* import-globals-from privacypane_tests_perwindow.js */
Services.scriptloader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
SpecialPowers.pushPrefEnv({"set":
[["browser.contentblocking.cookies-site-data.ui.enabled", true],
["browser.contentblocking.cookies-site-data.ui.reject-trackers.enabled", false]]
});
run_test_subset([
test_pane_visibility,
test_dependent_elements,
test_dependent_cookie_elements,
test_dependent_clearonclose_elements,
test_dependent_prefs,
]);

Просмотреть файл

@ -163,7 +163,11 @@ function test_dependent_cookie_elements(win) {
expect_disabled(true, [keepUntil, keepCookiesUntil]); expect_disabled(true, [keepUntil, keepCookiesUntil]);
expect_disabled(false, [blockCookiesLabel, blockCookiesMenu]); expect_disabled(false, [blockCookiesLabel, blockCookiesMenu]);
if (win.contentBlockingCookiesAndSiteDataRejectTrackersEnabled) {
blockCookiesMenu.value = "trackers"; blockCookiesMenu.value = "trackers";
} else {
blockCookiesMenu.value = "unvisited";
}
controlChanged(blockCookiesMenu); controlChanged(blockCookiesMenu);
expect_disabled(false); expect_disabled(false);
} else { } else {