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/xpinstall/browser_corrupt.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/xpinstall/browser_corrupt.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/xpinstall/browser_corrupt.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_corrupt.js b/toolkit/mozapps/extensions/test/xpinstall/browser_corrupt.js new file mode 100644 index 0000000000..2981e11fd7 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_corrupt.js @@ -0,0 +1,53 @@ +// ---------------------------------------------------------------------------- +// Test whether an install fails when the xpi is corrupt. +function test() { + // This test currently depends on InstallTrigger.install availability. + setInstallTriggerPrefs(); + + Harness.downloadFailedCallback = download_failed; + Harness.installsCompletedCallback = finish_test; + Harness.finalContentEvent = "InstallComplete"; + Harness.setup(); + + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); + + var triggers = encodeURIComponent( + JSON.stringify({ + "Corrupt XPI": TESTROOT + "corrupt.xpi", + }) + ); + gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser); + BrowserTestUtils.loadURIString( + gBrowser, + TESTROOT + "installtrigger.html?" + triggers + ); +} + +function download_failed(install) { + is(install.error, AddonManager.ERROR_CORRUPT_FILE, "Install should fail"); +} + +const finish_test = async function (count) { + is(count, 0, "No add-ons should have been installed"); + PermissionTestUtils.remove("http://example.com", "install"); + + const results = await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [], + () => { + return { + return: content.document.getElementById("return").textContent, + status: content.document.getElementById("status").textContent, + }; + } + ); + + is(results.status, "-207", "Callback should have seen the failure"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +}; |