summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/test/xpcshell/head_sideload.js
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/mozapps/extensions/test/xpcshell/head_sideload.js')
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/head_sideload.js76
1 files changed, 76 insertions, 0 deletions
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());
+}