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_webextension_install_syntax_error.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 '')
-rw-r--r-- | toolkit/mozapps/extensions/test/xpcshell/test_webextension_install_syntax_error.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install_syntax_error.js b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install_syntax_error.js new file mode 100644 index 0000000000..0edc6ec5a4 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install_syntax_error.js @@ -0,0 +1,42 @@ +const ADDON_ID = "webext-test@tests.mozilla.org"; + +add_task(async function setup() { + createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1"); + await promiseStartupManager(); +}); + +add_task(async function install_xpi() { + // WebExtension with a JSON syntax error in manifest.json + let xpi1 = AddonTestUtils.createTempWebExtensionFile({ + files: { + "manifest.json": String.raw`{ + "manifest_version: 2, + "browser_specific_settings": {"gecko": {"id": "${ADDON_ID}"}}, + "name": "Temp WebExt with Error", + "version": "0.1" + }`, + }, + }); + + // Valid WebExtension + let xpi2 = AddonTestUtils.createTempWebExtensionFile({ + files: { + "manifest.json": String.raw`{ + "manifest_version": 2, + "browser_specific_settings": {"gecko": {"id": "${ADDON_ID}"}}, + "name": "Temp WebExt without Error", + "version": "0.1" + }`, + }, + }); + + let install1 = await AddonManager.getInstallForFile(xpi1); + Assert.equal(install1.state, AddonManager.STATE_DOWNLOAD_FAILED); + Assert.equal(install1.error, AddonManager.ERROR_CORRUPT_FILE); + + // Replace xpi1 with xpi2 to have the same filename to reproduce install error + xpi2.moveTo(xpi1.parent, xpi1.leafName); + + let install2 = await AddonManager.getInstallForFile(xpi2); + Assert.equal(install2.error, 0); +}); |