Bug 1438925 - Select "Never check for updates" in Preferences UI when DisableAppUpdate policy is active r=jaws

MozReview-Commit-ID: 51ZaamngdIP

--HG--
extra : rebase_source : 874221b7047dace7b0f303cdcf58ad4c0800c9b0
This commit is contained in:
Kirk Steuber 2018-02-16 15:48:49 -08:00
parent d3c4d54b03
commit dbf911f4db
3 changed files with 26 additions and 3 deletions

View File

@ -1,5 +1,7 @@
[DEFAULT]
prefs =
app.update.enabled=true
app.update.auto=true
browser.policies.enabled=true
browser.policies.alternatePath='<test-root>/browser/components/enterprisepolicies/tests/browser/disable_app_update/config_disable_app_update.json'
support-files =

View File

@ -12,3 +12,17 @@ add_task(async function test_updates_post_policy() {
is(updateService.canCheckForUpdates, false,
"Should not be able to check for updates with DisableAppUpdate enabled.");
});
add_task(async function test_update_preferences_ui() {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:preferences");
await ContentTask.spawn(tab.linkedBrowser, null, async function() {
let updateRadioGroup = content.document.getElementById("updateRadioGroup");
is(updateRadioGroup.disabled, true,
"Update choices should be diabled when app update is locked by policy");
is(updateRadioGroup.value, "manual",
"Update choice should be set to \"manual\" when app update is disabled by policy");
});
await BrowserTestUtils.removeTab(tab);
});

View File

@ -1421,9 +1421,11 @@ var gMainPane = {
if (AppConstants.MOZ_UPDATER) {
var enabledPref = Preferences.get("app.update.enabled");
var autoPref = Preferences.get("app.update.auto");
let disabledByPolicy = Services.policies &&
!Services.policies.isAllowed("appUpdate");
var radiogroup = document.getElementById("updateRadioGroup");
if (!enabledPref.value) // Don't care for autoPref.value in this case.
if (!enabledPref.value || disabledByPolicy) // Don't care for autoPref.value in this case.
radiogroup.value = "manual"; // 3. Never check for updates.
else if (autoPref.value) // enabledPref.value && autoPref.value
radiogroup.value = "auto"; // 1. Automatically install updates
@ -1436,7 +1438,10 @@ var gMainPane = {
// canCheck is false if the enabledPref is false and locked,
// or the binary platform or OS version is not known.
// A locked pref is sufficient to disable the radiogroup.
radiogroup.disabled = !canCheck || enabledPref.locked || autoPref.locked;
radiogroup.disabled = !canCheck ||
enabledPref.locked ||
autoPref.locked ||
disabledByPolicy;
if (AppConstants.MOZ_MAINTENANCE_SERVICE) {
// Check to see if the maintenance service is installed.
@ -1463,7 +1468,9 @@ var gMainPane = {
* Sets the pref values based on the selected item of the radiogroup.
*/
updateWritePrefs() {
if (AppConstants.MOZ_UPDATER) {
let disabledByPolicy = Services.policies &&
!Services.policies.isAllowed("appUpdate");
if (AppConstants.MOZ_UPDATER && !disabledByPolicy) {
var enabledPref = Preferences.get("app.update.enabled");
var autoPref = Preferences.get("app.update.auto");
var radiogroup = document.getElementById("updateRadioGroup");