Bug 1763660 - Add query parameter stripping pref to ETP strict. r=anti-tracking-reviewers,timhuang

Differential Revision: https://phabricator.services.mozilla.com/D143513
This commit is contained in:
Paul Zuehlcke 2022-05-17 10:42:16 +00:00
Родитель 193f47029e
Коммит ced22621e7
4 изменённых файлов: 72 добавлений и 4 удалений

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

@ -1865,6 +1865,9 @@ pref("browser.contentblocking.reject-and-isolate-cookies.preferences.ui.enabled"
// OCSP cache partitioning:
// "ocsp": OCSP cache partitioning enabled
// "-ocsp": OCSP cache partitioning disabled
// Query parameter stripping:
// "qps": Query parameter stripping enabled
// "-qps": Query parameter stripping disabled
// Cookie behavior:
// "cookieBehavior0": cookie behaviour BEHAVIOR_ACCEPT
// "cookieBehavior1": cookie behaviour BEHAVIOR_REJECT_FOREIGN
@ -1880,7 +1883,7 @@ pref("browser.contentblocking.reject-and-isolate-cookies.preferences.ui.enabled"
// "cookieBehaviorPBM4": cookie behaviour BEHAVIOR_REJECT_TRACKER
// "cookieBehaviorPBM5": cookie behaviour BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN
// One value from each section must be included in the browser.contentblocking.features.strict pref.
pref("browser.contentblocking.features.strict", "tp,tpPrivate,cookieBehavior5,cookieBehaviorPBM5,cm,fp,stp,lvl2,rp,rpTop,ocsp");
pref("browser.contentblocking.features.strict", "tp,tpPrivate,cookieBehavior5,cookieBehaviorPBM5,cm,fp,stp,lvl2,rp,rpTop,ocsp,qps");
// Hide the "Change Block List" link for trackers/tracking content in the custom
// Content Blocking/ETP panel. By default, it will not be visible. There is also

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

@ -1203,6 +1203,10 @@ BrowserGlue.prototype = {
"privacy.partition.network_state.ocsp_cache",
this._matchCBCategory
);
Services.prefs.removeObserver(
"privacy.query_stripping.enabled",
this._matchCBCategory
);
Services.prefs.removeObserver(
ContentBlockingCategoriesPrefs.PREF_CB_CATEGORY,
this._updateCBCategory
@ -1719,6 +1723,10 @@ BrowserGlue.prototype = {
"privacy.partition.network_state.ocsp_cache",
this._matchCBCategory
);
Services.prefs.addObserver(
"privacy.query_stripping.enabled",
this._matchCBCategory
);
Services.prefs.addObserver(
ContentBlockingCategoriesPrefs.PREF_CB_CATEGORY,
this._updateCBCategory
@ -4678,6 +4686,7 @@ var ContentBlockingCategoriesPrefs = {
"network.http.referer.disallowCrossSiteRelaxingDefault": null,
"network.http.referer.disallowCrossSiteRelaxingDefault.top_navigation": null,
"privacy.partition.network_state.ocsp_cache": null,
"privacy.query_stripping.enabled": null,
},
standard: {
"network.cookie.cookieBehavior": null,
@ -4691,6 +4700,7 @@ var ContentBlockingCategoriesPrefs = {
"network.http.referer.disallowCrossSiteRelaxingDefault": null,
"network.http.referer.disallowCrossSiteRelaxingDefault.top_navigation": null,
"privacy.partition.network_state.ocsp_cache": null,
"privacy.query_stripping.enabled": null,
},
};
let type = "strict";
@ -4789,6 +4799,12 @@ var ContentBlockingCategoriesPrefs = {
"privacy.partition.network_state.ocsp_cache"
] = false;
break;
case "qps":
this.CATEGORY_PREFS[type]["privacy.query_stripping.enabled"] = true;
break;
case "-qps":
this.CATEGORY_PREFS[type]["privacy.query_stripping.enabled"] = false;
break;
case "cookieBehavior0":
this.CATEGORY_PREFS[type]["network.cookie.cookieBehavior"] =
Ci.nsICookieService.BEHAVIOR_ACCEPT;

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

@ -19,6 +19,7 @@ const REFERRER_PREF = "network.http.referer.disallowCrossSiteRelaxingDefault";
const REFERRER_TOP_PREF =
"network.http.referer.disallowCrossSiteRelaxingDefault.top_navigation";
const OCSP_PREF = "privacy.partition.network_state.ocsp_cache";
const QUERY_PARAM_STRIP_PREF = "privacy.query_stripping.enabled";
const PREF_TEST_NOTIFICATIONS =
"browser.safebrowsing.test-notifications.enabled";
const STRICT_PREF = "browser.contentblocking.features.strict";
@ -322,6 +323,7 @@ add_task(async function testContentBlockingStandardCategory() {
[REFERRER_PREF]: null,
[REFERRER_TOP_PREF]: null,
[OCSP_PREF]: null,
[QUERY_PARAM_STRIP_PREF]: null,
};
for (let pref in prefs) {
@ -367,6 +369,10 @@ add_task(async function testContentBlockingStandardCategory() {
!Services.prefs.getBoolPref(REFERRER_TOP_PREF)
);
Services.prefs.setBoolPref(OCSP_PREF, !Services.prefs.getBoolPref(OCSP_PREF));
Services.prefs.setBoolPref(
QUERY_PARAM_STRIP_PREF,
!Services.prefs.getBoolPref(QUERY_PARAM_STRIP_PREF)
);
for (let pref in prefs) {
switch (Services.prefs.getPrefType(pref)) {
@ -431,6 +437,7 @@ add_task(async function testContentBlockingStrictCategory() {
Services.prefs.setBoolPref(REFERRER_PREF, false);
Services.prefs.setBoolPref(REFERRER_TOP_PREF, false);
Services.prefs.setBoolPref(OCSP_PREF, false);
Services.prefs.setBoolPref(QUERY_PARAM_STRIP_PREF, false);
Services.prefs.setIntPref(
NCB_PREF,
Ci.nsICookieService.BEHAVIOR_LIMIT_FOREIGN
@ -581,6 +588,20 @@ add_task(async function testContentBlockingStrictCategory() {
`${OCSP_PREF} has been set to false`
);
break;
case "qps":
is(
Services.prefs.getBoolPref(QUERY_PARAM_STRIP_PREF),
true,
`${QUERY_PARAM_STRIP_PREF} has been set to true`
);
break;
case "-qps":
is(
Services.prefs.getBoolPref(QUERY_PARAM_STRIP_PREF),
false,
`${QUERY_PARAM_STRIP_PREF} has been set to false`
);
break;
case "cookieBehavior0":
is(
Services.prefs.getIntPref(NCB_PREF),
@ -687,6 +708,7 @@ add_task(async function testContentBlockingCustomCategory() {
REFERRER_PREF,
REFERRER_TOP_PREF,
OCSP_PREF,
QUERY_PARAM_STRIP_PREF,
];
await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
@ -736,6 +758,7 @@ add_task(async function testContentBlockingCustomCategory() {
REFERRER_PREF,
REFERRER_TOP_PREF,
OCSP_PREF,
QUERY_PARAM_STRIP_PREF,
]) {
Services.prefs.setBoolPref(pref, !Services.prefs.getBoolPref(pref));
await TestUtils.waitForCondition(

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

@ -22,6 +22,7 @@ const REFERRER_PREF = "network.http.referer.disallowCrossSiteRelaxingDefault";
const REFERRER_TOP_PREF =
"network.http.referer.disallowCrossSiteRelaxingDefault.top_navigation";
const OCSP_PREF = "privacy.partition.network_state.ocsp_cache";
const QUERY_PARAM_STRIP_PREF = "privacy.query_stripping.enabled";
const STRICT_DEF_PREF = "browser.contentblocking.features.strict";
// Tests that the content blocking standard category definition is based on the default settings of
@ -80,6 +81,10 @@ add_task(async function testContentBlockingStandardDefinition() {
!Services.prefs.prefHasUserValue(OCSP_PREF),
`${OCSP_PREF} pref has the default value`
);
ok(
!Services.prefs.prefHasUserValue(QUERY_PARAM_STRIP_PREF),
`${QUERY_PARAM_STRIP_PREF} pref has the default value`
);
let defaults = Services.prefs.getDefaultBranch("");
let originalTP = defaults.getBoolPref(TP_PREF);
@ -93,6 +98,7 @@ add_task(async function testContentBlockingStandardDefinition() {
let originalREFERRER = defaults.getBoolPref(REFERRER_PREF);
let originalREFERRERTOP = defaults.getBoolPref(REFERRER_TOP_PREF);
let originalOCSP = defaults.getBoolPref(OCSP_PREF);
let originalQueryParamStrip = defaults.getBoolPref(QUERY_PARAM_STRIP_PREF);
let nonDefaultNCB;
switch (originalNCB) {
@ -124,6 +130,7 @@ add_task(async function testContentBlockingStandardDefinition() {
defaults.setBoolPref(REFERRER_PREF, !originalREFERRER);
defaults.setBoolPref(REFERRER_TOP_PREF, !originalREFERRERTOP);
defaults.setBoolPref(OCSP_PREF, !originalOCSP);
defaults.setBoolPref(QUERY_PARAM_STRIP_PREF, !originalQueryParamStrip);
ok(
!Services.prefs.prefHasUserValue(TP_PREF),
@ -169,6 +176,10 @@ add_task(async function testContentBlockingStandardDefinition() {
!Services.prefs.prefHasUserValue(OCSP_PREF),
`${OCSP_PREF} pref has the default value`
);
ok(
!Services.prefs.prefHasUserValue(QUERY_PARAM_STRIP_PREF),
`${QUERY_PARAM_STRIP_PREF} pref has the default value`
);
// cleanup
defaults.setIntPref(NCB_PREF, originalNCB);
@ -183,6 +194,7 @@ add_task(async function testContentBlockingStandardDefinition() {
defaults.setBoolPref(REFERRER_PREF, originalREFERRER);
defaults.setBoolPref(REFERRER_TOP_PREF, originalREFERRERTOP);
defaults.setBoolPref(OCSP_PREF, originalOCSP);
defaults.setBoolPref(QUERY_PARAM_STRIP_PREF, !originalQueryParamStrip);
});
// Tests that the content blocking strict category definition changes the behavior
@ -193,7 +205,7 @@ add_task(async function testContentBlockingStrictDefinition() {
let originalStrictPref = defaults.getStringPref(STRICT_DEF_PREF);
defaults.setStringPref(
STRICT_DEF_PREF,
"tp,tpPrivate,fp,cm,cookieBehavior0,cookieBehaviorPBM0,stp,lvl2,rp,rpTop,ocsp"
"tp,tpPrivate,fp,cm,cookieBehavior0,cookieBehaviorPBM0,stp,lvl2,rp,rpTop,ocsp,qps"
);
Services.prefs.setStringPref(CAT_PREF, "strict");
is(
@ -208,7 +220,7 @@ add_task(async function testContentBlockingStrictDefinition() {
);
is(
Services.prefs.getStringPref(STRICT_DEF_PREF),
"tp,tpPrivate,fp,cm,cookieBehavior0,cookieBehaviorPBM0,stp,lvl2,rp,rpTop,ocsp",
"tp,tpPrivate,fp,cm,cookieBehavior0,cookieBehaviorPBM0,stp,lvl2,rp,rpTop,ocsp,qps",
`${STRICT_DEF_PREF} changed to what we set.`
);
@ -267,6 +279,11 @@ add_task(async function testContentBlockingStrictDefinition() {
true,
`${OCSP_PREF} pref has been set to true`
);
is(
Services.prefs.getBoolPref(QUERY_PARAM_STRIP_PREF),
true,
`${QUERY_PARAM_STRIP_PREF} pref has been set to true`
);
// Note, if a pref is not listed it will use the default value, however this is only meant as a
// backup if a mistake is made. The UI will not respond correctly.
@ -315,10 +332,14 @@ add_task(async function testContentBlockingStrictDefinition() {
!Services.prefs.prefHasUserValue(OCSP_PREF),
`${OCSP_PREF} pref has the default value`
);
ok(
!Services.prefs.prefHasUserValue(QUERY_PARAM_STRIP_PREF),
`${QUERY_PARAM_STRIP_PREF} pref has the default value`
);
defaults.setStringPref(
STRICT_DEF_PREF,
"-tpPrivate,-fp,-cm,-tp,cookieBehavior3,cookieBehaviorPBM2,-stp,-lvl2,-rp,-ocsp"
"-tpPrivate,-fp,-cm,-tp,cookieBehavior3,cookieBehaviorPBM2,-stp,-lvl2,-rp,-ocsp,-qps"
);
is(
Services.prefs.getBoolPref(TP_PREF),
@ -375,6 +396,11 @@ add_task(async function testContentBlockingStrictDefinition() {
false,
`${OCSP_PREF} pref has been set to false`
);
is(
Services.prefs.getBoolPref(QUERY_PARAM_STRIP_PREF),
false,
`${QUERY_PARAM_STRIP_PREF} pref has been set to false`
);
// cleanup
defaults.setStringPref(STRICT_DEF_PREF, originalStrictPref);