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 --- .../extensions/test/xpcshell/head_sideload.js | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 toolkit/mozapps/extensions/test/xpcshell/head_sideload.js (limited to 'toolkit/mozapps/extensions/test/xpcshell/head_sideload.js') diff --git a/toolkit/mozapps/extensions/test/xpcshell/head_sideload.js b/toolkit/mozapps/extensions/test/xpcshell/head_sideload.js new file mode 100644 index 0000000000..8ff3f2f072 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/head_sideload.js @@ -0,0 +1,76 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/publicdomain/zero/1.0/ + +/* import-globals-from head_addons.js */ + +// Enable all scopes. +Services.prefs.setIntPref("extensions.enabledScopes", AddonManager.SCOPE_ALL); +// Setting this to all enables the same behavior as before disabling sideloading. +// We reset this later after doing some legacy sideloading. +Services.prefs.setIntPref("extensions.sideloadScopes", AddonManager.SCOPE_ALL); +// AddonTestUtils sets this to zero, we need the default value. +Services.prefs.clearUserPref("extensions.autoDisableScopes"); + +createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); + +function getID(n) { + return `${n}@tests.mozilla.org`; +} +function initialVersion(n) { + return `${n}.0`; +} + +// Setup some common extension locations, one in each scope. + +// SCOPE_SYSTEM +const globalDir = gProfD.clone(); +globalDir.append("app-system-share"); +globalDir.append(gAppInfo.ID); +registerDirectory("XRESysSExtPD", globalDir.parent); + +// SCOPE_USER +const userDir = gProfD.clone(); +userDir.append("app-system-user"); +userDir.append(gAppInfo.ID); +registerDirectory("XREUSysExt", userDir.parent); + +// SCOPE_APPLICATION +const addonAppDir = gProfD.clone(); +addonAppDir.append("app-global"); +addonAppDir.append("extensions"); +registerDirectory("XREAddonAppDir", addonAppDir.parent); + +// SCOPE_PROFILE +const profileDir = gProfD.clone(); +profileDir.append("extensions"); + +const scopeDirectories = { + global: globalDir, + user: userDir, + app: addonAppDir, + profile: profileDir, +}; + +const scopeToDir = new Map([ + [AddonManager.SCOPE_SYSTEM, globalDir], + [AddonManager.SCOPE_USER, userDir], + [AddonManager.SCOPE_APPLICATION, addonAppDir], + [AddonManager.SCOPE_PROFILE, profileDir], +]); + +async function createWebExtension(id, version, dir) { + let xpi = AddonTestUtils.createTempWebExtensionFile({ + manifest: { + version, + browser_specific_settings: { gecko: { id } }, + }, + }); + await AddonTestUtils.manuallyInstall(xpi, dir); +} + +function check_startup_changes(aType, aIds) { + let changes = AddonManager.getStartupChanges(aType); + changes = changes.filter(aEl => /@tests.mozilla.org$/.test(aEl)); + + Assert.deepEqual([...aIds].sort(), changes.sort()); +} -- cgit v1.2.3