Skip to content

Commit f80735f

Browse files
committed
Bug 1861325 - Implement TranslateEnabled enterprise policy r=mkaply,translations-reviewers,fluent-reviewers,bolsson,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D205157
1 parent 7d60f7e commit f80735f

File tree

5 files changed

+67
-0
lines changed

5 files changed

+67
-0
lines changed

browser/components/enterprisepolicies/Policies.sys.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,6 +2392,12 @@ export var Policies = {
23922392
},
23932393
},
23942394

2395+
TranslateEnabled: {
2396+
onBeforeAddons(manager, param) {
2397+
setAndLockPref("browser.translations.enable", param);
2398+
},
2399+
},
2400+
23952401
UserMessaging: {
23962402
onBeforeAddons(manager, param) {
23972403
if ("WhatsNew" in param) {

browser/components/enterprisepolicies/schemas/policies-schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,10 @@
14221422
"required": ["Title", "URL"]
14231423
},
14241424

1425+
"TranslateEnabled": {
1426+
"type": "boolean"
1427+
},
1428+
14251429
"UserMessaging": {
14261430
"type": "object",
14271431
"properties": {

browser/components/enterprisepolicies/tests/browser/browser.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ https_first_disabled = true
117117

118118
["browser_policy_support_menu.js"]
119119

120+
["browser_policy_translateenabled.js"]
121+
120122
["browser_policy_usermessaging.js"]
121123

122124
["browser_policy_websitefilter.js"]
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* Any copyright is dedicated to the Public Domain.
2+
* http://creativecommons.org/publicdomain/zero/1.0/ */
3+
4+
"use strict";
5+
6+
add_setup(async function setup() {
7+
await setupPolicyEngineWithJson({
8+
policies: {
9+
TranslateEnabled: false,
10+
},
11+
});
12+
});
13+
14+
add_task(async function test_translate_pref_disabled() {
15+
is(
16+
Services.prefs.getBoolPref("browser.translations.enable"),
17+
false,
18+
"The translations pref should be disabled when the enterprise policy is active."
19+
);
20+
});
21+
22+
add_task(async function test_translate_button_disabled() {
23+
// Since testing will apply the policy after the browser has already started,
24+
// we will need to open a new window to actually see changes from the policy
25+
let win = await BrowserTestUtils.openNewBrowserWindow();
26+
27+
let appMenuButton = win.document.getElementById("PanelUI-menu-button");
28+
let viewShown = BrowserTestUtils.waitForEvent(
29+
win.PanelUI.mainView,
30+
"ViewShown"
31+
);
32+
33+
appMenuButton.click();
34+
await viewShown;
35+
36+
let translateSiteButton = win.document.getElementById(
37+
"appMenu-translate-button"
38+
);
39+
40+
is(
41+
translateSiteButton.hidden,
42+
true,
43+
"The app-menu translate button should be hidden when the enterprise policy is active."
44+
);
45+
46+
is(
47+
translateSiteButton.disabled,
48+
true,
49+
"The app-menu translate button should be disabled when the enterprise policy is active."
50+
);
51+
52+
await BrowserTestUtils.closeWindow(win);
53+
});

browser/locales/en-US/browser/policies/policies-descriptions.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ policy-StartDownloadsInTempDirectory = Force downloads to start off in a local,
221221
222222
policy-SupportMenu = Add a custom support menu item to the help menu.
223223
224+
policy-TranslateEnabled - Enable or disable webpage translation.
225+
224226
policy-UserMessaging = Don’t show certain messages to the user.
225227
226228
policy-UseSystemPrintDialog = Print using the system print dialog.

0 commit comments

Comments
 (0)