diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:50 +0000 |
commit | def92d1b8e9d373e2f6f27c366d578d97d8960c6 (patch) | |
tree | 2ef34b9ad8bb9a9220e05d60352558b15f513894 /browser/components/enterprisepolicies/tests/xpcshell | |
parent | Adding debian version 125.0.3-1. (diff) | |
download | firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.tar.xz firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/enterprisepolicies/tests/xpcshell')
6 files changed, 177 insertions, 7 deletions
diff --git a/browser/components/enterprisepolicies/tests/xpcshell/head.js b/browser/components/enterprisepolicies/tests/xpcshell/head.js index 8b81261538..3881760ed4 100644 --- a/browser/components/enterprisepolicies/tests/xpcshell/head.js +++ b/browser/components/enterprisepolicies/tests/xpcshell/head.js @@ -116,7 +116,7 @@ function checkUserPref(prefName, prefValue) { ); } -function checkClearPref(prefName, prefValue) { +function checkClearPref(prefName) { equal( Services.prefs.prefHasUserValue(prefName), false, diff --git a/browser/components/enterprisepolicies/tests/xpcshell/test_extensionsettings.js b/browser/components/enterprisepolicies/tests/xpcshell/test_extensionsettings.js index ee329a65f8..22a6269cce 100644 --- a/browser/components/enterprisepolicies/tests/xpcshell/test_extensionsettings.js +++ b/browser/components/enterprisepolicies/tests/xpcshell/test_extensionsettings.js @@ -21,7 +21,7 @@ let themeID = "policytheme@mozilla.com"; let fileURL; -add_task(async function setup() { +add_setup(async function setup() { await AddonTestUtils.promiseStartupManager(); let webExtensionFile = AddonTestUtils.createTempWebExtensionFile({ @@ -34,6 +34,10 @@ add_task(async function setup() { }, }); + server.registerFile( + "/data/amosigned-sha1only.xpi", + do_get_file("amosigned-sha1only.xpi") + ); server.registerFile("/data/policy_test.xpi", webExtensionFile); fileURL = Services.io .newFileURI(webExtensionFile) @@ -289,3 +293,112 @@ add_task(async function test_addon_normalinstalled_file() { await addon.uninstall(); }); + +add_task(async function test_allow_weak_signatures() { + // Make sure weak signatures are restricted. + const resetWeakSignaturePref = + AddonTestUtils.setWeakSignatureInstallAllowed(false); + + const id = "amosigned-xpi@tests.mozilla.org"; + const perAddonSettings = { + installation_mode: "normal_installed", + install_url: BASE_URL + "/amosigned-sha1only.xpi", + }; + + info( + "Sanity check: expect install to fail if not allowed through enterprise policy settings" + ); + await Promise.all([ + AddonTestUtils.promiseInstallEvent("onDownloadFailed"), + setupPolicyEngineWithJson({ + policies: { + ExtensionSettings: { + [id]: { ...perAddonSettings }, + }, + }, + }), + ]); + let addon = await AddonManager.getAddonByID(id); + equal(addon, null, "Add-on not installed"); + + info( + "Expect install to be allowed through per-addon enterprise policy settings" + ); + await Promise.all([ + AddonTestUtils.promiseInstallEvent("onInstallEnded"), + setupPolicyEngineWithJson({ + policies: { + ExtensionSettings: { + [id]: { + ...perAddonSettings, + temporarily_allow_weak_signatures: true, + }, + }, + }, + }), + ]); + addon = await AddonManager.getAddonByID(id); + notEqual(addon, null, "Add-on not installed"); + await addon.uninstall(); + + info( + "Expect install to be allowed through global enterprise policy settings" + ); + await Promise.all([ + AddonTestUtils.promiseInstallEvent("onInstallEnded"), + setupPolicyEngineWithJson({ + policies: { + ExtensionSettings: { + "*": { temporarily_allow_weak_signatures: true }, + [id]: { ...perAddonSettings }, + }, + }, + }), + ]); + addon = await AddonManager.getAddonByID(id); + notEqual(addon, null, "Add-on installed"); + await addon.uninstall(); + + info( + "Expect install to fail if allowed globally but disallowed by per-addon settings" + ); + await Promise.all([ + AddonTestUtils.promiseInstallEvent("onDownloadFailed"), + setupPolicyEngineWithJson({ + policies: { + ExtensionSettings: { + "*": { temporarily_allow_weak_signatures: true }, + [id]: { + ...perAddonSettings, + temporarily_allow_weak_signatures: false, + }, + }, + }, + }), + ]); + addon = await AddonManager.getAddonByID(id); + equal(addon, null, "Add-on not installed"); + + info( + "Expect install to be allowed through per addon setting when globally disallowed" + ); + await Promise.all([ + AddonTestUtils.promiseInstallEvent("onInstallEnded"), + setupPolicyEngineWithJson({ + policies: { + ExtensionSettings: { + "*": { temporarily_allow_weak_signatures: false }, + [id]: { + ...perAddonSettings, + temporarily_allow_weak_signatures: true, + }, + }, + }, + }), + ]); + addon = await AddonManager.getAddonByID(id); + notEqual(addon, null, "Add-on installed"); + await addon.uninstall(); + + resetWeakSignaturePref(); +}); diff --git a/browser/components/enterprisepolicies/tests/xpcshell/test_requestedlocales.js b/browser/components/enterprisepolicies/tests/xpcshell/test_requestedlocales.js index 5908b2d35c..bfed2491be 100644 --- a/browser/components/enterprisepolicies/tests/xpcshell/test_requestedlocales.js +++ b/browser/components/enterprisepolicies/tests/xpcshell/test_requestedlocales.js @@ -12,7 +12,7 @@ const REQ_LOC_CHANGE_EVENT = "intl:requested-locales-changed"; function promiseLocaleChanged(requestedLocale) { return new Promise(resolve => { let localeObserver = { - observe(aSubject, aTopic, aData) { + observe(aSubject, aTopic) { switch (aTopic) { case REQ_LOC_CHANGE_EVENT: let reqLocs = Services.locale.requestedLocales; @@ -26,10 +26,10 @@ function promiseLocaleChanged(requestedLocale) { }); } -function promiseLocaleNotChanged(requestedLocale) { +function promiseLocaleNotChanged() { return new Promise(resolve => { let localeObserver = { - observe(aSubject, aTopic, aData) { + observe(aSubject, aTopic) { switch (aTopic) { case REQ_LOC_CHANGE_EVENT: ok(false, "Locale should not change."); diff --git a/browser/components/enterprisepolicies/tests/xpcshell/test_simple_pref_policies.js b/browser/components/enterprisepolicies/tests/xpcshell/test_simple_pref_policies.js index 82caee16a7..c0952d0627 100644 --- a/browser/components/enterprisepolicies/tests/xpcshell/test_simple_pref_policies.js +++ b/browser/components/enterprisepolicies/tests/xpcshell/test_simple_pref_policies.js @@ -227,6 +227,10 @@ const POLICIES_TESTS = [ "privacy.clearOnShutdown.sessions": true, "privacy.clearOnShutdown.siteSettings": true, "privacy.clearOnShutdown.offlineApps": true, + "privacy.clearOnShutdown_v2.historyFormDataAndDownloads": true, + "privacy.clearOnShutdown_v2.cookiesAndStorage": true, + "privacy.clearOnShutdown_v2.cache": true, + "privacy.clearOnShutdown_v2.siteSettings": true, }, }, @@ -244,6 +248,10 @@ const POLICIES_TESTS = [ "privacy.clearOnShutdown.sessions": false, "privacy.clearOnShutdown.siteSettings": false, "privacy.clearOnShutdown.offlineApps": false, + "privacy.clearOnShutdown_v2.historyFormDataAndDownloads": false, + "privacy.clearOnShutdown_v2.cookiesAndStorage": false, + "privacy.clearOnShutdown_v2.cache": false, + "privacy.clearOnShutdown_v2.siteSettings": false, }, }, @@ -261,6 +269,9 @@ const POLICIES_TESTS = [ "privacy.clearOnShutdown.formdata": false, "privacy.clearOnShutdown.history": false, "privacy.clearOnShutdown.sessions": false, + "privacy.clearOnShutdown_v2.historyFormDataAndDownloads": false, + "privacy.clearOnShutdown_v2.cookiesAndStorage": false, + "privacy.clearOnShutdown_v2.cache": true, }, }, @@ -278,6 +289,9 @@ const POLICIES_TESTS = [ "privacy.clearOnShutdown.formdata": false, "privacy.clearOnShutdown.history": false, "privacy.clearOnShutdown.sessions": false, + "privacy.clearOnShutdown_v2.historyFormDataAndDownloads": false, + "privacy.clearOnShutdown_v2.cookiesAndStorage": true, + "privacy.clearOnShutdown_v2.cache": false, }, }, @@ -295,6 +309,9 @@ const POLICIES_TESTS = [ "privacy.clearOnShutdown.formdata": false, "privacy.clearOnShutdown.history": false, "privacy.clearOnShutdown.sessions": false, + "privacy.clearOnShutdown_v2.historyFormDataAndDownloads": false, + "privacy.clearOnShutdown_v2.cookiesAndStorage": false, + "privacy.clearOnShutdown_v2.cache": false, }, }, @@ -312,6 +329,9 @@ const POLICIES_TESTS = [ "privacy.clearOnShutdown.formdata": true, "privacy.clearOnShutdown.history": false, "privacy.clearOnShutdown.sessions": false, + "privacy.clearOnShutdown_v2.historyFormDataAndDownloads": false, + "privacy.clearOnShutdown_v2.cookiesAndStorage": false, + "privacy.clearOnShutdown_v2.cache": false, }, }, @@ -329,6 +349,9 @@ const POLICIES_TESTS = [ "privacy.clearOnShutdown.formdata": false, "privacy.clearOnShutdown.history": true, "privacy.clearOnShutdown.sessions": false, + "privacy.clearOnShutdown_v2.historyFormDataAndDownloads": true, + "privacy.clearOnShutdown_v2.cookiesAndStorage": false, + "privacy.clearOnShutdown_v2.cache": false, }, }, @@ -346,6 +369,9 @@ const POLICIES_TESTS = [ "privacy.clearOnShutdown.formdata": false, "privacy.clearOnShutdown.history": false, "privacy.clearOnShutdown.sessions": true, + "privacy.clearOnShutdown_v2.historyFormDataAndDownloads": false, + "privacy.clearOnShutdown_v2.cookiesAndStorage": false, + "privacy.clearOnShutdown_v2.cache": false, }, }, @@ -364,6 +390,10 @@ const POLICIES_TESTS = [ "privacy.clearOnShutdown.history": false, "privacy.clearOnShutdown.sessions": false, "privacy.clearOnShutdown.siteSettings": true, + "privacy.clearOnShutdown_v2.historyFormDataAndDownloads": false, + "privacy.clearOnShutdown_v2.cookiesAndStorage": false, + "privacy.clearOnShutdown_v2.cache": false, + "privacy.clearOnShutdown_v2.siteSettings": true, }, }, @@ -382,6 +412,9 @@ const POLICIES_TESTS = [ "privacy.clearOnShutdown.history": false, "privacy.clearOnShutdown.sessions": false, "privacy.clearOnShutdown.offlineApps": true, + "privacy.clearOnShutdown_v2.historyFormDataAndDownloads": false, + "privacy.clearOnShutdown_v2.cookiesAndStorage": false, + "privacy.clearOnShutdown_v2.cache": false, }, }, @@ -396,6 +429,7 @@ const POLICIES_TESTS = [ lockedPrefs: { "privacy.sanitize.sanitizeOnShutdown": true, "privacy.clearOnShutdown.cache": true, + "privacy.clearOnShutdown_v2.cache": true, }, unlockedPrefs: { "privacy.clearOnShutdown.cookies": false, @@ -403,6 +437,8 @@ const POLICIES_TESTS = [ "privacy.clearOnShutdown.formdata": false, "privacy.clearOnShutdown.history": false, "privacy.clearOnShutdown.sessions": false, + "privacy.clearOnShutdown_v2.historyFormDataAndDownloads": false, + "privacy.clearOnShutdown_v2.cookiesAndStorage": false, }, }, @@ -418,12 +454,15 @@ const POLICIES_TESTS = [ "privacy.sanitize.sanitizeOnShutdown": true, "privacy.clearOnShutdown.cache": true, "privacy.clearOnShutdown.cookies": false, + "privacy.clearOnShutdown_v2.cache": true, + "privacy.clearOnShutdown_v2.cookiesAndStorage": false, }, unlockedPrefs: { "privacy.clearOnShutdown.downloads": false, "privacy.clearOnShutdown.formdata": false, "privacy.clearOnShutdown.history": false, "privacy.clearOnShutdown.sessions": false, + "privacy.clearOnShutdown_v2.historyFormDataAndDownloads": false, }, }, @@ -442,6 +481,9 @@ const POLICIES_TESTS = [ "privacy.clearOnShutdown.formdata": false, "privacy.clearOnShutdown.history": false, "privacy.clearOnShutdown.sessions": false, + "privacy.clearOnShutdown_v2.historyFormDataAndDownloads": false, + "privacy.clearOnShutdown_v2.cookiesAndStorage": false, + "privacy.clearOnShutdown_v2.cache": true, }, }, @@ -1045,6 +1087,18 @@ const POLICIES_TESTS = [ "extensions.formautofill.creditCards.enabled": false, }, }, + + // POLICY: Proxy - locking if no values are set + { + policies: { + Proxy: { + Locked: true, + }, + }, + lockedPrefs: { + "network.proxy.type": 5, + }, + }, ]; add_task(async function test_policy_simple_prefs() { diff --git a/browser/components/enterprisepolicies/tests/xpcshell/test_sorted_alphabetically.js b/browser/components/enterprisepolicies/tests/xpcshell/test_sorted_alphabetically.js index 0d246c850c..73755b1dbc 100644 --- a/browser/components/enterprisepolicies/tests/xpcshell/test_sorted_alphabetically.js +++ b/browser/components/enterprisepolicies/tests/xpcshell/test_sorted_alphabetically.js @@ -32,7 +32,7 @@ add_task(async function test_policies_sorted() { ); checkArrayIsSorted( Object.keys(Policies), - "Policies.jsm is alphabetically sorted." + "Policies.sys.mjs is alphabetically sorted." ); }); diff --git a/browser/components/enterprisepolicies/tests/xpcshell/xpcshell.toml b/browser/components/enterprisepolicies/tests/xpcshell/xpcshell.toml index 69dd3e5103..b21e0f9022 100644 --- a/browser/components/enterprisepolicies/tests/xpcshell/xpcshell.toml +++ b/browser/components/enterprisepolicies/tests/xpcshell/xpcshell.toml @@ -2,7 +2,10 @@ skip-if = ["os == 'android'"] # bug 1730213 firefox-appdir = "browser" head = "head.js" -support-files = ["policytest_v0.1.xpi"] +support-files = [ + "policytest_v0.1.xpi", + "../../../../../toolkit/mozapps/extensions/test/xpinstall/amosigned-sha1only.xpi" +] ["test_3rdparty.js"] |