diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /toolkit/components/extensions/test/xpcshell/test_ext_permissions.js | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/extensions/test/xpcshell/test_ext_permissions.js')
-rw-r--r-- | toolkit/components/extensions/test/xpcshell/test_ext_permissions.js | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_permissions.js b/toolkit/components/extensions/test/xpcshell/test_ext_permissions.js index 948b75978a..ae6ce3d27e 100644 --- a/toolkit/components/extensions/test/xpcshell/test_ext_permissions.js +++ b/toolkit/components/extensions/test/xpcshell/test_ext_permissions.js @@ -12,8 +12,8 @@ const { ExtensionPermissions } = ChromeUtils.importESModule( Services.prefs.setBoolPref("extensions.manifestV3.enabled", true); -// ExtensionParent.jsm is being imported lazily because when it is imported Services.appinfo will be -// retrieved and cached (as a side-effect of Schemas.jsm being imported), and so Services.appinfo +// ExtensionParent.sys.mjs is being imported lazily because when it is imported Services.appinfo will be +// retrieved and cached (as a side-effect of Schemas.sys.mjs being imported), and so Services.appinfo // will not be returning the version set by AddonTestUtils.createAppInfo and this test will // fail on non-nightly builds (because the cached appinfo.version will be undefined and // AddonManager startup will fail). @@ -704,6 +704,7 @@ const GRANTED_WITHOUT_USER_PROMPT = [ "theme", "unlimitedStorage", "webRequest", + "webRequestAuthProvider", "webRequestBlocking", "webRequestFilterResponse", "webRequestFilterResponse.serviceWorkerScript", @@ -1058,3 +1059,47 @@ add_task(async function test_internal_permissions() { await extension.unload(); }); + +add_task(function test_normalizeOptional() { + const optional1 = { + origins: ["*://site.com/", "*://*.domain.com/"], + permissions: ["downloads", "tabs"], + }; + + function normalize(perms, optional) { + perms = { origins: [], permissions: [], ...perms }; + optional = { origins: [], permissions: [], ...optional }; + return ExtensionPermissions.normalizeOptional(perms, optional); + } + + normalize({ origins: ["http://site.com/"] }, optional1); + normalize({ origins: ["https://site.com/"] }, optional1); + normalize({ origins: ["*://blah.domain.com/"] }, optional1); + normalize({ permissions: ["downloads", "tabs"] }, optional1); + + Assert.throws( + () => normalize({ origins: ["http://www.example.com/"] }, optional1), + /was not declared in the manifest/ + ); + Assert.throws( + () => normalize({ permissions: ["proxy"] }, optional1), + /was not declared in optional_permissions/ + ); + + const optional2 = { + origins: ["<all_urls>", "*://*/*"], + permissions: ["idle", "clipboardWrite"], + }; + + normalize({ origins: ["http://site.com/"] }, optional2); + normalize({ origins: ["https://site.com/"] }, optional2); + normalize({ origins: ["*://blah.domain.com/"] }, optional2); + normalize({ permissions: ["idle", "clipboardWrite"] }, optional2); + + let perms = normalize({ origins: ["<all_urls>"] }, optional2); + equal( + perms.origins.sort().join(), + optional2.origins.sort().join(), + `Expect both "all sites" permissions` + ); +}); |