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_enabled.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_enabled.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/xpinstall/browser_enabled.js | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_enabled.js b/toolkit/mozapps/extensions/test/xpinstall/browser_enabled.js new file mode 100644 index 0000000000..b8ee1b254f --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_enabled.js @@ -0,0 +1,103 @@ +"use strict"; + +add_setup(async function () { + await SpecialPowers.pushPrefEnv({ + set: [ + ["extensions.InstallTrigger.enabled", true], + ["extensions.InstallTriggerImpl.enabled", true], + // Relax the user input requirements while running this test. + ["xpinstall.userActivation.required", false], + ], + }); +}); + +// Test whether an InstallTrigger.enabled is working +add_task(async function test_enabled() { + await BrowserTestUtils.openNewForegroundTab( + gBrowser, + TESTROOT + "enabled.html" + ); + + let text = await ContentTask.spawn( + gBrowser.selectedBrowser, + undefined, + () => content.document.getElementById("enabled").textContent + ); + + is(text, "true", "installTrigger should have been enabled"); + gBrowser.removeCurrentTab(); +}); + +// Test whether an InstallTrigger.enabled is working +add_task(async function test_disabled() { + Services.prefs.setBoolPref("xpinstall.enabled", false); + await BrowserTestUtils.openNewForegroundTab( + gBrowser, + TESTROOT + "enabled.html" + ); + + let text = await ContentTask.spawn( + gBrowser.selectedBrowser, + undefined, + () => content.document.getElementById("enabled").textContent + ); + + is(text, "false", "installTrigger should have not been enabled"); + Services.prefs.clearUserPref("xpinstall.enabled"); + gBrowser.removeCurrentTab(); +}); + +// Test whether an InstallTrigger.install call fails when xpinstall is disabled +add_task(async function test_disabled2() { + let installDisabledCalled = false; + + Harness.installDisabledCallback = installInfo => { + installDisabledCalled = true; + ok(true, "Saw installation disabled"); + }; + + Harness.installBlockedCallback = installInfo => { + ok(false, "Should never see the blocked install notification"); + return false; + }; + + Harness.installConfirmCallback = panel => { + ok(false, "Should never see an install confirmation dialog"); + return false; + }; + + Harness.setup(); + Services.prefs.setBoolPref("xpinstall.enabled", false); + + var triggers = encodeURIComponent( + JSON.stringify({ + "Unsigned XPI": TESTROOT + "amosigned.xpi", + }) + ); + + BrowserTestUtils.openNewForegroundTab( + gBrowser, + TESTROOT + "installtrigger.html?" + triggers + ); + + await BrowserTestUtils.waitForContentEvent( + gBrowser.selectedBrowser, + "InstallTriggered", + true, + undefined, + true + ); + + let text = await ContentTask.spawn( + gBrowser.selectedBrowser, + undefined, + () => content.document.getElementById("return").textContent + ); + + is(text, "false", "installTrigger should have not been enabled"); + ok(installDisabledCalled, "installDisabled callback was called"); + + Services.prefs.clearUserPref("xpinstall.enabled"); + gBrowser.removeCurrentTab(); + Harness.finish(); +}); |