forked from mirrors/gecko-dev
Bug 1919344 - Add isEnterprise check to Services.policies. a=RyanVM
Original Revision: https://phabricator.services.mozilla.com/D222522 Differential Revision: https://phabricator.services.mozilla.com/D233112
This commit is contained in:
parent
b9447ec32f
commit
1348276c1d
3 changed files with 44 additions and 26 deletions
|
|
@ -12,7 +12,7 @@ const { AppConstants } = ChromeUtils.importESModule(
|
||||||
add_task(async function test_telemetry_basic() {
|
add_task(async function test_telemetry_basic() {
|
||||||
await setupPolicyEngineWithJson({
|
await setupPolicyEngineWithJson({
|
||||||
policies: {
|
policies: {
|
||||||
DisableAboutSupport: true,
|
BlockAboutSupport: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -21,6 +21,7 @@ add_task(async function test_telemetry_basic() {
|
||||||
"policies.is_enterprise",
|
"policies.is_enterprise",
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
equal(Services.policies.isEnterprise, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function test_telemetry_just_roots() {
|
add_task(async function test_telemetry_just_roots() {
|
||||||
|
|
@ -37,12 +38,13 @@ add_task(async function test_telemetry_just_roots() {
|
||||||
"policies.is_enterprise",
|
"policies.is_enterprise",
|
||||||
AppConstants.IS_ESR
|
AppConstants.IS_ESR
|
||||||
);
|
);
|
||||||
|
equal(Services.policies.isEnterprise, AppConstants.IS_ESR);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function test_telemetry_roots_plus_policy() {
|
add_task(async function test_telemetry_roots_plus_policy() {
|
||||||
await setupPolicyEngineWithJson({
|
await setupPolicyEngineWithJson({
|
||||||
policies: {
|
policies: {
|
||||||
DisableAboutSupport: true,
|
BlockAboutSupport: true,
|
||||||
Certificates: {
|
Certificates: {
|
||||||
ImportEnterpriseRoots: true,
|
ImportEnterpriseRoots: true,
|
||||||
},
|
},
|
||||||
|
|
@ -54,6 +56,7 @@ add_task(async function test_telemetry_roots_plus_policy() {
|
||||||
"policies.is_enterprise",
|
"policies.is_enterprise",
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
equal(Services.policies.isEnterprise, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function test_telemetry_esr() {
|
add_task(async function test_telemetry_esr() {
|
||||||
|
|
@ -63,6 +66,7 @@ add_task(async function test_telemetry_esr() {
|
||||||
"policies.is_enterprise",
|
"policies.is_enterprise",
|
||||||
AppConstants.IS_ESR
|
AppConstants.IS_ESR
|
||||||
);
|
);
|
||||||
|
equal(Services.policies.isEnterprise, AppConstants.IS_ESR);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function test_telemetry_esr_mac_eol() {
|
add_task(async function test_telemetry_esr_mac_eol() {
|
||||||
|
|
@ -75,6 +79,7 @@ add_task(async function test_telemetry_esr_mac_eol() {
|
||||||
"policies.is_enterprise",
|
"policies.is_enterprise",
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
equal(Services.policies.isEnterprise, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function test_telemetry_esr_win_eol() {
|
add_task(async function test_telemetry_esr_win_eol() {
|
||||||
|
|
@ -87,6 +92,7 @@ add_task(async function test_telemetry_esr_win_eol() {
|
||||||
"policies.is_enterprise",
|
"policies.is_enterprise",
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
equal(Services.policies.isEnterprise, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function test_telemetry_esr_distro() {
|
add_task(async function test_telemetry_esr_distro() {
|
||||||
|
|
@ -99,4 +105,5 @@ add_task(async function test_telemetry_esr_distro() {
|
||||||
"policies.is_enterprise",
|
"policies.is_enterprise",
|
||||||
AppConstants.IS_ESR
|
AppConstants.IS_ESR
|
||||||
);
|
);
|
||||||
|
equal(Services.policies.isEnterprise, AppConstants.IS_ESR);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -124,35 +124,18 @@ EnterprisePoliciesManager.prototype = {
|
||||||
|
|
||||||
this.status = Ci.nsIEnterprisePolicies.ACTIVE;
|
this.status = Ci.nsIEnterprisePolicies.ACTIVE;
|
||||||
this._parsedPolicies = {};
|
this._parsedPolicies = {};
|
||||||
this._reportEnterpriseTelemetry(provider.policies);
|
|
||||||
this._activatePolicies(provider.policies);
|
this._activatePolicies(provider.policies);
|
||||||
|
this._reportEnterpriseTelemetry();
|
||||||
|
|
||||||
Services.prefs.setBoolPref(PREF_POLICIES_APPLIED, true);
|
Services.prefs.setBoolPref(PREF_POLICIES_APPLIED, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
_reportEnterpriseTelemetry(policies = {}) {
|
_reportEnterpriseTelemetry() {
|
||||||
let excludedDistributionIDs = [
|
Services.telemetry.scalarSet(
|
||||||
"mozilla-mac-eol-esr115",
|
"policies.count",
|
||||||
"mozilla-win-eol-esr115",
|
Object.keys(this._parsedPolicies || {}).length
|
||||||
];
|
);
|
||||||
let distroId = Services.prefs
|
Services.telemetry.scalarSet("policies.is_enterprise", this.isEnterprise);
|
||||||
.getDefaultBranch(null)
|
|
||||||
.getCharPref("distribution.id", "");
|
|
||||||
|
|
||||||
let policiesLength = Object.keys(policies).length;
|
|
||||||
|
|
||||||
Services.telemetry.scalarSet("policies.count", policiesLength);
|
|
||||||
|
|
||||||
let isEnterprise =
|
|
||||||
// As we migrate folks to ESR for other reasons (deprecating an OS),
|
|
||||||
// we need to add checks here for distribution IDs.
|
|
||||||
(AppConstants.IS_ESR && !excludedDistributionIDs.includes(distroId)) ||
|
|
||||||
// If there are multiple policies then its enterprise.
|
|
||||||
policiesLength > 1 ||
|
|
||||||
// If ImportEnterpriseRoots isn't the only policy then it's enterprise.
|
|
||||||
(policiesLength && !policies.Certificates?.ImportEnterpriseRoots);
|
|
||||||
|
|
||||||
Services.telemetry.scalarSet("policies.is_enterprise", isEnterprise);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_chooseProvider() {
|
_chooseProvider() {
|
||||||
|
|
@ -472,6 +455,30 @@ EnterprisePoliciesManager.prototype = {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get isEnterprise() {
|
||||||
|
let excludedDistributionIDs = [
|
||||||
|
"mozilla-mac-eol-esr115",
|
||||||
|
"mozilla-win-eol-esr115",
|
||||||
|
];
|
||||||
|
let distroId = Services.prefs
|
||||||
|
.getDefaultBranch(null)
|
||||||
|
.getCharPref("distribution.id", "");
|
||||||
|
|
||||||
|
let policiesLength = Object.keys(this._parsedPolicies || {}).length;
|
||||||
|
|
||||||
|
let isEnterprise =
|
||||||
|
// As we migrate folks to ESR for other reasons (deprecating an OS),
|
||||||
|
// we need to add checks here for distribution IDs.
|
||||||
|
(AppConstants.IS_ESR && !excludedDistributionIDs.includes(distroId)) ||
|
||||||
|
// If there are multiple policies then its enterprise.
|
||||||
|
policiesLength > 1 ||
|
||||||
|
// If ImportEnterpriseRoots isn't the only policy then it's enterprise.
|
||||||
|
(!!policiesLength &&
|
||||||
|
!this._parsedPolicies.Certificates?.ImportEnterpriseRoots);
|
||||||
|
|
||||||
|
return isEnterprise;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let DisallowedFeatures = {};
|
let DisallowedFeatures = {};
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@ interface nsIEnterprisePolicies : nsISupports
|
||||||
const short FAILED = 2;
|
const short FAILED = 2;
|
||||||
|
|
||||||
readonly attribute short status;
|
readonly attribute short status;
|
||||||
|
// We only consider a build to be enterprise when certain conditions are
|
||||||
|
// met. This value is set between profile-do-change and addons-startup,
|
||||||
|
// so it should be usable from most places.
|
||||||
|
readonly attribute short isEnterprise;
|
||||||
|
|
||||||
boolean isAllowed(in ACString feature);
|
boolean isAllowed(in ACString feature);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue