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_upgrade_incompatible.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_upgrade_incompatible.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/xpcshell/test_upgrade_incompatible.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_incompatible.js b/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_incompatible.js new file mode 100644 index 0000000000..b9eb0f31e1 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_incompatible.js @@ -0,0 +1,73 @@ +// Tests that when an extension manifest that was previously valid becomes +// unparseable after an application update, the extension becomes +// disabled. (See bug 1439600 for a concrete example of a situation where +// this happened). +add_task(async function test_upgrade_incompatible() { + const ID = "incompatible-upgrade@tests.mozilla.org"; + + createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); + + await promiseStartupManager(); + + let file = createTempWebExtensionFile({ + manifest: { + browser_specific_settings: { gecko: { id: ID } }, + }, + }); + + let { addon } = await promiseInstallFile(file); + + notEqual(addon, null); + equal(addon.appDisabled, false); + + await promiseShutdownManager(); + + // Create a new, incompatible extension + let newfile = createTempWebExtensionFile({ + manifest: { + browser_specific_settings: { gecko: { id: ID } }, + manifest_version: 1, + }, + }); + + // swap the incompatible extension in for the original + let path = PathUtils.join(gProfD.path, "extensions", `${ID}.xpi`); + let fileInfo = await IOUtils.stat(path); + let timestamp = fileInfo.lastModified; + + await IOUtils.move(newfile.path, path); + await promiseSetExtensionModifiedTime(path, timestamp); + Services.obs.notifyObservers(new FileUtils.File(path), "flush-cache-entry"); + + // Restart. With the change to the DB schema we recompute compatibility. + // With an unparseable manifest the addon should become disabled. + Services.prefs.setIntPref("extensions.databaseSchema", 0); + await promiseStartupManager(); + + addon = await promiseAddonByID(ID); + notEqual(addon, null); + equal(addon.appDisabled, true); + + await promiseShutdownManager(); + + file = createTempWebExtensionFile({ + manifest: { + browser_specific_settings: { gecko: { id: ID } }, + }, + }); + + // swap the old extension back in and check that we don't persist the disabled state forever. + await IOUtils.move(file.path, path); + await promiseSetExtensionModifiedTime(path, timestamp); + Services.obs.notifyObservers(new FileUtils.File(path), "flush-cache-entry"); + + // Restart. With the change to the DB schema we recompute compatibility. + Services.prefs.setIntPref("extensions.databaseSchema", 0); + await promiseStartupManager(); + + addon = await promiseAddonByID(ID); + notEqual(addon, null); + equal(addon.appDisabled, false); + + await promiseShutdownManager(); +}); |