diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/components/extensions/test/xpcshell/test_ext_manifest_permissions.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/extensions/test/xpcshell/test_ext_manifest_permissions.js')
-rw-r--r-- | browser/components/extensions/test/xpcshell/test_ext_manifest_permissions.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/browser/components/extensions/test/xpcshell/test_ext_manifest_permissions.js b/browser/components/extensions/test/xpcshell/test_ext_manifest_permissions.js new file mode 100644 index 0000000000..fed7af5d5b --- /dev/null +++ b/browser/components/extensions/test/xpcshell/test_ext_manifest_permissions.js @@ -0,0 +1,85 @@ +/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set sts=2 sw=2 et tw=80: */ +"use strict"; + +/* globals chrome */ + +Services.prefs.setBoolPref("extensions.manifestV3.enabled", true); + +async function testPermission(options) { + function background(bgOptions) { + browser.test.sendMessage("typeof-namespace", { + browser: typeof browser[bgOptions.namespace], + chrome: typeof chrome[bgOptions.namespace], + }); + } + + let extensionDetails = { + background: `(${background})(${JSON.stringify(options)})`, + }; + + let extension = ExtensionTestUtils.loadExtension(extensionDetails); + + await extension.startup(); + + let types = await extension.awaitMessage("typeof-namespace"); + equal( + types.browser, + "undefined", + `Type of browser.${options.namespace} without manifest entry` + ); + equal( + types.chrome, + "undefined", + `Type of chrome.${options.namespace} without manifest entry` + ); + + await extension.unload(); + + extensionDetails.manifest = options.manifest; + extension = ExtensionTestUtils.loadExtension(extensionDetails); + + await extension.startup(); + + types = await extension.awaitMessage("typeof-namespace"); + equal( + types.browser, + "object", + `Type of browser.${options.namespace} with manifest entry` + ); + equal( + types.chrome, + "object", + `Type of chrome.${options.namespace} with manifest entry` + ); + + await extension.unload(); +} + +add_task(async function test_action() { + await testPermission({ + namespace: "action", + manifest: { + manifest_version: 3, + action: {}, + }, + }); +}); + +add_task(async function test_browserAction() { + await testPermission({ + namespace: "browserAction", + manifest: { + browser_action: {}, + }, + }); +}); + +add_task(async function test_pageAction() { + await testPermission({ + namespace: "pageAction", + manifest: { + page_action: {}, + }, + }); +}); |