From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../test/xpcshell/test_system_allowed.js | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 toolkit/mozapps/extensions/test/xpcshell/test_system_allowed.js (limited to 'toolkit/mozapps/extensions/test/xpcshell/test_system_allowed.js') diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_system_allowed.js b/toolkit/mozapps/extensions/test/xpcshell/test_system_allowed.js new file mode 100644 index 0000000000..15e493d86a --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_allowed.js @@ -0,0 +1,54 @@ +// Tests that only allowed built-in system add-ons are loaded on startup. + +createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "0"); + +// Ensure that only allowed add-ons are loaded. +add_task(async function test_allowed_addons() { + // Build the test set + var distroDir = FileUtils.getDir("ProfD", ["sysfeatures"], true); + let xpi = await getSystemAddonXPI(1, "1.0"); + xpi.copyTo(distroDir, "system1@tests.mozilla.org.xpi"); + + xpi = await getSystemAddonXPI(2, "1.0"); + xpi.copyTo(distroDir, "system2@tests.mozilla.org.xpi"); + + xpi = await getSystemAddonXPI(3, "1.0"); + xpi.copyTo(distroDir, "system3@tests.mozilla.org.xpi"); + + registerDirectory("XREAppFeat", distroDir); + + // 1 and 2 are allowed, 3 is not. + let validAddons = { + system: ["system1@tests.mozilla.org", "system2@tests.mozilla.org"], + }; + await overrideBuiltIns(validAddons); + + await promiseStartupManager(); + + let addon = await AddonManager.getAddonByID("system1@tests.mozilla.org"); + notEqual(addon, null); + + addon = await AddonManager.getAddonByID("system2@tests.mozilla.org"); + notEqual(addon, null); + + addon = await AddonManager.getAddonByID("system3@tests.mozilla.org"); + Assert.equal(addon, null); + equal(addon, null); + + // 3 is now allowed, 1 and 2 are not. + validAddons = { system: ["system3@tests.mozilla.org"] }; + await overrideBuiltIns(validAddons); + + await promiseRestartManager(); + + addon = await AddonManager.getAddonByID("system1@tests.mozilla.org"); + equal(addon, null); + + addon = await AddonManager.getAddonByID("system2@tests.mozilla.org"); + equal(addon, null); + + addon = await AddonManager.getAddonByID("system3@tests.mozilla.org"); + notEqual(addon, null); + + await promiseShutdownManager(); +}); -- cgit v1.2.3