Bug 1954128 - Implement enterprise and kiosk policy support for accepting Terms of Service r=mkaply,fluent-reviewers,flod

Differential Revision: https://phabricator.services.mozilla.com/D242171
This commit is contained in:
Meg Viar
2025-03-20 19:32:27 +00:00
parent 9bdab2bee7
commit 2bf5f1ceec
5 changed files with 76 additions and 0 deletions

View File

@@ -2650,6 +2650,18 @@ export var Policies = {
param.Locked
);
}
if (param.SkipTermsOfUse) {
PoliciesUtils.setDefaultPref(
"datareporting.policy.dataSubmissionPolicyAcceptedVersion",
999,
param.Locked
);
PoliciesUtils.setDefaultPref(
"datareporting.policy.dataSubmissionPolicyNotifiedTime",
Date.now().toString(),
param.Locked
);
}
if ("MoreFromMozilla" in param) {
PoliciesUtils.setDefaultPref(
"browser.preferences.moreFromMozilla",

View File

@@ -1538,6 +1538,9 @@
"SkipOnboarding": {
"type": "boolean"
},
"SkipTermsOfUse": {
"type": "boolean"
},
"MoreFromMozilla": {
"type": "boolean"
},

View File

@@ -24,3 +24,34 @@ add_task(async function test_usermessaging() {
ok(firefoxLabsCategory.hidden, "The labs category is hidden");
});
});
add_task(async function test_skip_terms_of_use_timestamp_set() {
const startTime = Date.now();
await setupPolicyEngineWithJson({
policies: {
UserMessaging: {
SkipTermsOfUse: true,
},
},
});
const endTime = Date.now();
Assert.greater(
parseInt(
Services.prefs.getStringPref(
"datareporting.policy.dataSubmissionPolicyNotifiedTime"
)
),
startTime,
"Policy notified time is greater than start time."
);
Assert.greaterOrEqual(
endTime,
parseInt(
Services.prefs.getStringPref(
"datareporting.policy.dataSubmissionPolicyNotifiedTime"
)
),
"Policy notified time is less than or equal to end time."
);
});

View File

@@ -691,6 +691,34 @@ const POLICIES_TESTS = [
},
},
{
policies: {
UserMessaging: {
SkipTermsOfUse: false,
Locked: false,
},
},
unlockedPrefs: {
"datareporting.policy.dataSubmissionPolicyAcceptedVersion": 0,
"datareporting.policy.dataSubmissionPolicyNotifiedTime": "0",
},
},
{
policies: {
UserMessaging: {
SkipTermsOfUse: true,
Locked: true,
},
},
lockedPrefs: {
"datareporting.policy.dataSubmissionPolicyAcceptedVersion": 999,
// "datareporting.policy.dataSubmissionPolicyNotifiedTime" is a string of
// the timestamp at which the policy was set, this is tested in
// browser/components/enterprisepolicies/tests/browser/browser_policy_usermessaging.js
},
},
{
policies: {
UserMessaging: {

View File

@@ -226,6 +226,8 @@ policy-SecurityDevices2 = Add or delete PKCS #11 modules.
policy-ShowHomeButton = Show the home button on the toolbar.
policy-SkipTermsOfUse = Dont show the Terms of Use and Privacy Notice on startup.
policy-SSLVersionMax = Set the maximum SSL version.
policy-SSLVersionMin = Set the minimum SSL version.