diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /toolkit/mozapps/extensions/test/xpcshell/test_system_update_enterprisepolicy.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/mozapps/extensions/test/xpcshell/test_system_update_enterprisepolicy.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/xpcshell/test_system_update_enterprisepolicy.js | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_system_update_enterprisepolicy.js b/toolkit/mozapps/extensions/test/xpcshell/test_system_update_enterprisepolicy.js new file mode 100644 index 0000000000..2211a35862 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_update_enterprisepolicy.js @@ -0,0 +1,77 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +// This test verifies that system addon updates are correctly blocked by the +// DisableSystemAddonUpdate enterprise policy. + +const { EnterprisePolicyTesting } = ChromeUtils.importESModule( + "resource://testing-common/EnterprisePolicyTesting.sys.mjs" +); + +Services.policies; // Load policy engine + +createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2"); + +let distroDir = FileUtils.getDir("ProfD", ["sysfeatures", "empty"], true); +registerDirectory("XREAppFeat", distroDir); +add_task(() => initSystemAddonDirs()); + +/** + * Defines the set of initial conditions to run the test against. + * + * setup: A task to setup the profile into the initial state. + * initialState: The initial expected system add-on state after setup has run. + * + * These conditions run tests with no updated or default system add-ons + * initially installed + */ +const TEST_CONDITIONS = { + setup() { + clearSystemAddonUpdatesDir(); + distroDir.leafName = "empty"; + }, + initialState: [ + { isUpgrade: false, version: null }, + { isUpgrade: false, version: null }, + { isUpgrade: false, version: null }, + { isUpgrade: false, version: null }, + { isUpgrade: false, version: null }, + ], +}; + +add_task(async function test_update_disabled_by_policy() { + await setupSystemAddonConditions(TEST_CONDITIONS, distroDir); + + await EnterprisePolicyTesting.setupPolicyEngineWithJson({ + policies: { + DisableSystemAddonUpdate: true, + }, + }); + + await updateAllSystemAddons( + buildSystemAddonUpdates([ + { + id: "system2@tests.mozilla.org", + version: "2.0", + path: "system2_2.xpi", + xpi: await getSystemAddonXPI(2, "2.0"), + }, + { + id: "system3@tests.mozilla.org", + version: "2.0", + path: "system3_2.xpi", + xpi: await getSystemAddonXPI(3, "2.0"), + }, + ]) + ); + + await verifySystemAddonState( + TEST_CONDITIONS.initialState, + undefined, + false, + distroDir + ); + + await promiseShutdownManager(); +}); |