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/browser/browser_webapi_install_disabled.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/browser/browser_webapi_install_disabled.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/browser/browser_webapi_install_disabled.js b/toolkit/mozapps/extensions/test/browser/browser_webapi_install_disabled.js new file mode 100644 index 0000000000..5bc291fe7a --- /dev/null +++ b/toolkit/mozapps/extensions/test/browser/browser_webapi_install_disabled.js @@ -0,0 +1,60 @@ +const TESTPAGE = `${SECURE_TESTROOT}webapi_checkavailable.html`; +const XPI_URL = `${SECURE_TESTROOT}../xpinstall/amosigned.xpi`; + +function waitForClear() { + const MSG = "WebAPICleanup"; + return new Promise(resolve => { + let listener = { + receiveMessage(msg) { + if (msg.name == MSG) { + Services.mm.removeMessageListener(MSG, listener); + resolve(); + } + }, + }; + + Services.mm.addMessageListener(MSG, listener, true); + }); +} + +add_setup(async function () { + await SpecialPowers.pushPrefEnv({ + set: [ + ["extensions.webapi.testing", true], + ["xpinstall.enabled", false], + ["extensions.install.requireBuiltInCerts", false], + ], + }); + info("added preferences"); +}); + +async function testInstall(browser, args) { + let success = await SpecialPowers.spawn( + browser, + [{ args }], + async function (opts) { + let { args } = opts; + let install; + try { + install = await content.navigator.mozAddonManager.createInstall(args); + } catch (e) {} + return !!install; + } + ); + is(success, false, "Install was blocked"); +} + +add_task(async function () { + // withNewTab() will close the test tab before returning, at which point + // the cleanup event will come from the content process. We need to see + // that event but don't want to race to install a listener for it after + // the tab is closed. So set up the listener now but don't yield the + // listening promise until below. + let clearPromise = waitForClear(); + + await BrowserTestUtils.withNewTab(TESTPAGE, async function (browser) { + await testInstall(browser, { url: XPI_URL }); + }); + + await clearPromise; +}); |