diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /toolkit/mozapps/extensions/test/xpcshell/test_system_repository.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/mozapps/extensions/test/xpcshell/test_system_repository.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/xpcshell/test_system_repository.js | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_system_repository.js b/toolkit/mozapps/extensions/test/xpcshell/test_system_repository.js new file mode 100644 index 0000000000..24ddb257cc --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_repository.js @@ -0,0 +1,68 @@ +// Tests that AddonRepository doesn't download results for system add-ons + +const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled"; + +var gServer = new HttpServer(); +gServer.start(-1); + +createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "0"); + +// Test with a missing features directory +add_task(async function test_app_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); + + Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); + Services.prefs.setCharPref( + PREF_GETADDONS_BYIDS, + `http://localhost:${gServer.identity.primaryPort}/get?%IDS%` + ); + + gServer.registerPathHandler("/get", (request, response) => { + do_throw("Unexpected request to server."); + }); + + await overrideBuiltIns({ + system: [ + "system1@tests.mozilla.org", + "system2@tests.mozilla.org", + "system3@tests.mozilla.org", + ], + }); + + await promiseStartupManager(); + + await AddonRepository.cacheAddons([ + "system1@tests.mozilla.org", + "system2@tests.mozilla.org", + "system3@tests.mozilla.org", + ]); + + let cached = await AddonRepository.getCachedAddonByID( + "system1@tests.mozilla.org" + ); + Assert.equal(cached, null); + + cached = await AddonRepository.getCachedAddonByID( + "system2@tests.mozilla.org" + ); + Assert.equal(cached, null); + + cached = await AddonRepository.getCachedAddonByID( + "system3@tests.mozilla.org" + ); + Assert.equal(cached, null); + + await promiseShutdownManager(); + await new Promise(resolve => gServer.stop(resolve)); +}); |