Backed out 4 changesets (bug 1458308) for causing uiAutoPref.js perma failures CLOSED TREE

Backed out changeset 4bf34689d4b6 (bug 1458308)
Backed out changeset 51e675ce6c56 (bug 1458308)
Backed out changeset 99317c8cd247 (bug 1458308)
Backed out changeset 7370877bd9e1 (bug 1458308)
This commit is contained in:
Ciure Andrei 2018-10-30 20:35:43 +02:00
Родитель c794241681
Коммит 872b1e9fb8
13 изменённых файлов: 23 добавлений и 475 удалений

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

@ -134,15 +134,8 @@ pref("app.update.download.promptMaxAttempts", 2);
pref("app.update.elevation.promptMaxAttempts", 2); pref("app.update.elevation.promptMaxAttempts", 2);
// If set to true, the Update Service will automatically download updates if the // If set to true, the Update Service will automatically download updates if the
// user can apply updates. This pref is no longer used on Windows, except as the // user can apply updates.
// default value to migrate to the new location that this data is now stored
// (which is in a file in the update directory). Because of this, this pref
// should no longer be used directly. Instead,
// nsIUpdateService::getAutoUpdateIsEnabled and
// nsIUpdateService::setAutoUpdateIsEnabled should be used.
#ifndef XP_WIN
pref("app.update.auto", true); pref("app.update.auto", true);
#endif
// If set to true, the Update Service will present no UI for any event. // If set to true, the Update Service will present no UI for any event.
pref("app.update.silent", false); pref("app.update.silent", false);

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

@ -40,7 +40,6 @@ function appUpdater(options = {}) {
this.options = options; this.options = options;
this.updateDeck = document.getElementById("updateDeck"); this.updateDeck = document.getElementById("updateDeck");
this.promiseAutoUpdateSetting = null;
// Hide the update deck when the update window is already open and it's not // Hide the update deck when the update window is already open and it's not
// already applied, to avoid syncing issues between them. Applied updates // already applied, to avoid syncing issues between them. Applied updates
@ -82,9 +81,6 @@ function appUpdater(options = {}) {
return; return;
} }
// We might need this value later, so start loading it from the disk now.
this.promiseAutoUpdateSetting = this.aus.getAutoUpdateIsEnabled();
// That leaves the options // That leaves the options
// "Check for updates, but let me choose whether to install them", and // "Check for updates, but let me choose whether to install them", and
// "Automatically install updates". // "Automatically install updates".
@ -140,6 +136,14 @@ appUpdater.prototype =
gAppUpdater.aus.canStageUpdates; gAppUpdater.aus.canStageUpdates;
}, },
// true when updating is automatic.
get updateAuto() {
try {
return Services.prefs.getBoolPref("app.update.auto");
} catch (e) { }
return true; // Firefox default is true
},
/** /**
* Sets the panel of the updateDeck. * Sets the panel of the updateDeck.
* *
@ -256,16 +260,10 @@ appUpdater.prototype =
return; return;
} }
if (this.promiseAutoUpdateSetting == null) { if (gAppUpdater.updateAuto) // automatically download and install
this.promiseAutoUpdateSetting = this.aus.getAutoUpdateIsEnabled(); gAppUpdater.startDownload();
} else // ask
this.promiseAutoUpdateSetting.then(updateAuto => { gAppUpdater.selectPanel("downloadAndInstall");
if (updateAuto) { // automatically download and install
gAppUpdater.startDownload();
} else { // ask
gAppUpdater.selectPanel("downloadAndInstall");
}
});
}, },
/** /**

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

@ -20,7 +20,6 @@ ChromeUtils.defineModuleGetter(this, "CloudStorage",
"resource://gre/modules/CloudStorage.jsm"); "resource://gre/modules/CloudStorage.jsm");
XPCOMUtils.defineLazyServiceGetters(this, { XPCOMUtils.defineLazyServiceGetters(this, {
gAUS: ["@mozilla.org/updates/update-service;1", "nsIApplicationUpdateService"],
gHandlerService: ["@mozilla.org/uriloader/handler-service;1", "nsIHandlerService"], gHandlerService: ["@mozilla.org/uriloader/handler-service;1", "nsIHandlerService"],
gMIMEService: ["@mozilla.org/mime;1", "nsIMIMEService"], gMIMEService: ["@mozilla.org/mime;1", "nsIMIMEService"],
}); });
@ -44,8 +43,6 @@ const PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS =
// Strings to identify ExtensionSettingsStore overrides // Strings to identify ExtensionSettingsStore overrides
const CONTAINERS_KEY = "privacy.containers"; const CONTAINERS_KEY = "privacy.containers";
const AUTO_UPDATE_CHANGED_TOPIC = "auto-update-config-change";
// The nsHandlerInfoAction enumeration values in nsIHandlerInfo identify // The nsHandlerInfoAction enumeration values in nsIHandlerInfo identify
// the actions the application can take with content of various types. // the actions the application can take with content of various types.
// But since nsIHandlerInfo doesn't support plugins, there's no value // But since nsIHandlerInfo doesn't support plugins, there's no value
@ -178,6 +175,7 @@ if (AppConstants.platform === "win") {
if (AppConstants.MOZ_UPDATER) { if (AppConstants.MOZ_UPDATER) {
Preferences.addAll([ Preferences.addAll([
{ id: "app.update.auto", type: "bool" },
{ id: "app.update.disable_button.showUpdateHistory", type: "bool" }, { id: "app.update.disable_button.showUpdateHistory", type: "bool" },
]); ]);
@ -483,14 +481,6 @@ var gMainPane = {
if (AppConstants.MOZ_MAINTENANCE_SERVICE) { if (AppConstants.MOZ_MAINTENANCE_SERVICE) {
document.getElementById("useService").hidden = true; document.getElementById("useService").hidden = true;
} }
} else {
// Start with no option selected since we are still reading the value
document.getElementById("autoDesktop").removeAttribute("selected");
document.getElementById("manualDesktop").removeAttribute("selected");
// Start reading the correct value from the disk
this.updateReadPrefs();
setEventListener("updateRadioGroup", "command",
gMainPane.updateWritePrefs);
} }
if (AppConstants.MOZ_MAINTENANCE_SERVICE) { if (AppConstants.MOZ_MAINTENANCE_SERVICE) {
@ -519,7 +509,6 @@ var gMainPane = {
// the view when they change. // the view when they change.
Services.prefs.addObserver(PREF_SHOW_PLUGINS_IN_LIST, this); Services.prefs.addObserver(PREF_SHOW_PLUGINS_IN_LIST, this);
Services.prefs.addObserver(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS, this); Services.prefs.addObserver(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS, this);
Services.obs.addObserver(this, AUTO_UPDATE_CHANGED_TOPIC);
setEventListener("filter", "command", gMainPane.filter); setEventListener("filter", "command", gMainPane.filter);
setEventListener("typeColumn", "click", gMainPane.sort); setEventListener("typeColumn", "click", gMainPane.sort);
@ -1285,57 +1274,6 @@ var gMainPane = {
} }
}, },
/**
* Selects the correct item in the update radio group
*/
async updateReadPrefs() {
if (AppConstants.MOZ_UPDATER &&
(!Services.policies || Services.policies.isAllowed("appUpdate"))) {
let radiogroup = document.getElementById("updateRadioGroup");
radiogroup.disabled = true;
try {
let enabled = await gAUS.getAutoUpdateIsEnabled();
radiogroup.value = enabled;
radiogroup.disabled = false;
} catch (error) {
Cu.reportError(error);
}
}
},
/**
* Writes the value of the update radio group to the disk
*/
async updateWritePrefs() {
if (AppConstants.MOZ_UPDATER &&
(!Services.policies || Services.policies.isAllowed("appUpdate"))) {
let radiogroup = document.getElementById("updateRadioGroup");
let updateAutoValue = (radiogroup.value == "true");
radiogroup.disabled = true;
try {
await gAUS.setAutoUpdateIsEnabled(updateAutoValue);
radiogroup.disabled = false;
} catch (error) {
Cu.reportError(error);
await this.updateReadPrefs();
await this.reportUpdatePrefWriteError(error);
}
}
},
async reportUpdatePrefWriteError(error) {
let [title, message] = await document.l10n.formatValues([
{id: "update-pref-write-failure-title"},
{id: "update-pref-write-failure-message", args: {path: error.path}},
]);
// Set up the Ok Button
let buttonFlags = (Services.prompt.BUTTON_POS_0 *
Services.prompt.BUTTON_TITLE_OK);
Services.prompt.confirmEx(window, title, message, buttonFlags,
null, null, null, null, {});
},
/** /**
* Displays the history of installed updates. * Displays the history of installed updates.
*/ */
@ -1349,8 +1287,6 @@ var gMainPane = {
Services.prefs.removeObserver(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS, this); Services.prefs.removeObserver(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS, this);
Services.prefs.removeObserver(PREF_CONTAINERS_EXTENSION, this); Services.prefs.removeObserver(PREF_CONTAINERS_EXTENSION, this);
Services.obs.removeObserver(this, AUTO_UPDATE_CHANGED_TOPIC);
}, },
@ -1381,11 +1317,6 @@ var gMainPane = {
// the view when any of them changes. // the view when any of them changes.
this._rebuildView(); this._rebuildView();
} }
} else if (aTopic == AUTO_UPDATE_CHANGED_TOPIC) {
if (aData != "true" && aData != "false") {
throw new Error("Invalid preference value for app.update.auto");
}
document.getElementById("updateRadioGroup").value = aData;
} }
}, },

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

@ -560,12 +560,11 @@
#ifdef MOZ_UPDATER #ifdef MOZ_UPDATER
<description id="updateAllowDescription" data-l10n-id="update-application-allow-description"></description> <description id="updateAllowDescription" data-l10n-id="update-application-allow-description"></description>
<radiogroup id="updateRadioGroup"> <radiogroup id="updateRadioGroup" preference="app.update.auto">
<radio id="autoDesktop" <radio id="autoDesktop"
value="true" value="true"
data-l10n-id="update-application-auto"/> data-l10n-id="update-application-auto"/>
<radio id="manualDesktop" <radio value="false"
value="false"
data-l10n-id="update-application-check-choose"/> data-l10n-id="update-application-check-choose"/>
</radiogroup> </radiogroup>
#ifdef MOZ_MAINTENANCE_SERVICE #ifdef MOZ_MAINTENANCE_SERVICE

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

@ -360,12 +360,6 @@ update-enable-search-update =
.label = Automatically update search engines .label = Automatically update search engines
.accesskey = e .accesskey = e
update-pref-write-failure-title = Write Failure
# Variables:
# $path (String) - Path to the configuration file
update-pref-write-failure-message = Unable to save preference. Could not write to file: { $path }
## General Section - Performance ## General Section - Performance
performance-title = Performance performance-title = Performance

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

@ -184,6 +184,7 @@ const DEFAULT_ENVIRONMENT_PREFS = new Map([
["accessibility.browsewithcaret", {what: RECORD_PREF_VALUE}], ["accessibility.browsewithcaret", {what: RECORD_PREF_VALUE}],
["accessibility.force_disabled", {what: RECORD_PREF_VALUE}], ["accessibility.force_disabled", {what: RECORD_PREF_VALUE}],
["app.shield.optoutstudies.enabled", {what: RECORD_PREF_VALUE}], ["app.shield.optoutstudies.enabled", {what: RECORD_PREF_VALUE}],
["app.update.auto", {what: RECORD_PREF_VALUE}],
["app.update.interval", {what: RECORD_PREF_VALUE}], ["app.update.interval", {what: RECORD_PREF_VALUE}],
["app.update.service.enabled", {what: RECORD_PREF_VALUE}], ["app.update.service.enabled", {what: RECORD_PREF_VALUE}],
["app.update.silent", {what: RECORD_PREF_VALUE}], ["app.update.silent", {what: RECORD_PREF_VALUE}],
@ -266,6 +267,7 @@ const PREF_DISTRIBUTOR = "app.distributor";
const PREF_DISTRIBUTOR_CHANNEL = "app.distributor.channel"; const PREF_DISTRIBUTOR_CHANNEL = "app.distributor.channel";
const PREF_APP_PARTNER_BRANCH = "app.partner."; const PREF_APP_PARTNER_BRANCH = "app.partner.";
const PREF_PARTNER_ID = "mozilla.partner.id"; const PREF_PARTNER_ID = "mozilla.partner.id";
const PREF_UPDATE_AUTODOWNLOAD = "app.update.auto";
const PREF_SEARCH_COHORT = "browser.search.cohort"; const PREF_SEARCH_COHORT = "browser.search.cohort";
const COMPOSITOR_CREATED_TOPIC = "compositor:created"; const COMPOSITOR_CREATED_TOPIC = "compositor:created";
@ -277,7 +279,6 @@ const SEARCH_SERVICE_TOPIC = "browser-search-service";
const SESSIONSTORE_WINDOWS_RESTORED_TOPIC = "sessionstore-windows-restored"; const SESSIONSTORE_WINDOWS_RESTORED_TOPIC = "sessionstore-windows-restored";
const PREF_CHANGED_TOPIC = "nsPref:changed"; const PREF_CHANGED_TOPIC = "nsPref:changed";
const BLOCKLIST_LOADED_TOPIC = "blocklist-loaded"; const BLOCKLIST_LOADED_TOPIC = "blocklist-loaded";
const AUTO_UPDATE_PREF_CHANGE_TOPIC = "auto-update-config-change";
/** /**
* Enforces the parameter to a boolean value. * Enforces the parameter to a boolean value.
@ -901,7 +902,6 @@ function EnvironmentCache() {
if (AppConstants.MOZ_BUILD_APP == "browser") { if (AppConstants.MOZ_BUILD_APP == "browser") {
p.push(this._loadAttributionAsync()); p.push(this._loadAttributionAsync());
} }
p.push(this._loadAutoUpdateAsync());
for (const [id, {branch, options}] of gActiveExperimentStartupBuffer.entries()) { for (const [id, {branch, options}] of gActiveExperimentStartupBuffer.entries()) {
this.setExperimentActive(id, branch, options); this.setExperimentActive(id, branch, options);
@ -1152,7 +1152,6 @@ EnvironmentCache.prototype = {
Services.obs.addObserver(this, GFX_FEATURES_READY_TOPIC); Services.obs.addObserver(this, GFX_FEATURES_READY_TOPIC);
Services.obs.addObserver(this, SEARCH_ENGINE_MODIFIED_TOPIC); Services.obs.addObserver(this, SEARCH_ENGINE_MODIFIED_TOPIC);
Services.obs.addObserver(this, SEARCH_SERVICE_TOPIC); Services.obs.addObserver(this, SEARCH_SERVICE_TOPIC);
Services.obs.addObserver(this, AUTO_UPDATE_PREF_CHANGE_TOPIC);
}, },
_removeObservers() { _removeObservers() {
@ -1165,7 +1164,6 @@ EnvironmentCache.prototype = {
Services.obs.removeObserver(this, GFX_FEATURES_READY_TOPIC); Services.obs.removeObserver(this, GFX_FEATURES_READY_TOPIC);
Services.obs.removeObserver(this, SEARCH_ENGINE_MODIFIED_TOPIC); Services.obs.removeObserver(this, SEARCH_ENGINE_MODIFIED_TOPIC);
Services.obs.removeObserver(this, SEARCH_SERVICE_TOPIC); Services.obs.removeObserver(this, SEARCH_SERVICE_TOPIC);
Services.obs.removeObserver(this, AUTO_UPDATE_PREF_CHANGE_TOPIC);
}, },
observe(aSubject, aTopic, aData) { observe(aSubject, aTopic, aData) {
@ -1219,9 +1217,6 @@ EnvironmentCache.prototype = {
this._onPrefChanged(aData); this._onPrefChanged(aData);
} }
break; break;
case AUTO_UPDATE_PREF_CHANGE_TOPIC:
this._currentEnvironment.settings.update.autoDownload = (aData == "true");
break;
} }
}, },
@ -1417,6 +1412,7 @@ EnvironmentCache.prototype = {
update: { update: {
channel: updateChannel, channel: updateChannel,
enabled: !Services.policies || Services.policies.isAllowed("appUpdate"), enabled: !Services.policies || Services.policies.isAllowed("appUpdate"),
autoDownload: Services.prefs.getBoolPref(PREF_UPDATE_AUTODOWNLOAD, true),
}, },
userPrefs: this._getPrefData(), userPrefs: this._getPrefData(),
sandbox: this._getSandboxData(), sandbox: this._getSandboxData(),
@ -1428,7 +1424,6 @@ EnvironmentCache.prototype = {
this._updateAttribution(); this._updateAttribution();
this._updateDefaultBrowser(); this._updateDefaultBrowser();
this._updateSearchEngine(); this._updateSearchEngine();
this._updateAutoDownload();
}, },
_getSandboxData() { _getSandboxData() {
@ -1506,27 +1501,6 @@ EnvironmentCache.prototype = {
this._currentEnvironment.settings.attribution = attributionData; this._currentEnvironment.settings.attribution = attributionData;
}, },
/**
* Load the auto update pref and adds it to the environment
*/
async _loadAutoUpdateAsync() {
let aus = Cc["@mozilla.org/updates/update-service;1"]
.getService(Ci.nsIApplicationUpdateService);
this._updateAutoDownloadCache = await aus.getAutoUpdateIsEnabled();
this._updateAutoDownload();
},
/**
* Update the environment with the cached value for whether updates can auto-
* download.
*/
_updateAutoDownload() {
if (this._updateAutoDownloadCache === undefined) {
return;
}
this._currentEnvironment.settings.update.autoDownload = this._updateAutoDownloadCache;
},
/** /**
* Get the partner data in object form. * Get the partner data in object form.
* @return Object containing the partner data. * @return Object containing the partner data.

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

@ -362,48 +362,6 @@ interface nsIApplicationUpdateService : nsISupports
*/ */
readonly attribute boolean canCheckForUpdates; readonly attribute boolean canCheckForUpdates;
/**
* Determines whether or not the Update Service automatically downloads and
* installs updates. This corresponds to whether or not the user has selected
* "Automatically install updates" in about:preferences.
*
* On Windows, this setting is shared across all profiles for the
* installation. On other operating systems, this setting is stored in a pref
* and is thus a per-profile setting.
*
* Note: On Windows, this setting is stored in a file on the disk, so this
* operation involves reading that file.
*
* @return A Promise that resolves with a boolean.
*/
jsval getAutoUpdateIsEnabled();
/**
* Toggles whether the Update Service automatically downloads and installs
* updates. This effectively selects between the "Automatically install
* updates" and "Check for updates but let you choose to install them" options
* in about:preferences.
*
* On Windows, this setting is shared across all profiles for the
* installation. On other operating systems, this setting is stored in a pref
* and is thus a per-profile setting.
*
* Note: On Windows, this setting is stored in a file on disk, so this
* operation involves writing to that file.
*
* @param enabled If set to true, automatic download and installation of
* updates will be enabled. If set to false, this will be
* disabled.
* @return A Promise that, once the setting has been saved, resolves with the
* boolean value that was saved. If the setting could not be
* successfully saved, the Promise will reject.
* On Windows, where this setting is stored in a file, this Promise
* may reject with an I/O error.
* On other operating systems, this promise should not reject as
* this operation simply sets a pref.
*/
jsval setAutoUpdateIsEnabled(in boolean enabled);
/** /**
* Whether or not the installation requires elevation. Currently only * Whether or not the installation requires elevation. Currently only
* implemented on OSX, returns false on other platforms. * implemented on OSX, returns false on other platforms.

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

@ -12,19 +12,12 @@ ChromeUtils.import("resource://gre/modules/Services.jsm", this);
ChromeUtils.import("resource://gre/modules/ctypes.jsm", this); ChromeUtils.import("resource://gre/modules/ctypes.jsm", this);
ChromeUtils.import("resource://gre/modules/UpdateTelemetry.jsm", this); ChromeUtils.import("resource://gre/modules/UpdateTelemetry.jsm", this);
ChromeUtils.import("resource://gre/modules/AppConstants.jsm", this); ChromeUtils.import("resource://gre/modules/AppConstants.jsm", this);
ChromeUtils.import("resource://gre/modules/osfile.jsm", this);
XPCOMUtils.defineLazyGlobalGetters(this, ["DOMParser", "XMLHttpRequest"]); XPCOMUtils.defineLazyGlobalGetters(this, ["DOMParser", "XMLHttpRequest"]);
const UPDATESERVICE_CID = Components.ID("{B3C290A6-3943-4B89-8BBE-C01EB7B3B311}"); const UPDATESERVICE_CID = Components.ID("{B3C290A6-3943-4B89-8BBE-C01EB7B3B311}");
const PREF_APP_UPDATE_ALTWINDOWTYPE = "app.update.altwindowtype"; const PREF_APP_UPDATE_ALTWINDOWTYPE = "app.update.altwindowtype";
// Do not use PREF_APP_UPDATE_AUTO directly! Call getAutoUpdateIsEnabled or
// setAutoUpdateIsEnabled.
// See nsIApplicationUpdateService::getAutoUpdateIsEnabled and
// nsIApplicationUpdateService::setAutoUpdateIsEnabled in nsIUpdateService.idl
// for additional details.
const PREF_APP_UPDATE_AUTO = "app.update.auto"; const PREF_APP_UPDATE_AUTO = "app.update.auto";
const PREF_APP_UPDATE_AUTO_MIGRATED = "app.update.auto.migrated";
const PREF_APP_UPDATE_BACKGROUNDINTERVAL = "app.update.download.backgroundInterval"; const PREF_APP_UPDATE_BACKGROUNDINTERVAL = "app.update.download.backgroundInterval";
const PREF_APP_UPDATE_BACKGROUNDERRORS = "app.update.backgroundErrors"; const PREF_APP_UPDATE_BACKGROUNDERRORS = "app.update.backgroundErrors";
const PREF_APP_UPDATE_BACKGROUNDMAXERRORS = "app.update.backgroundMaxErrors"; const PREF_APP_UPDATE_BACKGROUNDMAXERRORS = "app.update.backgroundMaxErrors";
@ -53,14 +46,6 @@ const PREF_APP_UPDATE_SOCKET_RETRYTIMEOUT = "app.update.socket.retryTimeout";
const PREF_APP_UPDATE_STAGING_ENABLED = "app.update.staging.enabled"; const PREF_APP_UPDATE_STAGING_ENABLED = "app.update.staging.enabled";
const PREF_APP_UPDATE_URL = "app.update.url"; const PREF_APP_UPDATE_URL = "app.update.url";
const PREF_APP_UPDATE_URL_DETAILS = "app.update.url.details"; const PREF_APP_UPDATE_URL_DETAILS = "app.update.url.details";
// Note that although this value has the same format as those above, it is very
// different. It is not stored as part of the user's prefs. Instead it is stored
// in the file indicated by FILE_UPDATE_CONFIG_JSON , which will be located in
// the update directory. This allows it to be accessible from all Firefox
// profiles and from the Background Update Agent.
const CONFIG_APP_UPDATE_AUTO = "app.update.auto";
// The default value for the above setting
const DEFAULT_APP_UPDATE_AUTO = true;
const URI_BRAND_PROPERTIES = "chrome://branding/locale/brand.properties"; const URI_BRAND_PROPERTIES = "chrome://branding/locale/brand.properties";
const URI_UPDATE_HISTORY_DIALOG = "chrome://mozapps/content/update/history.xul"; const URI_UPDATE_HISTORY_DIALOG = "chrome://mozapps/content/update/history.xul";
@ -77,7 +62,6 @@ const FILE_ACTIVE_UPDATE_XML = "active-update.xml";
const FILE_BACKUP_UPDATE_LOG = "backup-update.log"; const FILE_BACKUP_UPDATE_LOG = "backup-update.log";
const FILE_LAST_UPDATE_LOG = "last-update.log"; const FILE_LAST_UPDATE_LOG = "last-update.log";
const FILE_UPDATES_XML = "updates.xml"; const FILE_UPDATES_XML = "updates.xml";
const FILE_UPDATE_CONFIG_JSON = "update-config.json";
const FILE_UPDATE_LOG = "update.log"; const FILE_UPDATE_LOG = "update.log";
const FILE_UPDATE_MAR = "update.mar"; const FILE_UPDATE_MAR = "update.mar";
const FILE_UPDATE_STATUS = "update.status"; const FILE_UPDATE_STATUS = "update.status";
@ -230,8 +214,6 @@ XPCOMUtils.defineLazyGetter(this, "gUpdateBundle", function aus_gUpdateBundle()
return Services.strings.createBundle(URI_UPDATES_PROPERTIES); return Services.strings.createBundle(URI_UPDATES_PROPERTIES);
}); });
XPCOMUtils.defineLazyGetter(this, "gTextDecoder", () => new TextDecoder());
/** /**
* Tests to make sure that we can write to a given directory. * Tests to make sure that we can write to a given directory.
* *
@ -2098,10 +2080,8 @@ UpdateService.prototype = {
// Histogram IDs: // Histogram IDs:
// UPDATE_NOT_PREF_UPDATE_AUTO_EXTERNAL // UPDATE_NOT_PREF_UPDATE_AUTO_EXTERNAL
// UPDATE_NOT_PREF_UPDATE_AUTO_NOTIFY // UPDATE_NOT_PREF_UPDATE_AUTO_NOTIFY
this.getAutoUpdateIsEnabled().then(enabled => { AUSTLMY.pingBoolPref("UPDATE_NOT_PREF_UPDATE_AUTO_" + this._pingSuffix,
AUSTLMY.pingGeneric("UPDATE_NOT_PREF_UPDATE_AUTO_" + this._pingSuffix, PREF_APP_UPDATE_AUTO, true, true);
enabled, DEFAULT_APP_UPDATE_AUTO);
});
// Histogram IDs: // Histogram IDs:
// UPDATE_NOT_PREF_UPDATE_STAGING_ENABLED_EXTERNAL // UPDATE_NOT_PREF_UPDATE_STAGING_ENABLED_EXTERNAL
// UPDATE_NOT_PREF_UPDATE_STAGING_ENABLED_NOTIFY // UPDATE_NOT_PREF_UPDATE_STAGING_ENABLED_NOTIFY
@ -2316,7 +2296,7 @@ UpdateService.prototype = {
* @param updates * @param updates
* An array of available updates * An array of available updates
*/ */
_selectAndInstallUpdate: async function AUS__selectAndInstallUpdate(updates) { _selectAndInstallUpdate: function AUS__selectAndInstallUpdate(updates) {
// Return early if there's an active update. The user is already aware and // Return early if there's an active update. The user is already aware and
// is downloading or performed some user action to prevent notification. // is downloading or performed some user action to prevent notification.
var um = Cc["@mozilla.org/updates/update-manager;1"]. var um = Cc["@mozilla.org/updates/update-manager;1"].
@ -2379,8 +2359,7 @@ UpdateService.prototype = {
* Major Notify * Major Notify
* Minor Auto Install * Minor Auto Install
*/ */
let updateAuto = await this.getAutoUpdateIsEnabled(); if (!Services.prefs.getBoolPref(PREF_APP_UPDATE_AUTO, true)) {
if (!updateAuto) {
LOG("UpdateService:_selectAndInstallUpdate - prompting because silent " + LOG("UpdateService:_selectAndInstallUpdate - prompting because silent " +
"install is disabled. Notifying observers. topic: update-available, " + "install is disabled. Notifying observers. topic: update-available, " +
"status: show-prompt"); "status: show-prompt");
@ -2463,130 +2442,6 @@ UpdateService.prototype = {
return true; return true;
}, },
_updateAutoSettingCachedVal: null,
// Used for serializing reads and writes of the app update json config file.
// This is especially important for making sure writes don't happen out of
// order. It would be bad if a user double-toggling this setting resulted in a
// race condition. The last write must be the one that ultimately controls
// the setting's value.
_updateAutoIOPromise: Promise.resolve(),
_readUpdateAutoConfig: async function AUS__readUpdateAuto() {
let configFile = getUpdateFile([FILE_UPDATE_CONFIG_JSON ]);
let binaryData = await OS.File.read(configFile.path);
let jsonData = gTextDecoder.decode(binaryData);
let configData = JSON.parse(jsonData);
return !!configData[CONFIG_APP_UPDATE_AUTO];
},
_writeUpdateAutoConfig: async function AUS__writeUpdateAutoPref(enabledValue) {
let enabledBoolValue = !!enabledValue;
let configFile = getUpdateFile([FILE_UPDATE_CONFIG_JSON]);
let configObject = {[CONFIG_APP_UPDATE_AUTO]: enabledBoolValue};
await OS.File.writeAtomic(configFile.path, JSON.stringify(configObject));
return enabledBoolValue;
},
// If the value of app.update.auto has changed, notify observers. Returns the
// new value for app.update.auto.
_maybeUpdateAutoConfigChanged: function AUS__maybeUpdateAutoConfigChanged(newValue) {
if (newValue != this._updateAutoSettingCachedVal) {
this._updateAutoSettingCachedVal = newValue;
Services.obs.notifyObservers(null, "auto-update-config-change",
newValue.toString());
}
return newValue;
},
/**
* See nsIUpdateService.idl
*/
getAutoUpdateIsEnabled: function AUS_getAutoUpdateIsEnabled() {
if (AppConstants.platform != "win") {
// Only in Windows do we store the update config in the update directory
let prefValue = Services.prefs.getBoolPref(PREF_APP_UPDATE_AUTO,
DEFAULT_APP_UPDATE_AUTO);
return Promise.resolve(prefValue);
}
// Justification for the empty catch statement below:
// All promises returned by (get|set)AutoUpdateIsEnabled are part of a
// single promise chain in order to serialize disk operations. We don't want
// the entire promise chain to reject when one operation fails.
//
// There is only one situation when a promise in this chain should ever
// reject, which is when writing fails and the error is logged and
// re-thrown. All other possible exceptions are wrapped in try blocks, which
// also log any exception that may occur.
let readPromise = this._updateAutoIOPromise.catch(() => {}).then(async () => {
try {
let configValue = await this._readUpdateAutoConfig();
// If we read a value out of this file, don't later perform migration.
// If the file is deleted, we don't want some stale pref getting
// written to it just because a different profile performed migration.
Services.prefs.setBoolPref(PREF_APP_UPDATE_AUTO_MIGRATED, true);
return configValue;
} catch (e) {
LOG("UpdateService.getAutoUpdateIsEnabled - Unable to read app " +
"update configuration file. Exception: " + e);
let valueMigrated = Services.prefs.getBoolPref(
PREF_APP_UPDATE_AUTO_MIGRATED,
false);
if (!valueMigrated) {
LOG("UpdateService.getAutoUpdateIsEnabled - Attempting migration.");
Services.prefs.setBoolPref(PREF_APP_UPDATE_AUTO_MIGRATED, true);
let prefValue = Services.prefs.getBoolPref(PREF_APP_UPDATE_AUTO,
DEFAULT_APP_UPDATE_AUTO);
try {
return await this._writeUpdateAutoConfig(prefValue);
} catch (e) {
LOG("UpdateService.getAutoUpdateIsEnabled - Migration failed. " +
"Exception: " + e);
}
}
}
// Fallthrough for if the value could not be read or migrated.
return DEFAULT_APP_UPDATE_AUTO;
}).then(this._maybeUpdateAutoConfigChanged.bind(this));
this._updateAutoIOPromise = readPromise;
return readPromise;
},
/**
* See nsIUpdateService.idl
*/
setAutoUpdateIsEnabled: function AUS_setAutoUpdateIsEnabled(enabledValue) {
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);
this._maybeUpdateAutoConfigChanged(prefValue);
return Promise.resolve(prefValue);
}
// Justification for the empty catch statement below:
// All promises returned by (get|set)AutoUpdateIsEnabled are part of a
// single promise chain in order to serialize disk operations. We don't want
// the entire promise chain to reject when one operation fails.
//
// There is only one situation when a promise in this chain should ever
// reject, which is when writing fails and the error is logged and
// re-thrown. All other possible exceptions are wrapped in try blocks, which
// also log any exception that may occur.
let writePromise = this._updateAutoIOPromise.catch(() => {}).then(async () => {
try {
return await this._writeUpdateAutoConfig(enabledValue);
} catch (e) {
LOG("UpdateService.setAutoUpdateIsEnabled - App update configuration " +
"file write failed. Exception: " + e);
// After logging, rethrow the error so the caller knows that writing the
// value in the app update config file failed.
throw e;
}
}).then(this._maybeUpdateAutoConfigChanged.bind(this));
this._updateAutoIOPromise = writePromise;
return writePromise;
},
/** /**
* See nsIUpdateService.idl * See nsIUpdateService.idl
*/ */

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

@ -6,9 +6,6 @@ support-files =
testConstants.js testConstants.js
[browser_TelemetryUpdatePing.js] [browser_TelemetryUpdatePing.js]
[browser_updateAutoPrefUI.js]
skip-if = os != 'win'
reason = Tests that update config is properly written to file, which is a Windows-only feature
[browser_updatesBackgroundWindow.js] [browser_updatesBackgroundWindow.js]
[browser_updatesBackgroundWindowFailures.js] [browser_updatesBackgroundWindowFailures.js]
skip-if = verify skip-if = verify

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

@ -1,55 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
ChromeUtils.import("resource://gre/modules/osfile.jsm", this);
// Changes, then verifies the value of app.update.auto via the about:preferences
// UI. Requires a tab with about:preferences open to be passed in.
async function changeAndVerifyPref(tab, newConfigValue) {
await ContentTask.spawn(tab.linkedBrowser, {newConfigValue}, async function({newConfigValue}) {
let radioId = newConfigValue ? "autoDesktop" : "manualDesktop";
let radioElement = content.document.getElementById(radioId);
radioElement.click();
});
// At this point, we really need to wait for the change to finish being
// written to the disk before we go to verify anything. Unfortunately, it
// would be difficult to check for quick changes to the attributes of the
// about:preferences controls (to wait for the controls to be disabled and
// re-enabled). So instead, just start the verification by asking the
// Application Update Service for the value of app.update.auto. It already
// serializes reads and writes to the app update config file, so this will not
// resolve until the file write is complete.
let configValueRead = await gAUS.getAutoUpdateIsEnabled();
is(configValueRead, newConfigValue,
"Value returned should have matched the expected value");
let configFile = getUpdateConfigFile();
let decoder = new TextDecoder();
let fileContents = await OS.File.read(configFile.path);
let saveObject = JSON.parse(decoder.decode(fileContents));
is(saveObject["app.update.auto"], newConfigValue,
"Value in file should match expected");
await ContentTask.spawn(tab.linkedBrowser, {newConfigValue}, async function({newConfigValue}) {
let updateRadioGroup = content.document.getElementById("updateRadioGroup");
is(updateRadioGroup.value, `${newConfigValue}`,
"Update preference should match expected");
});
}
add_task(async function testUpdateAutoPrefUI() {
let originalPrefValue = await gAUS.getAutoUpdateIsEnabled();
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:preferences");
await changeAndVerifyPref(tab, true);
await changeAndVerifyPref(tab, false);
await changeAndVerifyPref(tab, false);
await changeAndVerifyPref(tab, true);
await BrowserTestUtils.removeTab(tab);
await gAUS.setAutoUpdateIsEnabled(originalPrefValue);
});

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

@ -58,7 +58,6 @@ const FILE_UPDATE_SETTINGS_INI = "update-settings.ini";
const FILE_UPDATE_SETTINGS_INI_BAK = "update-settings.ini.bak"; const FILE_UPDATE_SETTINGS_INI_BAK = "update-settings.ini.bak";
const FILE_UPDATER_INI = "updater.ini"; const FILE_UPDATER_INI = "updater.ini";
const FILE_UPDATES_XML = "updates.xml"; const FILE_UPDATES_XML = "updates.xml";
const FILE_UPDATE_CONFIG = "update-config.json";
const FILE_UPDATE_LOG = "update.log"; const FILE_UPDATE_LOG = "update.log";
const FILE_UPDATE_MAR = "update.mar"; const FILE_UPDATE_MAR = "update.mar";
const FILE_UPDATE_STATUS = "update.status"; const FILE_UPDATE_STATUS = "update.status";
@ -583,15 +582,6 @@ function getGREBinDir() {
return Services.dirsvc.get(NS_GRE_BIN_DIR, Ci.nsIFile); return Services.dirsvc.get(NS_GRE_BIN_DIR, Ci.nsIFile);
} }
/**
* Returns the file containing update configuration
*/
function getUpdateConfigFile() {
let configFile = getUpdatesRootDir();
configFile.append(FILE_UPDATE_CONFIG);
return configFile;
}
/** /**
* Logs TEST-INFO messages. * Logs TEST-INFO messages.
* *

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

@ -1,83 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
ChromeUtils.import("resource://gre/modules/osfile.jsm", this);
// Checks both the value returned by the update service and the one written to
// the app update config file.
async function verifyPref(configFile, expectedValue) {
let decoder = new TextDecoder();
let configValue = await gAUS.getAutoUpdateIsEnabled();
Assert.equal(configValue, expectedValue,
"Value returned should have matched the expected value");
let fileContents = await OS.File.read(configFile.path);
let saveObject = JSON.parse(decoder.decode(fileContents));
Assert.equal(saveObject["app.update.auto"], expectedValue,
"Value in file should match expected");
}
async function run_test() {
setupTestCommon();
standardInit();
let configFile = getUpdateConfigFile();
let originalFileValue = await gAUS.getAutoUpdateIsEnabled();
let originalConfigValue = Services.prefs.getBoolPref("app.update.auto", null);
let originalMigrationValue =
Services.prefs.getBoolPref("app.update.auto.migrated", null);
// Test migration of a |false| value
Services.prefs.setBoolPref("app.update.auto.migrated", false);
Services.prefs.setBoolPref("app.update.auto", false);
debugDump(`about to remove config file`);
configFile.remove(false);
Assert.ok(!configFile.exists(), "Pref file should have been removed");
await verifyPref(configFile, false);
// Test that migration doesn't happen twice
Services.prefs.setBoolPref("app.update.auto", true);
await verifyPref(configFile, false);
// If the file is deleted after migration, the default value should be
// returned, regardless of the pref value.
debugDump(`about to remove config file`);
configFile.remove(false);
Assert.ok(!configFile.exists(), "Pref file should have been removed");
let configValue = await gAUS.getAutoUpdateIsEnabled();
Assert.equal(configValue, true, "getAutoUpdateIsEnabled should have " +
"returned the default value (true)");
// Setting a new value should cause the value to get written out again
await gAUS.setAutoUpdateIsEnabled(false);
await verifyPref(configFile, false);
// Test migration of a |true| value
Services.prefs.setBoolPref("app.update.auto.migrated", false);
Services.prefs.setBoolPref("app.update.auto", true);
configFile.remove(false);
Assert.ok(!configFile.exists(), "App update config file should have been " +
"removed");
await verifyPref(configFile, true);
// Test that setting app.update.auto without migrating also works
await gAUS.setAutoUpdateIsEnabled(false);
await verifyPref(configFile, false);
// Restore original state
await gAUS.setAutoUpdateIsEnabled(originalFileValue);
if (originalConfigValue == null) {
Services.prefs.clearUserPref("app.update.auto");
} else {
Services.prefs.setBoolPref("app.update.auto", originalConfigValue);
}
if (originalMigrationValue == null) {
Services.prefs.clearUserPref("app.update.auto.migrated");
} else {
Services.prefs.setBoolPref("app.update.auto.migrated",
originalMigrationValue);
}
doTestFinish();
}

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

@ -28,9 +28,6 @@ head = head_update.js
[uiSilentPref.js] [uiSilentPref.js]
[uiUnsupportedAlreadyNotified.js] [uiUnsupportedAlreadyNotified.js]
[uiAutoPref.js] [uiAutoPref.js]
[updateAutoPrefMigrate.js]
skip-if = os != 'win'
reason = Update pref migration is currently Windows only
[updateDirectoryMigrate.js] [updateDirectoryMigrate.js]
skip-if = os != 'win' skip-if = os != 'win'
reason = Update directory migration is currently Windows only reason = Update directory migration is currently Windows only