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 /comm/mail/base/test/webextensions/browser_permissions_optional.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-- | comm/mail/base/test/webextensions/browser_permissions_optional.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/comm/mail/base/test/webextensions/browser_permissions_optional.js b/comm/mail/base/test/webextensions/browser_permissions_optional.js new file mode 100644 index 0000000000..750658a8fd --- /dev/null +++ b/comm/mail/base/test/webextensions/browser_permissions_optional.js @@ -0,0 +1,53 @@ +"use strict"; +add_task(async function test_request_permissions_without_prompt() { + async function pageScript() { + const NO_PROMPT_PERM = "activeTab"; + window.addEventListener( + "keypress", + async () => { + let permGranted = await browser.permissions.request({ + permissions: [NO_PROMPT_PERM], + }); + browser.test.assertTrue( + permGranted, + `${NO_PROMPT_PERM} permission was granted.` + ); + let perms = await browser.permissions.getAll(); + browser.test.assertTrue( + perms.permissions.includes(NO_PROMPT_PERM), + `${NO_PROMPT_PERM} permission exists.` + ); + browser.test.sendMessage("permsGranted"); + }, + { once: true } + ); + browser.test.sendMessage("pageReady"); + } + + let extension = ExtensionTestUtils.loadExtension({ + background() { + browser.test.sendMessage("ready", browser.runtime.getURL("page.html")); + }, + files: { + "page.html": `<html><head><script src="page.js"></script></head></html>`, + "page.js": pageScript, + }, + manifest: { + optional_permissions: ["activeTab"], + }, + }); + await extension.startup(); + + let url = await extension.awaitMessage("ready"); + + let tab = openContentTab(url, undefined, null); + await extension.awaitMessage("pageReady"); + await new Promise(resolve => requestAnimationFrame(resolve)); + await BrowserTestUtils.synthesizeMouseAtCenter(tab.browser, {}, tab.browser); + await BrowserTestUtils.synthesizeKey("a", {}, tab.browser); + await extension.awaitMessage("permsGranted"); + await extension.unload(); + + let tabmail = document.getElementById("tabmail"); + tabmail.closeTab(tab); +}); |