Bug 1797513 - Remove TCP Toggle/Default rollout prefs. r=pbz,Mardak

Differential Revision: https://phabricator.services.mozilla.com/D162108
This commit is contained in:
Hannah Peuckmann 2022-12-13 09:22:03 +00:00
Родитель dd5464bf82
Коммит e1f9f7bf9e
5 изменённых файлов: 0 добавлений и 749 удалений

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

@ -25,8 +25,6 @@ https_first_disabled = true
https_first_disabled = true https_first_disabled = true
[browser_protectionsUI_cryptominers.js] [browser_protectionsUI_cryptominers.js]
https_first_disabled = true https_first_disabled = true
[browser_protectionsUI_dfpi_rollout.js]
[browser_protectionsUI_dfpi_rollout_phase2.js]
[browser_protectionsUI_fetch.js] [browser_protectionsUI_fetch.js]
https_first_disabled = true https_first_disabled = true
support-files = support-files =

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

@ -1,137 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const { TelemetryTestUtils } = ChromeUtils.import(
"resource://testing-common/TelemetryTestUtils.jsm"
);
ChromeUtils.defineESModuleGetters(this, {
BrowserGlue: "resource:///modules/BrowserGlue.sys.mjs",
});
const PREF_DFPI_ENABLED_BY_DEFAULT =
"privacy.restrict3rdpartystorage.rollout.enabledByDefault";
const COOKIE_BEHAVIOR_PREF = "network.cookie.cookieBehavior";
const defaultPrefs = Services.prefs.getDefaultBranch("");
const previousDefaultCB = defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF);
function cleanup() {
[COOKIE_BEHAVIOR_PREF, PREF_DFPI_ENABLED_BY_DEFAULT].forEach(
Services.prefs.clearUserPref
);
BrowserGlue._defaultCookieBehaviorAtStartup = previousDefaultCB;
defaultPrefs.setIntPref(COOKIE_BEHAVIOR_PREF, previousDefaultCB);
}
// Tests that the dFPI rollout pref updates the default cookieBehavior to 5,
// sets the correct search prefs and records telemetry.
add_task(async function testdFPIRolloutPref() {
// The BrowserGlue code which computes this flag runs before we can set the
// default cookie behavior for this test. Thus we need to overwrite it in
// order for the opt-out to work correctly.
BrowserGlue._defaultCookieBehaviorAtStartup =
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER;
defaultPrefs.setIntPref(
COOKIE_BEHAVIOR_PREF,
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER
);
Services.prefs.setBoolPref(PREF_DFPI_ENABLED_BY_DEFAULT, false);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER
);
Services.prefs.setBoolPref(PREF_DFPI_ENABLED_BY_DEFAULT, true);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN
);
Services.prefs.setBoolPref(PREF_DFPI_ENABLED_BY_DEFAULT, false);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER
);
Services.prefs.setBoolPref(PREF_DFPI_ENABLED_BY_DEFAULT, true);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN
);
cleanup();
});
/**
* Setting the rollout pref to false should revert to the initial default cookie
* behavior, not always BEHAVIOR_REJECT_TRACKER.
*/
add_task(async function testdFPIRolloutPrefNonDefaultCookieBehavior() {
BrowserGlue._defaultCookieBehaviorAtStartup =
Ci.nsICookieService.BEHAVIOR_ACCEPT;
defaultPrefs.setIntPref(
COOKIE_BEHAVIOR_PREF,
Ci.nsICookieService.BEHAVIOR_ACCEPT
);
is(
Services.prefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_ACCEPT,
"Initial cookie behavior should be BEHAVIOR_ACCEPT"
);
Services.prefs.setBoolPref(PREF_DFPI_ENABLED_BY_DEFAULT, true);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
"Default cookie behavior should be set to dFPI."
);
Services.prefs.setBoolPref(PREF_DFPI_ENABLED_BY_DEFAULT, false);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_ACCEPT,
"Default cookie behavior should be set to BEHAVIOR_ACCEPT."
);
cleanup();
});
/**
* When a client already ships with dFPI enabled, toggling the rollout pref
* should not change cookie behavior.
*/
add_task(async function testdFPIRolloutPrefDFPIAlreadyEnabled() {
// Simulate TCP enabled by default.
BrowserGlue._defaultCookieBehaviorAtStartup =
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN;
defaultPrefs.setIntPref(
COOKIE_BEHAVIOR_PREF,
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN
);
is(
Services.prefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
"Initial cookie behavior should be BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN"
);
Services.prefs.setBoolPref(PREF_DFPI_ENABLED_BY_DEFAULT, true);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
"Default cookie behavior should still be BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN."
);
Services.prefs.setBoolPref(PREF_DFPI_ENABLED_BY_DEFAULT, false);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
"Default cookie behavior should still be BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN."
);
cleanup();
});

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

@ -1,526 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const { TelemetryTestUtils } = ChromeUtils.import(
"resource://testing-common/TelemetryTestUtils.jsm"
);
const { ExperimentFakes } = ChromeUtils.import(
"resource://testing-common/NimbusTestUtils.jsm"
);
const { EnterprisePolicyTesting } = ChromeUtils.importESModule(
"resource://testing-common/EnterprisePolicyTesting.sys.mjs"
);
ChromeUtils.defineESModuleGetters(this, {
BrowserGlue: "resource:///modules/BrowserGlue.sys.mjs",
});
const ROLLOUT_PREF_PHASE1 =
"privacy.restrict3rdpartystorage.rollout.enabledByDefault";
const ROLLOUT_PREF_PHASE1_PREFERENCES =
"privacy.restrict3rdpartystorage.rollout.preferences.TCPToggleInStandard";
const COOKIE_BEHAVIOR_PREF = "network.cookie.cookieBehavior";
const CB_CATEGORY_PREF = "browser.contentblocking.category";
const defaultPrefs = Services.prefs.getDefaultBranch("");
const previousDefaultCB = defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF);
// Avoid timeouts on test-macosx1015-64-qr/opt-test-verify-fis-e10s
requestLongerTimeout(2);
function cleanup() {
BrowserGlue._defaultCookieBehaviorAtStartup = previousDefaultCB;
defaultPrefs.setIntPref(COOKIE_BEHAVIOR_PREF, previousDefaultCB);
Services.prefs.clearUserPref(ROLLOUT_PREF_PHASE1);
Services.prefs.clearUserPref(ROLLOUT_PREF_PHASE1_PREFERENCES);
Services.prefs.clearUserPref(CB_CATEGORY_PREF);
}
/**
* Waits for preference to be set and asserts the value.
* @param {string} pref - Preference key.
* @param {*} expectedValue - Expected value of the preference.
* @param {string} message - Assertion message.
*/
async function waitForAndAssertPrefState(pref, expectedValue, message) {
await TestUtils.waitForPrefChange(pref, value => {
if (value != expectedValue) {
return false;
}
is(value, expectedValue, message);
return true;
});
}
// Copied from browser/components/preferences/tests/head.js
async function openPreferencesViaOpenPreferencesAPI(aPane, aOptions) {
let finalPaneEvent = Services.prefs.getBoolPref("identity.fxaccounts.enabled")
? "sync-pane-loaded"
: "privacy-pane-loaded";
let finalPrefPaneLoaded = TestUtils.topicObserved(finalPaneEvent, () => true);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
openPreferences(aPane, aOptions);
let newTabBrowser = gBrowser.selectedBrowser;
if (!newTabBrowser.contentWindow) {
await BrowserTestUtils.waitForEvent(newTabBrowser, "Initialized", true);
await BrowserTestUtils.waitForEvent(newTabBrowser.contentWindow, "load");
await finalPrefPaneLoaded;
}
let win = gBrowser.contentWindow;
let selectedPane = win.history.state;
if (!aOptions || !aOptions.leaveOpen) {
gBrowser.removeCurrentTab();
}
return { selectedPane };
}
async function testPreferencesSectionVisibility(isVisible, message) {
await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
let etpStandardTCPRolloutBox = gBrowser.contentDocument.getElementById(
"etpStandardTCPRolloutBox"
);
if (message) {
info(message);
}
is(
BrowserTestUtils.is_visible(etpStandardTCPRolloutBox),
isVisible,
`Preferences TCP rollout UI in standard is ${
isVisible ? " " : "not "
}visible.`
);
gBrowser.removeCurrentTab();
}
function setDefaultCookieBehavior(cookieBehavior) {
BrowserGlue._defaultCookieBehaviorAtStartup = cookieBehavior;
defaultPrefs.setIntPref(COOKIE_BEHAVIOR_PREF, cookieBehavior);
}
function waitForNimbusFeatureUpdate(feature) {
return new Promise(resolve => {
let callback = () => {
NimbusFeatures[feature].off(callback);
resolve();
};
NimbusFeatures[feature].onUpdate(callback);
});
}
/**
* Tests that enabling the tcpByDefault Nimbus feature changes the default
* cookie behavior to enable TCP.
*/
add_task(async function test_phase2() {
// Disable TCP by default.
setDefaultCookieBehavior(Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER,
"TCP is disabled by default."
);
ok(
!Services.prefs.prefHasUserValue(COOKIE_BEHAVIOR_PREF),
"No user value for cookie behavior."
);
ok(
!NimbusFeatures.tcpByDefault.getVariable("enabled"),
"tcpByDefault Nimbus feature is disabled initially."
);
ok(
!NimbusFeatures.tcpPreferences.getVariable("enabled"),
"tcpPreferences Nimbus feature is disabled initially."
);
await testPreferencesSectionVisibility(
false,
"TCP preferences section should not be visible initially."
);
let cookieBehaviorChange = waitForAndAssertPrefState(
COOKIE_BEHAVIOR_PREF,
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
"Cookie behavior updates to TCP enabled."
);
// Enable Nimbus feature for phase 2.
let doEnrollmentCleanup = await ExperimentFakes.enrollWithFeatureConfig({
featureId: "tcpByDefault",
value: { enabled: true },
});
await cookieBehaviorChange;
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
"TCP is enabled by default."
);
ok(
!Services.prefs.prefHasUserValue(COOKIE_BEHAVIOR_PREF),
"No user value for cookie behavior."
);
ok(
NimbusFeatures.tcpByDefault.getVariable("enabled"),
"tcpByDefault Nimbus feature is enabled."
);
ok(
!NimbusFeatures.tcpPreferences.getVariable("enabled"),
"tcpPreferences Nimbus feature is still disabled."
);
await testPreferencesSectionVisibility(
false,
"Preferences section should still not be visible."
);
await doEnrollmentCleanup();
cleanup();
});
/**
* Tests that phase 2 overrides TCP opt-out choice from phase 1 and that we no
* longer show the preferences section.
*/
add_task(async function test_phase1_opt_out_to_phase2() {
// Disable TCP by default.
setDefaultCookieBehavior(Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER,
"TCP is disabled by default."
);
ok(
!Services.prefs.prefHasUserValue(COOKIE_BEHAVIOR_PREF),
"No user value for cookie behavior."
);
ok(
!NimbusFeatures.tcpByDefault.getVariable("enabled"),
"tcpByDefault Nimbus feature is disabled initially."
);
ok(
!NimbusFeatures.tcpPreferences.getVariable("enabled"),
"tcpPreferences Nimbus feature is disabled initially."
);
await testPreferencesSectionVisibility(
false,
"TCP preferences section should not be visible initially."
);
info("Set the phase 1 rollout pref indicating user opt-out state.");
// This simulates the prefs set when the user opts out via the messaging
// system modal.
Services.prefs.setBoolPref(ROLLOUT_PREF_PHASE1, false);
Services.prefs.setBoolPref(ROLLOUT_PREF_PHASE1_PREFERENCES, true);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER,
`After opt-out TCP is still disabled by default.`
);
ok(
!NimbusFeatures.tcpByDefault.getVariable("enabled"),
"tcpByDefault Nimbus feature is still disabled."
);
ok(
NimbusFeatures.tcpPreferences.getVariable("enabled"),
"tcpPreferences Nimbus feature is enabled after-opt-out."
);
await testPreferencesSectionVisibility(
true,
"Preferences section should be visible after opt-out."
);
let cookieBehaviorChange = waitForAndAssertPrefState(
COOKIE_BEHAVIOR_PREF,
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
"Cookie behavior updates to TCP enabled after tcpByDefault enrollment."
);
// Enable Nimbus feature for phase 2.
let doEnrollmentCleanup = await ExperimentFakes.enrollWithFeatureConfig({
featureId: "tcpByDefault",
value: { enabled: true },
});
await cookieBehaviorChange;
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
"TCP is enabled by default."
);
ok(
!Services.prefs.prefHasUserValue(COOKIE_BEHAVIOR_PREF),
"No user value for cookie behavior."
);
await testPreferencesSectionVisibility(
false,
"Preferences section should no longer be visible."
);
await doEnrollmentCleanup();
cleanup();
});
/**
* Tests that in phase 2 that we no longer show the preferences section if a
* client opted-in in phase 1.
*/
add_task(async function test_phase1_opt_in_to_phase2() {
// Disable TCP by default.
setDefaultCookieBehavior(Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER,
"TCP is disabled by default."
);
ok(
!Services.prefs.prefHasUserValue(COOKIE_BEHAVIOR_PREF),
"No user value for cookie behavior."
);
ok(
!NimbusFeatures.tcpByDefault.getVariable("enabled"),
"tcpByDefault Nimbus feature is disabled initially."
);
ok(
!NimbusFeatures.tcpPreferences.getVariable("enabled"),
"tcpPreferences Nimbus feature is disabled initially."
);
await testPreferencesSectionVisibility(
false,
"TCP preferences section should not be visible initially."
);
info("Set the phase 1 rollout pref indicator user opt-in state.");
// This simulates the prefs set when the user opts-in via the messaging
// system modal.
Services.prefs.setBoolPref(ROLLOUT_PREF_PHASE1, true);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
`TCP is enabled default.`
);
ok(
!NimbusFeatures.tcpByDefault.getVariable("enabled"),
"tcpByDefault Nimbus feature is still disabled."
);
// ROLLOUT_PREF_PHASE1_PREFERENCES controls the tcpPreferences feature state,
// it is the fallback pref defined for the feature..
// ROLLOUT_PREF_PHASE1_PREFERENCES is not set, but the preferences section is
// shown because the rollout pref is set to true.
ok(
!NimbusFeatures.tcpPreferences.getVariable("enabled"),
"tcpPreferences Nimbus feature is disabled after opt-in."
);
await testPreferencesSectionVisibility(
true,
"Preferences section should be visible after opt-in."
);
let featureUpdatePromise = waitForNimbusFeatureUpdate("tcpByDefault");
// Enable Nimbus feature for phase 2.
let doEnrollmentCleanup = await ExperimentFakes.enrollWithFeatureConfig({
featureId: "tcpByDefault",
value: { enabled: true },
});
// We can't await a pref change here since the rollout-pref opt-in has already
// enabled TCP. Enabling the feature will not change the pref state.
// Instead, wait for the Nimbus feature update callback.
await featureUpdatePromise;
ok(
NimbusFeatures.tcpByDefault.getVariable("enabled"),
"tcpByDefault Nimbus feature is now enabled."
);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
"TCP is still enabled by default."
);
ok(
!Services.prefs.prefHasUserValue(COOKIE_BEHAVIOR_PREF),
"No user value for cookie behavior."
);
await testPreferencesSectionVisibility(
false,
"Preferences section should still not be visible."
);
info(
"Changing opt-in choice after phase 2 enrollment should not disable TCP."
);
Services.prefs.setBoolPref(ROLLOUT_PREF_PHASE1, false);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
"TCP is still enabled by default after opt-out."
);
ok(
!Services.prefs.prefHasUserValue(COOKIE_BEHAVIOR_PREF),
"No user value for cookie behavior."
);
Services.prefs.clearUserPref(ROLLOUT_PREF_PHASE1);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
"TCP is still enabled by default after pref clear."
);
ok(
!Services.prefs.prefHasUserValue(COOKIE_BEHAVIOR_PREF),
"No user value for cookie behavior."
);
await doEnrollmentCleanup();
cleanup();
});
/**
* Tests that in phase 2+ we don't target clients with enterprise policy setting
* a cookie behavior.
*/
add_task(async function test_phase2_enterprise_policy_with_cookie_behavior() {
// Disable TCP by default.
setDefaultCookieBehavior(Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER,
"TCP is disabled by default."
);
ok(
!Services.prefs.prefHasUserValue(COOKIE_BEHAVIOR_PREF),
"No user value for cookie behavior."
);
await EnterprisePolicyTesting.setupPolicyEngineWithJson({
policies: {
Cookies: {
Locked: false,
Behavior: "accept",
},
},
});
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_ACCEPT,
"Cookie behavior is set to ACCEPT by enterprise policy."
);
ok(
!Services.prefs.prefHasUserValue(COOKIE_BEHAVIOR_PREF),
"No user value for cookie behavior."
);
// Enable Nimbus feature for phase 2.
let doEnrollmentCleanup = await ExperimentFakes.enrollWithFeatureConfig({
featureId: "tcpByDefault",
value: { enabled: true },
});
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_ACCEPT,
"Cookie behavior is *still* set to ACCEPT_ALL by enterprise policy."
);
ok(
!Services.prefs.prefHasUserValue(COOKIE_BEHAVIOR_PREF),
"No user value for cookie behavior."
);
await doEnrollmentCleanup();
await EnterprisePolicyTesting.setupPolicyEngineWithJson("");
cleanup();
});
/**
* Tests that in phase 2+ still target clients with enterprise policy *not*
* setting a cookie behavior.
*/
add_task(
async function test_phase2_enterprise_policy_without_cookie_behavior() {
// Disable TCP by default.
setDefaultCookieBehavior(Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER,
"TCP is disabled by default."
);
ok(
!Services.prefs.prefHasUserValue(COOKIE_BEHAVIOR_PREF),
"No user value for cookie behavior."
);
await EnterprisePolicyTesting.setupPolicyEngineWithJson({
policies: {
PopupBlocking: {
Locked: true,
},
},
});
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER,
"Cookie behavior is still set to BEHAVIOR_REJECT_TRACKER."
);
ok(
!Services.prefs.prefHasUserValue(COOKIE_BEHAVIOR_PREF),
"No user value for cookie behavior."
);
let cookieBehaviorChange = waitForAndAssertPrefState(
COOKIE_BEHAVIOR_PREF,
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
"Cookie behavior updates to TCP enabled after tcpByDefault enrollment."
);
// Enable Nimbus feature for phase 2.
let doEnrollmentCleanup = await ExperimentFakes.enrollWithFeatureConfig({
featureId: "tcpByDefault",
value: { enabled: true },
});
await cookieBehaviorChange;
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
"TCP is enabled by default."
);
ok(
!Services.prefs.prefHasUserValue(COOKIE_BEHAVIOR_PREF),
"No user value for cookie behavior."
);
await doEnrollmentCleanup();
await EnterprisePolicyTesting.setupPolicyEngineWithJson("");
cleanup();
}
);

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

@ -137,8 +137,6 @@ if (AppConstants.ENABLE_WEBDRIVER) {
} }
const PREF_PDFJS_ISDEFAULT_CACHE_STATE = "pdfjs.enabledCache.state"; const PREF_PDFJS_ISDEFAULT_CACHE_STATE = "pdfjs.enabledCache.state";
const PREF_DFPI_ENABLED_BY_DEFAULT =
"privacy.restrict3rdpartystorage.rollout.enabledByDefault";
const PRIVATE_BROWSING_BINARY = "private_browsing.exe"; const PRIVATE_BROWSING_BINARY = "private_browsing.exe";
// Index of Private Browsing icon in private_browsing.exe // Index of Private Browsing icon in private_browsing.exe
@ -1249,11 +1247,6 @@ BrowserGlue.prototype = {
"browser.contentblocking.features.strict", "browser.contentblocking.features.strict",
this._setPrefExpectationsAndUpdate this._setPrefExpectationsAndUpdate
); );
Services.prefs.removeObserver(
PREF_DFPI_ENABLED_BY_DEFAULT,
this._setDefaultCookieBehavior
);
lazy.NimbusFeatures.tcpByDefault.off(this._setDefaultCookieBehavior);
}, },
// runs on startup, before the first command line handler is invoked // runs on startup, before the first command line handler is invoked
@ -1716,18 +1709,6 @@ BrowserGlue.prototype = {
16 * aWindow.devicePixelRatio 16 * aWindow.devicePixelRatio
); );
// Keep track of the initial default cookie behavior to revert to when
// users opt-out. This is used by _setDefaultCookieBehavior.
BrowserGlue._defaultCookieBehaviorAtStartup = Services.prefs
.getDefaultBranch("")
.getIntPref("network.cookie.cookieBehavior");
// _setDefaultCookieBehavior needs to run before other functions that modify
// privacy preferences such as _setPrefExpectationsAndUpdate and _matchCBCategory
this._setDefaultCookieBehavior();
this._setPrefExpectationsAndUpdate();
this._matchCBCategory();
// This observes the entire privacy.trackingprotection.* pref tree. // This observes the entire privacy.trackingprotection.* pref tree.
Services.prefs.addObserver( Services.prefs.addObserver(
"privacy.trackingprotection", "privacy.trackingprotection",
@ -1777,11 +1758,6 @@ BrowserGlue.prototype = {
"browser.contentblocking.features.strict", "browser.contentblocking.features.strict",
this._setPrefExpectationsAndUpdate this._setPrefExpectationsAndUpdate
); );
Services.prefs.addObserver(
PREF_DFPI_ENABLED_BY_DEFAULT,
this._setDefaultCookieBehavior
);
lazy.NimbusFeatures.tcpByDefault.onUpdate(this._setDefaultCookieBehavior);
}, },
_updateAutoplayPref() { _updateAutoplayPref() {
@ -1795,45 +1771,6 @@ BrowserGlue.prototype = {
} }
}, },
_setDefaultCookieBehavior() {
let defaultPrefs = Services.prefs.getDefaultBranch("");
let hasCookieBehaviorPolicy = () =>
Services.policies.status == Services.policies.ACTIVE &&
Services.policies.getActivePolicies()?.Cookies?.Behavior;
// For phase 2 we enable dFPI / TCP for all clients which are part of the
// rollout.
// Avoid overwriting cookie behavior set by enterprise policy.
if (
lazy.NimbusFeatures.tcpByDefault.getVariable("enabled") &&
!hasCookieBehaviorPolicy()
) {
// Enable TCP by updating the default pref state for cookie behaviour. This
// means we won't override user choice.
defaultPrefs.setIntPref(
"network.cookie.cookieBehavior",
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN
);
return;
}
// For the initial rollout of dFPI, set the default cookieBehavior based on the pref
// set during onboarding when the user chooses to enable protections or not.
if (!Services.prefs.prefHasUserValue(PREF_DFPI_ENABLED_BY_DEFAULT)) {
return;
}
let dFPIEnabled = Services.prefs.getBoolPref(PREF_DFPI_ENABLED_BY_DEFAULT);
defaultPrefs.setIntPref(
"network.cookie.cookieBehavior",
dFPIEnabled
? Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN
: BrowserGlue._defaultCookieBehaviorAtStartup
);
},
_setPrefExpectations() { _setPrefExpectations() {
ContentBlockingCategoriesPrefs.setPrefExpectations(); ContentBlockingCategoriesPrefs.setPrefExpectations();
}, },

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

@ -576,27 +576,6 @@ readerMode:
description: >- description: >-
What version of Pocket CTA to show in Reader Mode (Empty string is no What version of Pocket CTA to show in Reader Mode (Empty string is no
CTA) CTA)
tcpPreferences:
description: "Toggles the Total Cookie Protection section in about:preferences"
owner: tihuang@mozilla.com
hasExposure: false
isEarlyStartup: false
variables:
enabled:
type: boolean
fallbackPref: "privacy.restrict3rdpartystorage.rollout.preferences.TCPToggleInStandard"
description: "Turn on the section in about:preferences"
tcpByDefault:
description: "Enables TCP by default by updating the default pref value of network.cookie.cookieBehavior."
owner: tihuang@mozilla.com
hasExposure: false
isEarlyStartup: true
variables:
enabled:
type: boolean
description: "Enables TCP by default"
cfr: cfr:
description: "A Firefox Messaging System message for the cfr message channel" description: "A Firefox Messaging System message for the cfr message channel"
owner: omc@mozilla.com owner: omc@mozilla.com