summaryrefslogtreecommitdiffstats
path: root/browser/components/enterprisepolicies/tests
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/enterprisepolicies/tests')
-rw-r--r--browser/components/enterprisepolicies/tests/browser/browser.toml2
-rw-r--r--browser/components/enterprisepolicies/tests/browser/browser_policy_pageinfo_permissions.js4
-rw-r--r--browser/components/enterprisepolicies/tests/browser/browser_policy_translateenabled.js53
-rw-r--r--browser/components/enterprisepolicies/tests/browser/disable_app_update/browser_policy_disable_app_update.js2
-rw-r--r--browser/components/enterprisepolicies/tests/browser/disable_developer_tools/browser_policy_disable_developer_tools.js2
-rw-r--r--browser/components/enterprisepolicies/tests/browser/head.js2
-rw-r--r--browser/components/enterprisepolicies/tests/xpcshell/head.js2
-rw-r--r--browser/components/enterprisepolicies/tests/xpcshell/test_extensionsettings.js115
-rw-r--r--browser/components/enterprisepolicies/tests/xpcshell/test_requestedlocales.js6
-rw-r--r--browser/components/enterprisepolicies/tests/xpcshell/test_simple_pref_policies.js54
-rw-r--r--browser/components/enterprisepolicies/tests/xpcshell/test_sorted_alphabetically.js2
-rw-r--r--browser/components/enterprisepolicies/tests/xpcshell/xpcshell.toml5
12 files changed, 237 insertions, 12 deletions
diff --git a/browser/components/enterprisepolicies/tests/browser/browser.toml b/browser/components/enterprisepolicies/tests/browser/browser.toml
index 25ac681e5b..0517bb6557 100644
--- a/browser/components/enterprisepolicies/tests/browser/browser.toml
+++ b/browser/components/enterprisepolicies/tests/browser/browser.toml
@@ -117,6 +117,8 @@ https_first_disabled = true
["browser_policy_support_menu.js"]
+["browser_policy_translateenabled.js"]
+
["browser_policy_usermessaging.js"]
["browser_policy_websitefilter.js"]
diff --git a/browser/components/enterprisepolicies/tests/browser/browser_policy_pageinfo_permissions.js b/browser/components/enterprisepolicies/tests/browser/browser_policy_pageinfo_permissions.js
index 4921464782..2fc7892c8f 100644
--- a/browser/components/enterprisepolicies/tests/browser/browser_policy_pageinfo_permissions.js
+++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_pageinfo_permissions.js
@@ -58,8 +58,8 @@ add_task(async function test_pageinfo_permissions() {
"xr",
];
- await BrowserTestUtils.withNewTab(TEST_ORIGIN, async function (browser) {
- let pageInfo = BrowserPageInfo(TEST_ORIGIN, "permTab");
+ await BrowserTestUtils.withNewTab(TEST_ORIGIN, async function () {
+ let pageInfo = BrowserCommands.pageInfo(TEST_ORIGIN, "permTab");
await BrowserTestUtils.waitForEvent(pageInfo, "load");
for (let i = 0; i < permissions.length; i++) {
diff --git a/browser/components/enterprisepolicies/tests/browser/browser_policy_translateenabled.js b/browser/components/enterprisepolicies/tests/browser/browser_policy_translateenabled.js
new file mode 100644
index 0000000000..3658cf6388
--- /dev/null
+++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_translateenabled.js
@@ -0,0 +1,53 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_setup(async function setup() {
+ await setupPolicyEngineWithJson({
+ policies: {
+ TranslateEnabled: false,
+ },
+ });
+});
+
+add_task(async function test_translate_pref_disabled() {
+ is(
+ Services.prefs.getBoolPref("browser.translations.enable"),
+ false,
+ "The translations pref should be disabled when the enterprise policy is active."
+ );
+});
+
+add_task(async function test_translate_button_disabled() {
+ // Since testing will apply the policy after the browser has already started,
+ // we will need to open a new window to actually see changes from the policy
+ let win = await BrowserTestUtils.openNewBrowserWindow();
+
+ let appMenuButton = win.document.getElementById("PanelUI-menu-button");
+ let viewShown = BrowserTestUtils.waitForEvent(
+ win.PanelUI.mainView,
+ "ViewShown"
+ );
+
+ appMenuButton.click();
+ await viewShown;
+
+ let translateSiteButton = win.document.getElementById(
+ "appMenu-translate-button"
+ );
+
+ is(
+ translateSiteButton.hidden,
+ true,
+ "The app-menu translate button should be hidden when the enterprise policy is active."
+ );
+
+ is(
+ translateSiteButton.disabled,
+ true,
+ "The app-menu translate button should be disabled when the enterprise policy is active."
+ );
+
+ await BrowserTestUtils.closeWindow(win);
+});
diff --git a/browser/components/enterprisepolicies/tests/browser/disable_app_update/browser_policy_disable_app_update.js b/browser/components/enterprisepolicies/tests/browser/disable_app_update/browser_policy_disable_app_update.js
index 2f68436882..929f0470da 100644
--- a/browser/components/enterprisepolicies/tests/browser/disable_app_update/browser_policy_disable_app_update.js
+++ b/browser/components/enterprisepolicies/tests/browser/disable_app_update/browser_policy_disable_app_update.js
@@ -96,7 +96,7 @@ function waitForAboutDialog() {
var domwindow = aXULWindow.docShell.domWindow;
domwindow.addEventListener("load", aboutDialogOnLoad, true);
},
- onCloseWindow: aXULWindow => {},
+ onCloseWindow: () => {},
};
Services.wm.addListener(listener);
diff --git a/browser/components/enterprisepolicies/tests/browser/disable_developer_tools/browser_policy_disable_developer_tools.js b/browser/components/enterprisepolicies/tests/browser/disable_developer_tools/browser_policy_disable_developer_tools.js
index 27794aabbb..585218a016 100644
--- a/browser/components/enterprisepolicies/tests/browser/disable_developer_tools/browser_policy_disable_developer_tools.js
+++ b/browser/components/enterprisepolicies/tests/browser/disable_developer_tools/browser_policy_disable_developer_tools.js
@@ -73,7 +73,7 @@ async function testPageBlockedByPolicy(page, policyJSON) {
async browser => {
BrowserTestUtils.startLoadingURIString(browser, page);
await BrowserTestUtils.browserLoaded(browser, false, page, true);
- await SpecialPowers.spawn(browser, [page], async function (innerPage) {
+ await SpecialPowers.spawn(browser, [page], async function () {
ok(
content.document.documentURI.startsWith(
"about:neterror?e=blockedByPolicy"
diff --git a/browser/components/enterprisepolicies/tests/browser/head.js b/browser/components/enterprisepolicies/tests/browser/head.js
index bb08173aa9..dfa01fad0e 100644
--- a/browser/components/enterprisepolicies/tests/browser/head.js
+++ b/browser/components/enterprisepolicies/tests/browser/head.js
@@ -237,7 +237,7 @@ async function testPageBlockedByPolicy(page, policyJSON) {
async browser => {
BrowserTestUtils.startLoadingURIString(browser, page);
await BrowserTestUtils.browserLoaded(browser, false, page, true);
- await SpecialPowers.spawn(browser, [page], async function (innerPage) {
+ await SpecialPowers.spawn(browser, [page], async function () {
ok(
content.document.documentURI.startsWith(
"about:neterror?e=blockedByPolicy"
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"]