diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /toolkit/components/enterprisepolicies/tests/browser/browser_policies_enterprise_only.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/enterprisepolicies/tests/browser/browser_policies_enterprise_only.js')
-rw-r--r-- | toolkit/components/enterprisepolicies/tests/browser/browser_policies_enterprise_only.js | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/toolkit/components/enterprisepolicies/tests/browser/browser_policies_enterprise_only.js b/toolkit/components/enterprisepolicies/tests/browser/browser_policies_enterprise_only.js new file mode 100644 index 0000000000..3da3d250c6 --- /dev/null +++ b/toolkit/components/enterprisepolicies/tests/browser/browser_policies_enterprise_only.js @@ -0,0 +1,70 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const PREF_DISALLOW_ENTERPRISE = "browser.policies.testing.disallowEnterprise"; + +add_task(async function test_enterprise_only_policies() { + let { Policies } = ChromeUtils.importESModule( + "resource:///modules/policies/Policies.sys.mjs" + ); + + let normalPolicyRan = false, + enterprisePolicyRan = false; + + Policies.NormalPolicy = { + onProfileAfterChange(manager, param) { + normalPolicyRan = true; + }, + }; + + Policies.EnterpriseOnlyPolicy = { + onProfileAfterChange(manager, param) { + enterprisePolicyRan = true; + }, + }; + + Services.prefs.setBoolPref(PREF_DISALLOW_ENTERPRISE, true); + + await setupPolicyEngineWithJson( + // policies.json + { + policies: { + NormalPolicy: true, + EnterpriseOnlyPolicy: true, + }, + }, + + // custom schema + { + properties: { + NormalPolicy: { + type: "boolean", + }, + + EnterpriseOnlyPolicy: { + type: "boolean", + enterprise_only: true, + }, + }, + } + ); + + is( + Services.policies.status, + Ci.nsIEnterprisePolicies.ACTIVE, + "Engine is active" + ); + is(normalPolicyRan, true, "Normal policy ran as expected"); + is( + enterprisePolicyRan, + false, + "Enterprise-only policy was prevented from running" + ); + + // Clean-up + delete Policies.NormalPolicy; + delete Policies.EnterpriseOnlyPolicy; + Services.prefs.clearUserPref(PREF_DISALLOW_ENTERPRISE); +}); |