Backed out 7 changesets (bug 1612979) for causing browser chrome failure at browser/disable_app_update/browser_policy_disable_app_update.js

CLOSED TREE

Backed out changeset b65ab84f5403 (bug 1612979)
Backed out changeset 8162219895ea (bug 1612979)
Backed out changeset 975a2ced2917 (bug 1612979)
Backed out changeset c5223f21be3d (bug 1612979)
Backed out changeset 935ee9393b16 (bug 1612979)
Backed out changeset 67b182d75120 (bug 1612979)
Backed out changeset 69cd81740888 (bug 1612979)
This commit is contained in:
Daniel Varga 2020-03-03 19:31:55 +02:00
Родитель 61edf989ef
Коммит 31894db69f
7 изменённых файлов: 16 добавлений и 159 удалений

Просмотреть файл

@ -77,18 +77,6 @@ var Policies = {
},
},
AppAutoUpdate: {
onBeforeUIStartup(manager, param) {
// Logic feels a bit reversed here, but it's correct. If AppAutoUpdate is
// true, we disallow turning off auto updating, and visa versa.
if (param) {
manager.disallowFeature("app-auto-updates-off");
} else {
manager.disallowFeature("app-auto-updates-on");
}
},
},
AppUpdateURL: {
onBeforeAddons(manager, param) {
setDefaultPref("app.update.url", param.href);

Просмотреть файл

@ -17,10 +17,6 @@
}
},
"AppAutoUpdate": {
"type": "boolean"
},
"AppUpdateURL": {
"type": "URL"
},
@ -724,6 +720,9 @@
"type": "number",
"enum": [-1, 0, 1]
},
"app.update.auto": {
"type": "boolean"
},
"browser.bookmarks.autoExportHTML": {
"type": "boolean"
},

Просмотреть файл

@ -16,7 +16,6 @@ support-files =
skip-if = os != 'mac'
[browser_policies_notice_in_aboutpreferences.js]
[browser_policies_setAndLockPref_API.js]
[browser_policy_app_auto_update.js]
[browser_policy_app_update.js]
[browser_policy_block_about.js]
[browser_policy_block_set_desktop_background.js]

Просмотреть файл

@ -1,79 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
ChromeUtils.defineModuleGetter(
this,
"UpdateUtils",
"resource://gre/modules/UpdateUtils.jsm"
);
async function test_app_update_auto(expectedEnabled, expectedLocked) {
let actualEnabled = await UpdateUtils.getAppUpdateAutoEnabled();
is(
actualEnabled,
expectedEnabled,
`Actual auto update enabled setting should match the expected value of ${expectedEnabled}`
);
let actualLocked = UpdateUtils.appUpdateAutoSettingIsLocked();
is(
actualLocked,
expectedLocked,
`Auto update enabled setting ${
expectedLocked ? "should" : "should not"
} be locked`
);
let setSuccess = true;
try {
await UpdateUtils.setAppUpdateAutoEnabled(actualEnabled);
} catch (error) {
setSuccess = false;
}
is(
setSuccess,
!expectedLocked,
`Setting auto update ${expectedLocked ? "should" : "should not"} fail`
);
await BrowserTestUtils.withNewTab("about:preferences", browser => {
is(
browser.contentDocument.getElementById("updateSettingsContainer").hidden,
expectedLocked,
`When auto update ${
expectedLocked ? "is" : "isn't"
} locked, the corresponding preferences entry ${
expectedLocked ? "should" : "shouldn't"
} be hidden`
);
});
}
add_task(async function test_app_auto_update_policy() {
let originalUpdateAutoValue = await UpdateUtils.getAppUpdateAutoEnabled();
registerCleanupFunction(async () => {
await UpdateUtils.setAppUpdateAutoEnabled(originalUpdateAutoValue);
});
await UpdateUtils.setAppUpdateAutoEnabled(true);
await test_app_update_auto(true, false);
await setupPolicyEngineWithJson({
policies: {
AppAutoUpdate: false,
},
});
await test_app_update_auto(false, true);
await setupPolicyEngineWithJson({});
await UpdateUtils.setAppUpdateAutoEnabled(false);
await test_app_update_auto(false, false);
await setupPolicyEngineWithJson({
policies: {
AppAutoUpdate: true,
},
});
await test_app_update_auto(true, true);
});

Просмотреть файл

@ -639,12 +639,10 @@ var gMainPane = {
});
setEventListener("showUpdateHistory", "command", gMainPane.showUpdates);
let updateDisabled =
Services.policies && !Services.policies.isAllowed("appUpdate");
if (updateDisabled || UpdateUtils.appUpdateAutoSettingIsLocked()) {
if (Services.policies && !Services.policies.isAllowed("appUpdate")) {
document.getElementById("updateAllowDescription").hidden = true;
document.getElementById("updateSettingsContainer").hidden = true;
if (updateDisabled && AppConstants.MOZ_MAINTENANCE_SERVICE) {
document.getElementById("updateRadioGroup").hidden = true;
if (AppConstants.MOZ_MAINTENANCE_SERVICE) {
document.getElementById("useService").hidden = true;
}
} else {

Просмотреть файл

@ -11,8 +11,6 @@
policy-3rdparty = Set policies that WebExtensions can access via chrome.storage.managed.
policy-AppAutoUpdate = Enable or disable automatic application update.
policy-AppUpdateURL = Set custom app update URL.
policy-Authentication = Configure integrated authentication for websites that support it.

Просмотреть файл

@ -163,22 +163,12 @@ var UpdateUtils = {
* has selected "Automatically install updates" in about:preferences.
*
* On Windows, this setting is shared across all profiles for the installation
* and is read asynchronously from the file. On other operating systems, this
* and is read asynchrnously from the file. On other operating systems, this
* setting is stored in a pref and is thus a per-profile setting.
*
* @return A Promise that resolves with a boolean.
*/
getAppUpdateAutoEnabled() {
if (Services.policies) {
if (!Services.policies.isAllowed("app-auto-updates-off")) {
// We aren't allowed to turn off auto-update - it is forced on.
return Promise.resolve(true);
}
if (!Services.policies.isAllowed("app-auto-updates-on")) {
// We aren't allowed to turn on auto-update - it is forced off.
return Promise.resolve(false);
}
}
if (AppConstants.platform != "win") {
// On platforms other than Windows the setting is stored in a preference.
let prefValue = Services.prefs.getBoolPref(
@ -240,7 +230,7 @@ var UpdateUtils = {
// Fallthrough for if the value could not be read or migrated.
return DEFAULT_APP_UPDATE_AUTO;
})
.then(maybeUpdateAutoConfigChanged);
.then(maybeUpdateAutoConfigChanged.bind(this));
updateAutoIOPromise = readPromise;
return readPromise;
},
@ -252,13 +242,9 @@ var UpdateUtils = {
* in about:preferences.
*
* On Windows, this setting is shared across all profiles for the installation
* and is written asynchronously to the file. On other operating systems, this
* and is written asynchrnously to the file. On other operating systems, this
* setting is stored in a pref and is thus a per-profile setting.
*
* If this method is called when the setting is locked, the returned promise
* will reject. The lock status can be determined with
* UpdateUtils.appUpdateAutoSettingIsLocked()
*
* @param enabled If set to true, automatic download and installation of
* updates will be enabled. If set to false, this will be
* disabled.
@ -271,20 +257,11 @@ var UpdateUtils = {
* this operation simply sets a pref.
*/
setAppUpdateAutoEnabled(enabledValue) {
if (this.appUpdateAutoSettingIsLocked()) {
return Promise.reject(
"setAppUpdateAutoEnabled: Unable to change value of setting because " +
"it is locked by policy"
);
}
if (AppConstants.platform != "win") {
// Only in Windows do we store the update config in the update directory
let prefValue = !!enabledValue;
Services.prefs.setBoolPref(PREF_APP_UPDATE_AUTO, prefValue);
// Rather than call maybeUpdateAutoConfigChanged, a pref observer has
// been connected to PREF_APP_UPDATE_AUTO. This allows us to catch direct
// changes to the pref (which Firefox shouldn't be doing, but the user
// might do in about:config).
maybeUpdateAutoConfigChanged(prefValue);
return Promise.resolve(prefValue);
}
// Justification for the empty catch statement below:
@ -312,25 +289,10 @@ var UpdateUtils = {
throw e;
}
})
.then(maybeUpdateAutoConfigChanged);
.then(maybeUpdateAutoConfigChanged.bind(this));
updateAutoIOPromise = writePromise;
return writePromise;
},
/**
* This function should be used to determine if the automatic application
* update setting is locked by an enterprise policy
*
* @return true if the automatic update setting is currently locked.
* Otherwise, false.
*/
appUpdateAutoSettingIsLocked() {
return (
Services.policies &&
(!Services.policies.isAllowed("app-auto-updates-off") ||
!Services.policies.isAllowed("app-auto-updates-on"))
);
},
};
// Used for serializing reads and writes of the app update json config file so
@ -360,7 +322,11 @@ async function writeUpdateAutoConfig(enabledValue) {
// Notifies observers if the value of app.update.auto has changed and returns
// the value for app.update.auto.
function maybeUpdateAutoConfigChanged(newValue) {
if (newValue !== updateAutoSettingCachedVal) {
// Don't notify on the first read when updateAutoSettingCachedVal is null.
if (
updateAutoSettingCachedVal !== null &&
newValue != updateAutoSettingCachedVal
) {
updateAutoSettingCachedVal = newValue;
Services.obs.notifyObservers(
null,
@ -370,18 +336,6 @@ function maybeUpdateAutoConfigChanged(newValue) {
}
return newValue;
}
// On non-Windows platforms, the Update Auto Config is still stored as a pref.
// On those platforms, the best way to notify observers of this setting is
// just to propagate it from a pref observer
if (AppConstants.platform != "win") {
Services.prefs.addObserver(
PREF_APP_UPDATE_AUTO,
async (subject, topic, data) => {
let value = await UpdateUtils.getAppUpdateAutoEnabled();
maybeUpdateAutoConfigChanged(value);
}
);
}
/* Get the distribution pref values, from defaults only */
function getDistributionPrefValue(aPrefName) {