Bug 1738227 - Reset parsedPolicies when policy engine is restarted in tests. r=pbz

Differential Revision: https://phabricator.services.mozilla.com/D130115
This commit is contained in:
Mike Kaply 2021-11-02 21:10:38 +00:00
Родитель 50cdffc389
Коммит 7c2358efad
3 изменённых файлов: 16 добавлений и 3 удалений

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

@ -4687,9 +4687,7 @@ var ContentBlockingCategoriesPrefs = {
// If there is a custom policy which changes a related pref, then put the user in custom so
// they still have access to other content blocking prefs, and to keep our default definitions
// from changing.
let policy =
Services.policies.status != Ci.nsIEnterprisePolicies.INACTIVE &&
Services.policies.getActivePolicies();
let policy = Services.policies.getActivePolicies();
if (policy && (policy.EnableTrackingProtection || policy.Cookies)) {
Services.prefs.setStringPref(this.PREF_CB_CATEGORY, "custom");
}

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

@ -249,6 +249,7 @@ EnterprisePoliciesManager.prototype = {
Services.ppmm.sharedData.delete("EnterprisePolicies:DisallowedFeatures");
this._status = Ci.nsIEnterprisePolicies.UNINITIALIZED;
this._parsedPolicies = undefined;
for (let timing of Object.keys(this._callbacks)) {
this._callbacks[timing] = [];
}

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

@ -124,3 +124,17 @@ add_task(async function test_simple_policies() {
delete Policies.simple_policy2;
delete Policies.simple_policy3;
});
add_task(async function test_policy_cleanup() {
await EnterprisePolicyTesting.setupPolicyEngineWithJson("");
is(
Services.policies.getActivePolicies(),
undefined,
"No policies should be defined"
);
is(
Services.policies.status,
Ci.nsIEnterprisePolicies.INACTIVE,
"Engine is inactive at the end of the test"
);
});