diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 913b2121307..f6bf915a1ab 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -3438,105 +3438,267 @@ "n_buckets" : 10, "description": "PLACES: Days from last maintenance" }, - "UPDATER_BACKGROUND_CHECK_CODE_EXTERNAL": { - "expires_in_version": "default", - "kind": "enumerated", - "n_values": 50, - "description": "Updater: externally initiated (typically by the application) background update check result code (see PING_BGUC_* constants defined in /toolkit/mozapps/update/nsUpdateService.js)" + "UPDATE_CHECK_NO_UPDATE_EXTERNAL" : { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of no updates were found for a background update check (externally initiated)" }, - "UPDATER_BACKGROUND_CHECK_CODE_NOTIFY": { - "expires_in_version": "40", - "kind": "enumerated", - "n_values": 50, - "description": "Updater: timer initiated background update check result code (see PING_BGUC_* constants defined in /toolkit/mozapps/update/nsUpdateService.js)" + "UPDATE_CHECK_NO_UPDATE_NOTIFY" : { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of no updates were found for a background update check (timer initiated)" }, - "UPDATER_INVALID_LASTUPDATETIME_EXTERNAL": { - "expires_in_version": "40", - "kind": "boolean", - "description": "Updater: Whether the last update time is invalid when a background update check was externally requested (typically by the application)" - }, - "UPDATER_INVALID_LASTUPDATETIME_NOTIFY": { - "expires_in_version": "40", - "kind": "boolean", - "description": "Updater: Whether the last update time is invalid when a background update check was timer initiated" - }, - "UPDATER_LAST_NOTIFY_INTERVAL_DAYS_EXTERNAL": { - "expires_in_version": "40", - "kind": "exponential", - "n_buckets": 10, - "high": "60", - "description": "Updater: The interval in days between the previous and the current background update check when the check was externally requested (typically by the application)" - }, - "UPDATER_LAST_NOTIFY_INTERVAL_DAYS_NOTIFY": { - "expires_in_version": "40", - "kind": "exponential", - "n_buckets": 10, - "high": "60", - "description": "Updater: The interval in days between the previous and the current background update check when the check was timer initiated" - }, - "UPDATER_STATUS_CODES": { + "UPDATE_CHECK_CODE_EXTERNAL": { "expires_in_version": "never", "kind": "enumerated", "n_values": 50, - "description": "Updater: the status of the latest update performed" + "description": "Update: background update check result code except for no updates found (externally initiated)" }, - "UPDATER_UPDATES_ENABLED": { - "expires_in_version": "default", + "UPDATE_CHECK_CODE_NOTIFY": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 50, + "description": "Update: background update check result code except for no updates found (timer initiated)" + }, + "UPDATE_CHECK_EXTENDED_ERROR_EXTERNAL": { + "expires_in_version": "never", + "kind": "count", + "keyed": true, + "description": "Update: keyed count (key names are prefixed with AUS_CHECK_EX_ERR_) of background update check extended error code (externally initiated)" + }, + "UPDATE_CHECK_EXTENDED_ERROR_NOTIFY": { + "expires_in_version": "never", + "kind": "count", + "keyed": true, + "description": "Update: keyed count (key names are prefixed with AUS_CHECK_EX_ERR_) of background update check extended error code (timer initiated)" + }, + "UPDATE_INVALID_LASTUPDATETIME_EXTERNAL": { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of systems that have a last update time greater than the current time (externally initiated)" + }, + "UPDATE_INVALID_LASTUPDATETIME_NOTIFY": { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of systems that have a last update time greater than the current time (timer initiated)" + }, + "UPDATE_LAST_NOTIFY_INTERVAL_DAYS_EXTERNAL": { + "expires_in_version": "never", + "kind": "exponential", + "n_buckets": 60, + "high": "365", + "description": "Update: interval in days since the last background update check (externally initiated)" + }, + "UPDATE_LAST_NOTIFY_INTERVAL_DAYS_NOTIFY": { + "expires_in_version": "never", + "kind": "exponential", + "n_buckets": 30, + "high": "180", + "description": "Update: interval in days since the last background update check (timer initiated)" + }, + "UPDATE_SERVICE_INSTALLED_EXTERNAL": { + "expires_in_version": "never", "kind": "boolean", - "description": "Updater: Whether or not updates are enabled" + "description": "Update: whether the service is installed (externally initiated)" }, - "UPDATER_UPDATES_METRO_ENABLED": { - "expires_in_version": "default", + "UPDATE_SERVICE_INSTALLED_NOTIFY": { + "expires_in_version": "never", "kind": "boolean", - "description": "Updater: Whether or not Metro updates are enabled" + "description": "Update: whether the service is installed (timer initiated)" }, - "UPDATER_UPDATES_AUTOMATIC": { - "expires_in_version": "40", + "UPDATE_SERVICE_MANUALLY_UNINSTALLED_EXTERNAL": { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of systems that manually uninstalled the service (externally initiated)" + }, + "UPDATE_SERVICE_MANUALLY_UNINSTALLED_NOTIFY": { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of systems that manually uninstalled the service (timer initiated)" + }, + "UPDATE_CANNOT_APPLY_EXTERNAL": { + "expires_in_version": "never", "kind": "boolean", - "description": "Updater: Whether or not updates are automatic" + "description": "Update: systems that cannot apply updates (externally initiated)" }, - "UPDATER_SERVICE_ENABLED": { - "expires_in_version": "default", + "UPDATE_CANNOT_APPLY_NOTIFY": { + "expires_in_version": "never", "kind": "boolean", - "description": "Updater: Whether or not the MozillaMaintenance service is enabled" + "description": "Update: systems that cannot apply updates (timer initiated)" }, - "UPDATER_SERVICE_ERROR_CODE": { - "expires_in_version": "default", + "UPDATE_CANNOT_STAGE_EXTERNAL": { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of systems that cannot stage updates (externally initiated)" + }, + "UPDATE_CANNOT_STAGE_NOTIFY": { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of systems that cannot stage updates (timer initiated)" + }, + "UPDATE_HAS_PREF_URL_OVERRIDE_EXTERNAL": { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of systems that have an app.update.url.override preference (externally initiated)" + }, + "UPDATE_HAS_PREF_URL_OVERRIDE_NOTIFY": { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of systems that have an app.update.url.override preference (timer initiated)" + }, + "UPDATE_PREF_UPDATE_CANCELATIONS_EXTERNAL": { + "expires_in_version": "never", "kind": "enumerated", "n_values": 100, - "description": "Updater: 0=success else SERVICE_* error code defined in /toolkit/mozapps/update/common/errors.h" + "description": "Update: number of sequential update elevation request cancelations greater than 0 (externally initiated)" }, - "UPDATER_SERVICE_ERRORS": { - "expires_in_version": "default", + "UPDATE_PREF_UPDATE_CANCELATIONS_NOTIFY": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 100, + "description": "Update: number of sequential update elevation request cancelations greater than 0 (timer initiated)" + }, + "UPDATE_PREF_SERVICE_ERRORS_EXTERNAL": { + "expires_in_version": "never", "kind": "enumerated", "n_values": 30, - "description": "Updater: The number of MozillaMaintenance service errors that have occurred" + "description": "Update: number of sequential update service errors greater than 0 (externally initiated)" }, - "UPDATER_SERVICE_INSTALLED": { - "expires_in_version": "default", - "kind": "boolean", - "description": "Updater: Whether or not the MozillaMaintenance service is installed" - }, - "UPDATER_SERVICE_MANUALLY_UNINSTALLED": { - "expires_in_version": "default", - "kind": "boolean", - "description": "Updater: Whether or not someone manually uninstalled the service." - }, - "UPDATER_STAGE_ENABLED": { - "expires_in_version": "40", - "kind": "boolean", - "description": "Updater: Whether or not staging updates are enabled" - }, - "UPDATER_HAS_PERMISSIONS": { - "expires_in_version": "40", - "kind": "boolean", - "description": "Updater: Whether or not the updater has permissions" - }, - "UPDATER_WIZ_LAST_PAGE_CODE": { - "expires_in_version": "40", + "UPDATE_PREF_SERVICE_ERRORS_NOTIFY": { + "expires_in_version": "never", "kind": "enumerated", - "n_values": 25, - "description": "Updater: The update wizard page displayed when the UI was closed (mapped in toolkit/mozapps/update/content/updates.js)" + "n_values": 30, + "description": "Update: number of sequential update service errors greater than 0 (timer initiated)" + }, + "UPDATE_NOT_PREF_UPDATE_AUTO_EXTERNAL": { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of when the app.update.auto boolean preference is not the default value of true (true values are not submitted)" + }, + "UPDATE_NOT_PREF_UPDATE_AUTO_NOTIFY": { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of when the app.update.auto boolean preference is not the default value of true (true values are not submitted)" + }, + "UPDATE_NOT_PREF_UPDATE_ENABLED_EXTERNAL": { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of when the app.update.enabled boolean preference is not the default value of true (true values are not submitted)" + }, + "UPDATE_NOT_PREF_UPDATE_ENABLED_NOTIFY": { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of when the app.update.enabled boolean preference is not the default value of true (true values are not submitted)" + }, + "UPDATE_NOT_PREF_UPDATE_STAGING_ENABLED_EXTERNAL": { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of when the app.update.staging.enabled boolean preference is not the default value of true (true values are not submitted)" + }, + "UPDATE_NOT_PREF_UPDATE_STAGING_ENABLED_NOTIFY": { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of when the app.update.staging.enabled boolean preference is not the default value of true (true values are not submitted)" + }, + "UPDATE_NOT_PREF_UPDATE_SERVICE_ENABLED_EXTERNAL": { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of when the app.update.service.enabled boolean preference is not the default value of true (true values are not submitted)" + }, + "UPDATE_NOT_PREF_UPDATE_SERVICE_ENABLED_NOTIFY": { + "expires_in_version": "never", + "kind": "count", + "description": "Update: count of when the app.update.service.enabled boolean preference is not the default value of true (true values are not submitted)" + }, + "UPDATE_DOWNLOAD_CODE_COMPLETE": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 50, + "description": "Update: complete patch download result code" + }, + "UPDATE_DOWNLOAD_CODE_PARTIAL": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 50, + "description": "Update: complete patch download result code" + }, + "UPDATE_STATE_CODE_COMPLETE_STARTUP": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 20, + "description": "Update: the state of a complete update from update.status on startup" + }, + "UPDATE_STATE_CODE_PARTIAL_STARTUP": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 20, + "description": "Update: the state of a partial patch update from update.status on startup" + }, + "UPDATE_STATE_CODE_UNKNOWN_STARTUP": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 20, + "description": "Update: the state of an unknown patch update from update.status on startup" + }, + "UPDATE_STATE_CODE_COMPLETE_STAGE": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 20, + "description": "Update: the state of a complete patch update from update.status after staging" + }, + "UPDATE_STATE_CODE_PARTIAL_STAGE": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 20, + "description": "Update: the state of a partial patch update from update.status after staging" + }, + "UPDATE_STATE_CODE_UNKNOWN_STAGE": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 20, + "description": "Update: the state of an unknown patch update from update.status after staging" + }, + "UPDATE_STATUS_ERROR_CODE_COMPLETE_STARTUP": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 100, + "description": "Update: the status error code for a failed complete patch update from update.status on startup" + }, + "UPDATE_STATUS_ERROR_CODE_PARTIAL_STARTUP": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 100, + "description": "Update: the status error code for a failed partial patch update from update.status on startup" + }, + "UPDATE_STATUS_ERROR_CODE_UNKNOWN_STARTUP": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 100, + "description": "Update: the status error code for a failed unknown patch update from update.status on startup" + }, + "UPDATE_STATUS_ERROR_CODE_COMPLETE_STAGE": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 100, + "description": "Update: the status error code for a failed complete patch update from update.status after staging" + }, + "UPDATE_STATUS_ERROR_CODE_PARTIAL_STAGE": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 100, + "description": "Update: the status error code for a failed partial patch update from update.status after staging" + }, + "UPDATE_STATUS_ERROR_CODE_UNKNOWN_STAGE": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 100, + "description": "Update: the status error code for a failed unknown patch update from update.status after staging" + }, + "UPDATE_WIZ_LAST_PAGE_CODE": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 30, + "description": "Update: the update wizard page displayed when the UI was closed (mapped in toolkit/mozapps/update/UpdateTelemetry.jsm)" }, "THUNDERBIRD_GLODA_SIZE_MB": { "expires_in_version": "40", diff --git a/toolkit/mozapps/update/UpdateTelemetry.jsm b/toolkit/mozapps/update/UpdateTelemetry.jsm new file mode 100644 index 00000000000..5324b1cc5c0 --- /dev/null +++ b/toolkit/mozapps/update/UpdateTelemetry.jsm @@ -0,0 +1,520 @@ +/* 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/. */ + +"use strict"; + +this.EXPORTED_SYMBOLS = [ + "AUSTLMY" +]; + +const {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components; + +Cu.import("resource://gre/modules/Services.jsm", this); + +this.AUSTLMY = { + // Telemetry for the application update background update check occurs when + // the background update timer fires after the update interval which is + // determined by the app.update.interval preference and its telemetry + // histogram IDs have the suffix '_NOTIFY'. + // Telemetry for the externally initiated background update check occurs when + // a call is made to |checkForBackgroundUpdates| which is typically initiated + // by an application when it has determined that the application should have + // received an update. This has separate telemetry so it is possible to + // analyze using the telemetry data systems that have not been updating when + // they should have. + + // The update check was performed by the call to checkForBackgroundUpdates in + // nsUpdateService.js. + EXTERNAL: "EXTERNAL", + // The update check was performed by the call to notify in nsUpdateService.js. + NOTIFY: "NOTIFY", + + /** + * Values for the UPDATE_CHECK_CODE_NOTIFY and UPDATE_CHECK_CODE_EXTERNAL + * Telemetry histograms. + */ + // No update found (no notification) + CHK_NO_UPDATE_FOUND: 0, + // No incompatible add-ons found during incompatible check (background download) + CHK_ADDON_NO_INCOMPAT: 1, + // Showing prompt due to the update.xml specifying showPrompt + // (update notification) + CHK_SHOWPROMPT_SNIPPET: 2, + // Showing prompt due to preference (update notification) + CHK_SHOWPROMPT_PREF: 3, + // Incompatible add-on check disabled by preference (background download) + CHK_ADDON_PREF_DISABLED: 4, + // Incompatible add-on checke not performed due to same app version as the + // update's app version (background download) + CHK_ADDON_SAME_APP_VER: 5, + // Incompatible add-ons found and all of them have updates (background download) + CHK_ADDON_UPDATES_FOR_INCOMPAT: 6, + // Incompatible add-ons found (update notification) + CHK_ADDON_HAVE_INCOMPAT: 7, + // Already has an active update in progress (no notification) + CHK_HAS_ACTIVEUPDATE: 8, + // A background download is already in progress (no notification) + CHK_IS_DOWNLOADING: 9, + // An update is already staged (no notification) + CHK_IS_STAGED: 10, + // An update is already downloaded (no notification) + CHK_IS_DOWNLOADED: 11, + // Background checks disabled by preference (no notification) + CHK_PREF_DISABLED: 12, + // Update checks disabled by admin locked preference (no notification) + CHK_ADMIN_DISABLED: 13, + // Unable to check for updates per hasUpdateMutex() (no notification) + CHK_NO_MUTEX: 14, + // Unable to check for updates per gCanCheckForUpdates (no notification). This + // should be covered by other codes and is recorded just in case. + CHK_UNABLE_TO_CHECK: 15, + // Background checks disabled for the current session (no notification) + CHK_DISABLED_FOR_SESSION: 16, + // Unable to perform a background check while offline (no notification) + CHK_OFFLINE: 17, + // No update found certificate check failed and threshold reached + // (possible mitm attack notification) + CHK_CERT_ATTR_NO_UPDATE_PROMPT: 18, + // No update found certificate check failed and threshold not reached + // (no notification) + CHK_CERT_ATTR_NO_UPDATE_SILENT: 19, + // Update found certificate check failed and threshold reached + // (possible mitm attack notification) + CHK_CERT_ATTR_WITH_UPDATE_PROMPT: 20, + // Update found certificate check failed and threshold not reached + // (no notification) + CHK_CERT_ATTR_WITH_UPDATE_SILENT: 21, + // General update check failure and threshold reached + // (check failure notification) + CHK_GENERAL_ERROR_PROMPT: 22, + // General update check failure and threshold not reached (no notification) + CHK_GENERAL_ERROR_SILENT: 23, + // No compatible update found though there were updates (no notification) + CHK_NO_COMPAT_UPDATE_FOUND: 24, + // Update found for a previous version (no notification) + CHK_UPDATE_PREVIOUS_VERSION: 25, + // Update found for a version with the never preference set (no notification) + CHK_UPDATE_NEVER_PREF: 26, + // Update found without a type attribute (no notification) + CHK_UPDATE_INVALID_TYPE: 27, + // The system is no longer supported (system unsupported notification) + CHK_UNSUPPORTED: 28, + // Unable to apply updates (manual install to update notification) + CHK_UNABLE_TO_APPLY: 29, + // Unable to check for updates due to no OS version (no notification) + CHK_NO_OS_VERSION: 30, + // Unable to check for updates due to no OS ABI (no notification) + CHK_NO_OS_ABI: 31, + // Invalid url for app.update.url default preference (no notification) + CHK_INVALID_DEFAULT_URL: 32, + // Invalid url for app.update.url user preference (no notification) + CHK_INVALID_USER_OVERRIDE_URL: 33, + // Invalid url for app.update.url.override user preference (no notification) + CHK_INVALID_DEFAULT_OVERRIDE_URL: 34, + + /** + * Submit a telemetry ping for the update check result code or a telemetry + * ping for a count type histogram count when no update was found. The no + * update found ping is separate since it is the typical result, is less + * interesting than the other result codes, and it is easier to analyze the + * other codes without including it. + * + * @param aSuffix + * The histogram id suffix for histogram IDs: + * UPDATE_CHECK_CODE_EXTERNAL + * UPDATE_CHECK_CODE_NOTIFY + * UPDATE_CHECK_NO_UPDATE_EXTERNAL + * UPDATE_CHECK_NO_UPDATE_NOTIFY + * @param aCode + * An integer value as defined by the values that start with CHK_ in + * the above section. + */ + pingCheckCode: function UT_pingCheckCode(aSuffix, aCode) { + try { + if (aCode == this.CHK_NO_UPDATE_FOUND) { + let id = "UPDATE_CHECK_NO_UPDATE_" + aSuffix; + // count type histogram + Services.telemetry.getHistogramById(id).add(); + } else { + let id = "UPDATE_CHECK_CODE_" + aSuffix; + // enumerated type histogram + Services.telemetry.getHistogramById(id).add(aCode); + } + } catch (e) { + Cu.reportError(e); + } + }, + + /** + * Submit a telemetry ping for a failed update check's unhandled error code + * when the pingCheckCode is CHK_GENERAL_ERROR_SILENT. The histogram is a + * keyed count type with key names that are prefixed with 'AUS_CHECK_EX_ERR_'. + * + * @param aSuffix + * The histogram id suffix for histogram IDs: + * UPDATE_CHK_EXTENDED_ERROR_EXTERNAL + * UPDATE_CHK_EXTENDED_ERROR_NOTIFY + * @param aCode + * The extended error value return by a failed update check. + */ + pingCheckExError: function UT_pingCheckExError(aSuffix, aCode) { + try { + let id = "UPDATE_CHECK_EXTENDED_ERROR_" + aSuffix; + let val = "AUS_CHECK_EX_ERR_" + aCode; + // keyed count type histogram + Services.telemetry.getKeyedHistogramById(id).add(val); + } catch (e) { + Cu.reportError(e); + } + }, + + // The state code and if present the status error code were read on startup. + STARTUP: "STARTUP", + // The state code and status error code if present were read after staging. + STAGE: "STAGE", + + // Patch type Complete + PATCH_COMPLETE: "COMPLETE", + // Patch type partial + PATCH_PARTIAL: "PARTIAL", + // Patch type unknown + PATCH_UNKNOWN: "UNKNOWN", + + /** + * Values for the UPDATE_DOWNLOAD_CODE_COMPLETE and + * UPDATE_DOWNLOAD_CODE_PARTIAL Telemetry histograms. + */ + DWNLD_SUCCESS: 0, + DWNLD_RETRY_OFFLINE: 1, + DWNLD_RETRY_NET_TIMEOUT: 2, + DWNLD_RETRY_CONNECTION_REFUSED: 3, + DWNLD_RETRY_NET_RESET: 4, + DWNLD_ERR_NO_UPDATE: 5, + DWNLD_ERR_NO_UPDATE_PATCH: 6, + DWNLD_ERR_NO_PATCH_FILE: 7, + DWNLD_ERR_PATCH_SIZE_LARGER: 8, + DWNLD_ERR_PATCH_SIZE_NOT_EQUAL: 9, + DWNLD_ERR_BINDING_ABORTED: 10, + DWNLD_ERR_ABORT: 11, + DWNLD_ERR_DOCUMENT_NOT_CACHED: 12, + DWNLD_ERR_VERIFY_NO_REQUEST: 13, + DWNLD_ERR_VERIFY_PATCH_SIZE_NOT_EQUAL: 14, + DWNLD_ERR_VERIFY_NO_HASH_MATCH: 15, + + /** + * Submit a telemetry ping for the update download result code. + * + * @param aIsComplete + * If true the histogram is for a patch type complete, if false the + * histogram is for a patch type partial, and when undefined the + * histogram is for an unknown patch type. This is used to determine + * the histogram ID out of the following histogram IDs: + * UPDATE_DOWNLOAD_CODE_COMPLETE + * UPDATE_DOWNLOAD_CODE_PARTIAL + * @param aCode + * An integer value as defined by the values that start with DWNLD_ in + * the above section. + */ + pingDownloadCode: function UT_pingDownloadCode(aIsComplete, aCode) { + let patchType = this.PATCH_UNKNOWN; + if (aIsComplete === true) { + patchType = this.PATCH_COMPLETE; + } else if (aIsComplete === false) { + patchType = this.PATCH_PARTIAL; + } + try { + let id = "UPDATE_DOWNLOAD_CODE_" + patchType; + // enumerated type histogram + Services.telemetry.getHistogramById(id).add(aCode); + } catch (e) { + Cu.reportError(e); + } + }, + + /** + * Submit a telemetry ping for the update status state code. + * + * @param aSuffix + * The histogram id suffix for histogram IDs: + * UPDATE_STATE_CODE_COMPLETE_STARTUP + * UPDATE_STATE_CODE_PARTIAL_STARTUP + * UPDATE_STATE_CODE_UNKNOWN_STARTUP + * UPDATE_STATE_CODE_COMPLETE_STAGE + * UPDATE_STATE_CODE_PARTIAL_STAGE + * UPDATE_STATE_CODE_UNKNOWN_STAGE + * @param aCode + * An integer value as defined by the values that start with STATE_ in + * the above section for the update state from the update.status file. + */ + pingStateCode: function UT_pingStateCode(aSuffix, aCode) { + try { + let id = "UPDATE_STATE_CODE_" + aSuffix; + // enumerated type histogram + Services.telemetry.getHistogramById(id).add(aCode); + } catch(e) { + Cu.reportError(e); + } + }, + + /** + * Submit a telemetry ping for the update status error code. This does not + * submit a success value which can be determined from the state code. + * + * @param aSuffix + * The histogram id suffix for histogram IDs: + * UPDATE_STATUS_ERROR_CODE_COMPLETE_STARTUP + * UPDATE_STATUS_ERROR_CODE_PARTIAL_STARTUP + * UPDATE_STATUS_ERROR_CODE_UNKNOWN_STARTUP + * UPDATE_STATUS_ERROR_CODE_COMPLETE_STAGE + * UPDATE_STATUS_ERROR_CODE_PARTIAL_STAGE + * UPDATE_STATUS_ERROR_CODE_UNKNOWN_STAGE + * @param aCode + * An integer value for the error code from the update.status file. + */ + pingStatusErrorCode: function UT_pingStatusErrorCode(aSuffix, aCode) { + try { + let id = "UPDATE_STATUS_ERROR_CODE_" + aSuffix; + // enumerated type histogram + Services.telemetry.getHistogramById(id).add(aCode); + } catch(e) { + Cu.reportError(e); + } + }, + + /** + * Submit the interval in days since the last notification for this background + * update check or a boolean if the last notification is in the future. + * + * @param aSuffix + * The histogram id suffix for histogram IDs: + * UPDATE_INVALID_LASTUPDATETIME_EXTERNAL + * UPDATE_INVALID_LASTUPDATETIME_NOTIFY + * UPDATE_LAST_NOTIFY_INTERVAL_DAYS_EXTERNAL + * UPDATE_LAST_NOTIFY_INTERVAL_DAYS_NOTIFY + */ + pingLastUpdateTime: function UT_pingLastUpdateTime(aSuffix) { + const PREF_APP_UPDATE_LASTUPDATETIME = "app.update.lastUpdateTime.background-update-timer"; + if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_LASTUPDATETIME)) { + let lastUpdateTimeSeconds = Services.prefs.getIntPref(PREF_APP_UPDATE_LASTUPDATETIME); + if (lastUpdateTimeSeconds) { + let currentTimeSeconds = Math.round(Date.now() / 1000); + if (lastUpdateTimeSeconds > currentTimeSeconds) { + try { + let id = "UPDATE_INVALID_LASTUPDATETIME_" + aSuffix; + // count type histogram + Services.telemetry.getHistogramById().add(); + } catch(e) { + Cu.reportError(e); + } + } else { + let intervalDays = (currentTimeSeconds - lastUpdateTimeSeconds) / + (60 * 60 * 24); + try { + let id = "UPDATE_LAST_NOTIFY_INTERVAL_DAYS_" + aSuffix; + // exponential type histogram + Services.telemetry.getHistogramById(id).add(intervalDays); + } catch(e) { + Cu.reportError(e); + } + } + } + } + }, + + /** + * Submit a telemetry ping for the last page displayed by the update wizard. + * + * @param aPageID + * The page id for the last page displayed. + */ + pingWizLastPageCode: function UT_pingWizLastPageCode(aPageID) { + let pageMap = { invalid: 0, + dummy: 1, + checking: 2, + pluginupdatesfound: 3, + noupdatesfound: 4, + manualUpdate: 5, + unsupported: 6, + incompatibleCheck: 7, + updatesfoundbasic: 8, + updatesfoundbillboard: 9, + license: 10, + incompatibleList: 11, + downloading: 12, + errors: 13, + errorextra: 14, + errorpatching: 15, + finished: 16, + finishedBackground: 17, + installed: 18 }; + try { + let id = "UPDATE_WIZ_LAST_PAGE_CODE"; + // enumerated type histogram + Services.telemetry.getHistogramById(id).add(pageMap[aPageID] || + pageMap.invalid); + } catch (e) { + Cu.reportError(e); + } + }, + + /** + * Submit a telemetry ping for a boolean type histogram that indicates if the + * service is installed and a telemetry ping for a boolean type histogram that + * indicates if the service was at some point installed and is now + * uninstalled. + * Note: the total for the following histogram IDs can be used to determine + * the total number of telemetry timer and externally initiated + * submissions for systems that build with MOZ_MAINTENANCE_SERVICE + * defined: + * UPDATE_SERVICE_INSTALLED_EXTERNAL + * UPDATE_SERVICE_INSTALLED_NOTIFY + * + * @param aSuffix + * The histogram id suffix for histogram IDs: + * UPDATE_SERVICE_INSTALLED_EXTERNAL + * UPDATE_SERVICE_INSTALLED_NOTIFY + * UPDATE_SERVICE_MANUALLY_UNINSTALLED_EXTERNAL + * UPDATE_SERVICE_MANUALLY_UNINSTALLED_NOTIFY + * @param aInstalled + * Whether the service is installed. + */ + pingServiceInstallStatus: function UT_PSIS(aSuffix, aInstalled) { + // Report the error but don't throw since it is more important to + // successfully update than to throw. + if (!("@mozilla.org/windows-registry-key;1" in Cc)) { + Cu.reportError(Cr.NS_ERROR_NOT_AVAILABLE); + return; + } + + try { + let id = "UPDATE_SERVICE_INSTALLED_" + aSuffix; + // boolean type histogram + Services.telemetry.getHistogramById(id).add(aInstalled); + } catch(e) { + Cu.reportError(e); + } + + let attempted = 0; + try { + let wrk = Cc["@mozilla.org/windows-registry-key;1"]. + createInstance(Ci.nsIWindowsRegKey); + wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE, + "SOFTWARE\\Mozilla\\MaintenanceService", + wrk.ACCESS_READ | wrk.WOW64_64); + // Was the service at some point installed, but is now uninstalled? + attempted = wrk.readIntValue("Attempted"); + wrk.close(); + } catch(e) { + // Since this will throw if the registry key doesn't exist (e.g. the + // service has never been installed) don't report an error. + } + + try { + let id = "UPDATE_SERVICE_MANUALLY_UNINSTALLED_" + aSuffix; + if (!aInstalled && attempted) { + // count type histogram + Services.telemetry.getHistogramById(id).add(); + } + } catch(e) { + Cu.reportError(e); + } + }, + + /** + * Submit a telemetry ping for a count type histogram when the expected value + * does not equal the boolean value of a pref or if the pref isn't present + * when the expected value does not equal default value. This lessens the + * amount of data submitted to telemetry. + * + * @param aID + * The histogram ID to report to. + * @param aPref + * The preference to check. + * @param aDefault + * The default value when the preference isn't present. + * @param aExpected (optional) + * If specified and the value is the same as the value that will be + * added the value won't be added to telemetry. + */ + pingBoolPref: function UT_pingBoolPref(aID, aPref, aDefault, aExpected) { + try { + let val = aDefault; + if (Services.prefs.getPrefType(aPref) != Ci.nsIPrefBranch.PREF_INVALID) { + val = Services.prefs.getBoolPref(aPref); + } + if (val != aExpected) { + // count type histogram + Services.telemetry.getHistogramById(aID).add(); + } + } catch(e) { + Cu.reportError(e); + } + }, + + /** + * Submit a telemetry ping for a histogram with the integer value of a + * preference when it is not the expected value or the default value when it + * is not the expected value. This lessens the amount of data submitted to + * telemetry. + * + * @param aID + * The histogram ID to report to. + * @param aPref + * The preference to check. + * @param aDefault + * The default value when the pref is not set. + * @param aExpected (optional) + * If specified and the value is the same as the value that will be + * added the value won't be added to telemetry. + */ + pingIntPref: function UT_pingIntPref(aID, aPref, aDefault, aExpected) { + try { + let val = aDefault; + if (Services.prefs.getPrefType(aPref) != Ci.nsIPrefBranch.PREF_INVALID) { + val = Services.prefs.getIntPref(aPref); + } + if (aExpected === undefined || val != aExpected) { + // enumerated or exponential type histogram + Services.telemetry.getHistogramById(aID).add(val); + } + } catch(e) { + Cu.reportError(e); + } + }, + + /** + * Submit a telemetry ping for all histogram types that take a single + * parameter to the telemetry add function and the count type histogram when + * the aExpected parameter is specified. If the aExpected parameter is + * specified and it equals the value specified by the aValue + * parameter the telemetry submission will be skipped. + * Note: the total for the following histogram IDs can be used to determine + * the total number of telemetry timer and externally initiated + * submissions: + * UPDATE_CANNOT_APPLY_EXTERNAL + * UPDATE_CANNOT_APPLY_NOTIFY + * + * @param aID + * The histogram ID to report to. + * @param aValue + * The value to add when aExpected is not defined or the value to + * check if it is equal to when aExpected is defined. + * @param aExpected (optional) + * If specified and the value is the same as the value specified by + * aValue parameter the submission will be skipped. + */ + pingGeneric: function UT_pingGeneric(aID, aValue, aExpected) { + try { + if (aExpected === undefined) { + Services.telemetry.getHistogramById(aID).add(aValue); + } else if (aValue != aExpected) { + // count type histogram + Services.telemetry.getHistogramById(aID).add(); + } + } catch(e) { + Cu.reportError(e); + } + } +}; +Object.freeze(AUSTLMY); diff --git a/toolkit/mozapps/update/common/errors.h b/toolkit/mozapps/update/common/errors.h index 360f2e3f253..43f00c2266d 100644 --- a/toolkit/mozapps/update/common/errors.h +++ b/toolkit/mozapps/update/common/errors.h @@ -9,9 +9,12 @@ #define OK 0 -// Old unused error codes: -// #define MEM_ERROR 1 // Replaced with errors 10-16 (inclusive) -// #define IO_ERROR 2 // Use READ_ERROR or WRITE_ERROR instead +// Error codes that are no longer used should not be used again unless they +// aren't used in client code (e.g. nsUpdateService.js, updates.js, +// UpdatePrompt.js, etc.). + +#define MAR_ERROR_EMPTY_ACTION_LIST 1 +#define LOADSOURCE_ERROR_WRONG_SIZE 2 // Error codes 3-16 are for general update problems. #define USAGE_ERROR 3 @@ -39,8 +42,7 @@ #define MAR_CHANNEL_MISMATCH_ERROR 22 #define VERSION_DOWNGRADE_ERROR 23 -// Error codes 24-34 are related to the maintenance service -// and so are Windows only +// Error codes 24-33 and 49 are for the Windows maintenance service. #define SERVICE_UPDATER_COULD_NOT_BE_STARTED 24 #define SERVICE_NOT_ENOUGH_COMMAND_LINE_ARGS 25 #define SERVICE_UPDATER_SIGN_ERROR 26 @@ -51,26 +53,38 @@ #define SERVICE_UPDATER_NOT_FIXED_DRIVE 31 #define SERVICE_COULD_NOT_LOCK_UPDATER 32 #define SERVICE_INSTALLDIR_ERROR 33 -#define SERVICE_COULD_NOT_COPY_UPDATER 49 #define NO_INSTALLDIR_ERROR 34 #define WRITE_ERROR_ACCESS_DENIED 35 // #define WRITE_ERROR_SHARING_VIOLATION 36 // Replaced with errors 46-48 #define WRITE_ERROR_CALLBACK_APP 37 -#define INVALID_UPDATER_STATUS_CODE 38 #define UNEXPECTED_BZIP_ERROR 39 #define UNEXPECTED_MAR_ERROR 40 #define UNEXPECTED_BSPATCH_ERROR 41 #define UNEXPECTED_FILE_OPERATION_ERROR 42 #define FILESYSTEM_MOUNT_READWRITE_ERROR 43 -#define FOTA_GENERAL_ERROR 44 -#define FOTA_UNKNOWN_ERROR 45 -#define WRITE_ERROR_SHARING_VIOLATION_SIGNALED 46 -#define WRITE_ERROR_SHARING_VIOLATION_NOPROCESSFORPID 47 -#define WRITE_ERROR_SHARING_VIOLATION_NOPID 48 +#define DELETE_ERROR_EXPECTED_DIR 46 +#define DELETE_ERROR_EXPECTED_FILE 47 +#define RENAME_ERROR_EXPECTED_FILE 48 + +// Error codes 24-33 and 49 are for the Windows maintenance service. +#define SERVICE_COULD_NOT_COPY_UPDATER 49 + +#define WRITE_ERROR_FILE_COPY 61 +#define WRITE_ERROR_DELETE_FILE 62 +#define WRITE_ERROR_OPEN_PATCH_FILE 63 +#define WRITE_ERROR_PATCH_FILE 64 +#define WRITE_ERROR_APPLY_DIR_PATH 65 +#define WRITE_ERROR_CALLBACK_PATH 66 +#define WRITE_ERROR_FILE_ACCESS_DENIED 67 +#define WRITE_ERROR_DIR_ACCESS_DENIED 68 +#define WRITE_ERROR_DELETE_BACKUP 69 +#define WRITE_ERROR_EXTRACT 70 + +// Error codes 80 through 99 are reserved for nsUpdateService.js // The following error codes are only used by updater.exe -// when a fallback key exists and XPCShell tests are being run. +// when a fallback key exists for tests. #define FALLBACKKEY_UNKNOWN_ERROR 100 #define FALLBACKKEY_REGPATH_ERROR 101 #define FALLBACKKEY_NOKEY_ERROR 102 diff --git a/toolkit/mozapps/update/content/updates.js b/toolkit/mozapps/update/content/updates.js index d8692791ca9..80c69de4abb 100644 --- a/toolkit/mozapps/update/content/updates.js +++ b/toolkit/mozapps/update/content/updates.js @@ -5,15 +5,14 @@ 'use strict'; -Components.utils.import("resource://gre/modules/DownloadUtils.jsm"); -Components.utils.import("resource://gre/modules/AddonManager.jsm"); -Components.utils.import("resource://gre/modules/Services.jsm"); - // Firefox's macBrowserOverlay.xul includes scripts that define Cc, Ci, and Cr // so we have to use different names. -const CoC = Components.classes; -const CoI = Components.interfaces; -const CoR = Components.results; +const {classes: CoC, interfaces: CoI, results: CoR, utils: CoU} = Components; + +CoU.import("resource://gre/modules/DownloadUtils.jsm", this); +CoU.import("resource://gre/modules/AddonManager.jsm", this); +CoU.import("resource://gre/modules/Services.jsm", this); +CoU.import("resource://gre/modules/UpdateTelemetry.jsm", this); const XMLNS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; @@ -22,15 +21,16 @@ const PREF_APP_UPDATE_BILLBOARD_TEST_URL = "app.update.billboard.test_url"; const PREF_APP_UPDATE_CERT_ERRORS = "app.update.cert.errors"; const PREF_APP_UPDATE_ENABLED = "app.update.enabled"; const PREF_APP_UPDATE_LOG = "app.update.log"; -const PREF_APP_UPDATE_MANUAL_URL = "app.update.url.manual"; -const PREF_APP_UPDATE_NEVER_BRANCH = "app.update.never."; const PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED = "app.update.notifiedUnsupported"; const PREF_APP_UPDATE_TEST_LOOP = "app.update.test.loop"; -const PREF_PLUGINS_UPDATEURL = "plugins.update.url"; +const PREF_APP_UPDATE_URL_MANUAL = "app.update.url.manual"; + +const PREFBRANCH_APP_UPDATE_NEVER = "app.update.never."; const PREF_EM_HOTFIX_ID = "extensions.hotfix.id"; +const PREF_PLUGINS_UPDATE_URL = "plugins.update.url"; -const UPDATE_TEST_LOOP_INTERVAL = 2000; +const UPDATE_TEST_LOOP_INTERVAL = 2000; const URI_UPDATES_PROPERTIES = "chrome://mozapps/locale/update/updates.properties"; @@ -145,38 +145,12 @@ var gUpdates = { _runUnload: true, /** - * Submit the last page code when the wizard exited. The pageid is used to map - * to an integer instead of using the pageindex since pages can be added and - * removed which would change the page's pageindex. - * @param pageID + * Submit on close telemtry values for the update wizard. + * @param pageID + * The page id for the last page displayed. */ - _sendLastPageCodePing: function(pageID) { - var pageMap = { invalid: 0, - dummy: 1, - checking: 2, - pluginupdatesfound: 3, - noupdatesfound: 4, - manualUpdate: 5, - unsupported: 6, - incompatibleCheck: 7, - updatesfoundbasic: 8, - updatesfoundbillboard: 9, - license: 10, - incompatibleList: 11, - downloading: 12, - errors: 13, - errorextra: 14, - errorpatching: 15, - finished: 16, - finishedBackground: 17, - installed: 18 }; - try { - Services.telemetry.getHistogramById("UPDATER_WIZ_LAST_PAGE_CODE"). - add(pageMap[pageID] || pageMap.invalid); - } - catch (e) { - Components.utils.reportError(e); - } + _submitTelemetry: function(aPageID) { + AUSTLMY.pingWizLastPageCode(aPageID); }, /** @@ -269,7 +243,7 @@ var gUpdates = { // If the user clicks "No Thanks", we should not prompt them to update to // this version again unless they manually select "Check for Updates..." // which will clear all of the "never" prefs. - var neverPrefName = PREF_APP_UPDATE_NEVER_BRANCH + this.update.appVersion; + var neverPrefName = PREFBRANCH_APP_UPDATE_NEVER + this.update.appVersion; Services.prefs.setBoolPref(neverPrefName, true); }, @@ -288,7 +262,7 @@ var gUpdates = { var pageid = document.documentElement.currentPage.pageid; if ("onWizardFinish" in this._pages[pageid]) this._pages[pageid].onWizardFinish(); - this._sendLastPageCodePing(pageid); + this._submitTelemetry(pageid); }, /** @@ -300,7 +274,7 @@ var gUpdates = { var pageid = document.documentElement.currentPage.pageid; if ("onWizardCancel" in this._pages[pageid]) this._pages[pageid].onWizardCancel(); - this._sendLastPageCodePing(pageid); + this._submitTelemetry(pageid); }, /** @@ -550,7 +524,7 @@ var gUpdates = { "or the findUpdates method!"; if (addon.id) errMsg += " Add-on ID: " + addon.id; - Components.utils.reportError(errMsg); + CoU.reportError(errMsg); return; } @@ -574,7 +548,7 @@ var gUpdates = { self.addons.push(addon); } catch (e) { - Components.utils.reportError(e); + CoU.reportError(e); } }); @@ -627,7 +601,7 @@ var gCheckingPage = { // clicked "never" for an update, selected "Check for Updates...", and // then canceled. If we don't clear the "never" prefs future // notifications will never happen. - Services.prefs.deleteBranch(PREF_APP_UPDATE_NEVER_BRANCH); + Services.prefs.deleteBranch(PREFBRANCH_APP_UPDATE_NEVER); // The user will be notified if there is an error so clear the background // check error count. @@ -738,18 +712,18 @@ var gPluginsPage = { * URL of the plugin updates page */ _url: null, - + /** * Initialize */ onPageShow: function() { var prefs = Services.prefs; - if (prefs.getPrefType(PREF_PLUGINS_UPDATEURL) == prefs.PREF_INVALID) { + if (prefs.getPrefType(PREF_PLUGINS_UPDATE_URL) == prefs.PREF_INVALID) { gUpdates.wiz.goTo("noupdatesfound"); return; } - - this._url = Services.urlFormatter.formatURLPref(PREF_PLUGINS_UPDATEURL); + + this._url = Services.urlFormatter.formatURLPref(PREF_PLUGINS_UPDATE_URL); var link = document.getElementById("pluginupdateslink"); link.setAttribute("href", this._url); @@ -776,7 +750,7 @@ var gPluginsPage = { gUpdates.setButtons(null, null, "okButton", true); gUpdates.wiz.getButton("finish").focus(); }, - + /** * Finish button clicked. */ @@ -908,7 +882,7 @@ var gIncompatibleCheckPage = { */ var gManualUpdatePage = { onPageShow: function() { - var manualURL = Services.urlFormatter.formatURLPref(PREF_APP_UPDATE_MANUAL_URL); + var manualURL = Services.urlFormatter.formatURLPref(PREF_APP_UPDATE_URL_MANUAL); var manualUpdateLinkLabel = document.getElementById("manualUpdateLinkLabel"); manualUpdateLinkLabel.value = manualURL; manualUpdateLinkLabel.setAttribute("url", manualURL); @@ -1711,7 +1685,7 @@ var gErrorsPage = { var errorReason = document.getElementById("errorReason"); errorReason.value = statusText; - var manualURL = Services.urlFormatter.formatURLPref(PREF_APP_UPDATE_MANUAL_URL); + var manualURL = Services.urlFormatter.formatURLPref(PREF_APP_UPDATE_URL_MANUAL); var errorLinkLabel = document.getElementById("errorLinkLabel"); errorLinkLabel.value = manualURL; errorLinkLabel.setAttribute("url", manualURL); @@ -1750,7 +1724,7 @@ var gErrorExtraPage = { } else document.getElementById("genericBackgroundErrorLabel").hidden = false; - var manualURL = Services.urlFormatter.formatURLPref(PREF_APP_UPDATE_MANUAL_URL); + var manualURL = Services.urlFormatter.formatURLPref(PREF_APP_UPDATE_URL_MANUAL); var errorLinkLabel = document.getElementById("errorExtraLinkLabel"); errorLinkLabel.value = manualURL; errorLinkLabel.setAttribute("url", manualURL); @@ -1773,7 +1747,7 @@ var gErrorPatchingPage = { onWizardNext: function() { switch (gUpdates.update.selectedPatch.state) { case STATE_PENDING: - case STATE_PENDING_SVC: + case STATE_PENDING_SVC: gUpdates.wiz.goTo("finished"); break; case STATE_DOWNLOADING: diff --git a/toolkit/mozapps/update/moz.build b/toolkit/mozapps/update/moz.build index 1efbe5efa3f..6318e71d154 100644 --- a/toolkit/mozapps/update/moz.build +++ b/toolkit/mozapps/update/moz.build @@ -46,4 +46,8 @@ if CONFIG['MOZ_UPDATER']: 'nsUpdateService.js', ] + EXTRA_JS_MODULES += [ + 'UpdateTelemetry.jsm', + ] + JAR_MANIFESTS += ['jar.mn'] diff --git a/toolkit/mozapps/update/nsUpdateService.js b/toolkit/mozapps/update/nsUpdateService.js index 196c277608b..1aa0950db0c 100644 --- a/toolkit/mozapps/update/nsUpdateService.js +++ b/toolkit/mozapps/update/nsUpdateService.js @@ -7,16 +7,14 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); -Components.utils.import("resource://gre/modules/FileUtils.jsm"); -Components.utils.import("resource://gre/modules/AddonManager.jsm"); -Components.utils.import("resource://gre/modules/Services.jsm"); -Components.utils.import("resource://gre/modules/ctypes.jsm"); +const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components; -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cr = Components.results; -const Cu = Components.utils; +Cu.import("resource://gre/modules/XPCOMUtils.jsm", this); +Cu.import("resource://gre/modules/FileUtils.jsm", this); +Cu.import("resource://gre/modules/AddonManager.jsm", this); +Cu.import("resource://gre/modules/Services.jsm", this); +Cu.import("resource://gre/modules/ctypes.jsm", this); +Cu.import("resource://gre/modules/UpdateTelemetry.jsm", this); const UPDATESERVICE_CID = Components.ID("{B3C290A6-3943-4B89-8BBE-C01EB7B3B311}"); const UPDATESERVICE_CONTRACTID = "@mozilla.org/updates/update-service;1"; @@ -26,6 +24,7 @@ const PREF_APP_UPDATE_AUTO = "app.update.auto"; const PREF_APP_UPDATE_BACKGROUND_INTERVAL = "app.update.download.backgroundInterval"; const PREF_APP_UPDATE_BACKGROUNDERRORS = "app.update.backgroundErrors"; const PREF_APP_UPDATE_BACKGROUNDMAXERRORS = "app.update.backgroundMaxErrors"; +const PREF_APP_UPDATE_CANCELATIONS = "app.update.cancelations"; const PREF_APP_UPDATE_CERTS_BRANCH = "app.update.certs."; const PREF_APP_UPDATE_CERT_CHECKATTRS = "app.update.cert.checkAttributes"; const PREF_APP_UPDATE_CERT_ERRORS = "app.update.cert.errors"; @@ -33,11 +32,9 @@ const PREF_APP_UPDATE_CERT_MAXERRORS = "app.update.cert.maxErrors"; const PREF_APP_UPDATE_CERT_REQUIREBUILTIN = "app.update.cert.requireBuiltIn"; const PREF_APP_UPDATE_CUSTOM = "app.update.custom"; const PREF_APP_UPDATE_ENABLED = "app.update.enabled"; -const PREF_APP_UPDATE_METRO_ENABLED = "app.update.metro.enabled"; const PREF_APP_UPDATE_IDLETIME = "app.update.idletime"; const PREF_APP_UPDATE_INCOMPATIBLE_MODE = "app.update.incompatible.mode"; const PREF_APP_UPDATE_INTERVAL = "app.update.interval"; -const PREF_APP_UPDATE_LASTUPDATETIME = "app.update.lastUpdateTime.background-update-timer"; const PREF_APP_UPDATE_LOG = "app.update.log"; const PREF_APP_UPDATE_MODE = "app.update.mode"; const PREF_APP_UPDATE_NEVER_BRANCH = "app.update.never."; @@ -69,8 +66,6 @@ const URI_BRAND_PROPERTIES = "chrome://branding/locale/brand.properties"; const URI_UPDATES_PROPERTIES = "chrome://mozapps/locale/update/updates.properties"; const URI_UPDATE_NS = "http://www.mozilla.org/2005/app-update"; -const CATEGORY_UPDATE_TIMER = "update-timer"; - const KEY_GRED = "GreD"; const KEY_UPDROOT = "UpdRootD"; const KEY_EXECUTABLE = "XREExeF"; @@ -125,12 +120,9 @@ const STATE_SUCCEEDED = "succeeded"; const STATE_DOWNLOAD_FAILED = "download-failed"; const STATE_FAILED = "failed"; -// From updater/errors.h: -const WRITE_ERROR = 7; -// const UNEXPECTED_ERROR = 8; // Replaced with errors 38-42 -const ELEVATION_CANCELED = 9; - -// Windows service specific errors +// The values below used by this code are from common/errors.h +const WRITE_ERROR = 7; +const ELEVATION_CANCELED = 9; const SERVICE_UPDATER_COULD_NOT_BE_STARTED = 24; const SERVICE_NOT_ENOUGH_COMMAND_LINE_ARGS = 25; const SERVICE_UPDATER_SIGN_ERROR = 26; @@ -141,30 +133,65 @@ const SERVICE_STILL_APPLYING_ON_FAILURE = 30; const SERVICE_UPDATER_NOT_FIXED_DRIVE = 31; const SERVICE_COULD_NOT_LOCK_UPDATER = 32; const SERVICE_INSTALLDIR_ERROR = 33; +const WRITE_ERROR_ACCESS_DENIED = 35; +const WRITE_ERROR_CALLBACK_APP = 37; +const FILESYSTEM_MOUNT_READWRITE_ERROR = 43; const SERVICE_COULD_NOT_COPY_UPDATER = 49; +const WRITE_ERROR_FILE_COPY = 61; +const WRITE_ERROR_DELETE_FILE = 62; +const WRITE_ERROR_OPEN_PATCH_FILE = 63; +const WRITE_ERROR_PATCH_FILE = 64; +const WRITE_ERROR_APPLY_DIR_PATH = 65; +const WRITE_ERROR_CALLBACK_PATH = 66; +const WRITE_ERROR_FILE_ACCESS_DENIED = 67; +const WRITE_ERROR_DIR_ACCESS_DENIED = 68; +const WRITE_ERROR_DELETE_BACKUP = 69; +const WRITE_ERROR_EXTRACT = 70; -const WRITE_ERROR_ACCESS_DENIED = 35; -// const WRITE_ERROR_SHARING_VIOLATION = 36; // Replaced with errors 46-48 -const WRITE_ERROR_CALLBACK_APP = 37; -const INVALID_UPDATER_STATUS_CODE = 38; -const UNEXPECTED_BZIP_ERROR = 39; -const UNEXPECTED_MAR_ERROR = 40; -const UNEXPECTED_BSPATCH_ERROR = 41; -const UNEXPECTED_FILE_OPERATION_ERROR = 42; -const FILESYSTEM_MOUNT_READWRITE_ERROR = 43; -const FOTA_GENERAL_ERROR = 44; -const FOTA_UNKNOWN_ERROR = 45; -const WRITE_ERROR_SHARING_VIOLATION_SIGNALED = 46; -const WRITE_ERROR_SHARING_VIOLATION_NOPROCESSFORPID = 47; -const WRITE_ERROR_SHARING_VIOLATION_NOPID = 48; -const FOTA_FILE_OPERATION_ERROR = 49; -const FOTA_RECOVERY_ERROR = 50; +// Array of write errors to simplify checks for write errors +const WRITE_ERRORS = [WRITE_ERROR, + WRITE_ERROR_ACCESS_DENIED, + WRITE_ERROR_CALLBACK_APP, + WRITE_ERROR_FILE_COPY, + WRITE_ERROR_DELETE_FILE, + WRITE_ERROR_OPEN_PATCH_FILE, + WRITE_ERROR_PATCH_FILE, + WRITE_ERROR_APPLY_DIR_PATH, + WRITE_ERROR_CALLBACK_PATH, + WRITE_ERROR_FILE_ACCESS_DENIED, + WRITE_ERROR_DIR_ACCESS_DENIED, + WRITE_ERROR_DELETE_BACKUP, + WRITE_ERROR_EXTRACT]; +// Array of write errors to simplify checks for service errors +const SERVICE_ERRORS = [SERVICE_UPDATER_COULD_NOT_BE_STARTED, + SERVICE_NOT_ENOUGH_COMMAND_LINE_ARGS, + SERVICE_UPDATER_SIGN_ERROR, + SERVICE_UPDATER_COMPARE_ERROR, + SERVICE_UPDATER_IDENTITY_ERROR, + SERVICE_STILL_APPLYING_ON_SUCCESS, + SERVICE_STILL_APPLYING_ON_FAILURE, + SERVICE_UPDATER_NOT_FIXED_DRIVE, + SERVICE_COULD_NOT_LOCK_UPDATER, + SERVICE_INSTALLDIR_ERROR, + SERVICE_COULD_NOT_COPY_UPDATER]; + +// Error codes 80 through 99 are reserved for nsUpdateService.js and are not +// defined in common/errors.h +const FOTA_GENERAL_ERROR = 80; +const FOTA_UNKNOWN_ERROR = 81; +const FOTA_FILE_OPERATION_ERROR = 82; +const FOTA_RECOVERY_ERROR = 83; +// Staging failed and changed the state to pending +const STAGE_FAIL_FALLBACK = 97; +const INVALID_UPDATER_STATE_CODE = 98; +const INVALID_UPDATER_STATUS_CODE = 99; + +// Custom update error codes const CERT_ATTR_CHECK_FAILED_NO_UPDATE = 100; const CERT_ATTR_CHECK_FAILED_HAS_UPDATE = 101; const BACKGROUNDCHECK_MULTIPLE_FAILURES = 110; const NETWORK_ERROR_OFFLINE = 111; -const FILE_ERROR_TOO_BIG = 112; // Error codes should be < 1000. Errors above 1000 represent http status codes const HTTP_ERROR_OFFSET = 1000; @@ -186,78 +213,6 @@ const DEFAULT_SOCKET_MAX_ERRORS = 10; // The number of milliseconds to wait before retrying a connection error. const DEFAULT_UPDATE_RETRY_TIMEOUT = 2000; -// A background download is in progress (no notification) -const PING_BGUC_IS_DOWNLOADING = 0; -// An update is staged (no notification) -const PING_BGUC_IS_STAGED = 1; -// Invalid url for app.update.url default preference (no notification) -const PING_BGUC_INVALID_DEFAULT_URL = 2; -// Invalid url for app.update.url user preference (no notification) -const PING_BGUC_INVALID_CUSTOM_URL = 3; -// Invalid url for app.update.url.override user preference (no notification) -const PING_BGUC_INVALID_OVERRIDE_URL = 4; -// Unable to check for updates per gCanCheckForUpdates and hasUpdateMutex() -// (no notification) -const PING_BGUC_UNABLE_TO_CHECK = 5; -// Already has an active update in progress (no notification) -const PING_BGUC_HAS_ACTIVEUPDATE = 6; -// Background checks disabled by preference (no notification) -const PING_BGUC_PREF_DISABLED = 7; -// Background checks disabled for the current session (no notification) -const PING_BGUC_DISABLED_FOR_SESSION = 8; -// Background checks disabled in Metro (no notification) -const PING_BGUC_METRO_DISABLED = 9; -// Unable to perform a background check while offline (no notification) -const PING_BGUC_OFFLINE = 10; -// No update found certificate check failed and threshold reached -// (possible mitm attack notification) -const PING_BGUC_CERT_ATTR_NO_UPDATE_NOTIFY = 11; -// No update found certificate check failed and threshold not reached -// (no notification) -const PING_BGUC_CERT_ATTR_NO_UPDATE_SILENT = 12; -// Update found certificate check failed and threshold reached -// (possible mitm attack notification) -const PING_BGUC_CERT_ATTR_WITH_UPDATE_NOTIFY = 13; -// Update found certificate check failed and threshold not reached -// (no notification) -const PING_BGUC_CERT_ATTR_WITH_UPDATE_SILENT = 14; -// General update check failure and threshold reached -// (check failure notification) -const PING_BGUC_GENERAL_ERROR_NOTIFY = 15; -// General update check failure and threshold not reached -// (no notification) -const PING_BGUC_GENERAL_ERROR_SILENT = 16; -// No update found (no notification) -const PING_BGUC_NO_UPDATE_FOUND = 17; -// No compatible update found though there were updates (no notification) -const PING_BGUC_NO_COMPAT_UPDATE_FOUND = 18; -// Update found for a previous version (no notification) -const PING_BGUC_UPDATE_PREVIOUS_VERSION = 19; -// Update found for a version with the never preference set (no notification) -const PING_BGUC_UPDATE_NEVER_PREF = 20; -// Update found without a type attribute (no notification) -const PING_BGUC_UPDATE_INVALID_TYPE = 21; -// The system is no longer supported (system unsupported notification) -const PING_BGUC_UNSUPPORTED = 22; -// Unable to apply updates (manual install to update notification) -const PING_BGUC_UNABLE_TO_APPLY = 23; -// Showing prompt due to the update.xml specifying showPrompt -// (update notification) -const PING_BGUC_SHOWPROMPT_SNIPPET = 24; -// Showing prompt due to preference (update notification) -const PING_BGUC_SHOWPROMPT_PREF = 25; -// Incompatible add-on check disabled by preference (background download) -const PING_BGUC_ADDON_PREF_DISABLED = 26; -// Incompatible add-on not checked not performed due to same update version and -// app version (background download) -const PING_BGUC_ADDON_SAME_APP_VER = 27; -// No incompatible add-ons found during incompatible check (background download) -const PING_BGUC_CHECK_NO_INCOMPAT = 28; -// Incompatible add-ons found and all of them have updates (background download) -const PING_BGUC_ADDON_UPDATES_FOR_INCOMPAT = 29; -// Incompatible add-ons found (update notification) -const PING_BGUC_ADDON_HAVE_INCOMPAT = 30; - var gLocale = null; var gUpdateMutexHandle = null; @@ -555,9 +510,7 @@ function getPerInstallationMutexName(aGlobal) { * Whether or not the current instance has the update mutex. The update mutex * gives protection against 2 applications from the same installation updating: * 1) Running multiple profiles from the same installation path - * 2) Running a Metro and Desktop application at the same time from the same - * path - * 3) 2 applications running in 2 different user sessions from the same path + * 2) Two applications running in 2 different user sessions from the same path * * @return true if this instance holds the update mutex */ @@ -574,16 +527,6 @@ function hasUpdateMutex() { } XPCOMUtils.defineLazyGetter(this, "gCanApplyUpdates", function aus_gCanApplyUpdates() { - function submitHasPermissionsTelemetryPing(val) { - try { - let h = Services.telemetry.getHistogramById("UPDATER_HAS_PERMISSIONS"); - h.add(+val); - } catch(e) { - // Don't allow any exception to be propagated. - Components.utils.reportError(e); - } - } - let useService = false; if (shouldUseService() && isServiceInstalled()) { // No need to perform directory write checks, the maintenance service will @@ -616,15 +559,15 @@ XPCOMUtils.defineLazyGetter(this, "gCanApplyUpdates", function aus_gCanApplyUpda LOG("gCanApplyUpdates - windowsVersion = " + windowsVersion); /** - # For Vista, updates can be performed to a location requiring admin - # privileges by requesting elevation via the UAC prompt when launching - # updater.exe if the appDir is under the Program Files directory - # (e.g. C:\Program Files\) and UAC is turned on and we can elevate - # (e.g. user has a split token). - # - # Note: this does note attempt to handle the case where UAC is turned on - # and the installation directory is in a restricted location that - # requires admin privileges to update other than Program Files. + * For Vista, updates can be performed to a location requiring admin + * privileges by requesting elevation via the UAC prompt when launching + * updater.exe if the appDir is under the Program Files directory + * (e.g. C:\Program Files\) and UAC is turned on and we can elevate + * (e.g. user has a split token). + * + * Note: this does note attempt to handle the case where UAC is turned on + * and the installation directory is in a restricted location that + * requires admin privileges to update other than Program Files. */ var userCanElevate = false; @@ -649,24 +592,24 @@ XPCOMUtils.defineLazyGetter(this, "gCanApplyUpdates", function aus_gCanApplyUpda } /** -# On Windows, we no longer store the update under the app dir. -# -# If we are on Windows (including Vista, if we can't elevate) we need to -# to check that we can create and remove files from the actual app -# directory (like C:\Program Files\Mozilla Firefox). If we can't -# (because this user is not an adminstrator, for example) canUpdate() -# should return false. -# -# For Vista, we perform this check to enable updating the application -# when the user has write access to the installation directory under the -# following scenarios: -# 1) the installation directory is not under Program Files -# (e.g. C:\Program Files) -# 2) UAC is turned off -# 3) UAC is turned on and the user is not an admin -# (e.g. the user does not have a split token) -# 4) UAC is turned on and the user is already elevated, so they can't be -# elevated again + * On Windows, we no longer store the update under the app dir. + * + * If we are on Windows (including Vista, if we can't elevate) we need to + * to check that we can create and remove files from the actual app + * directory (like C:\Program Files\Mozilla Firefox). If we can't + * (because this user is not an adminstrator, for example) canUpdate() + * should return false. + * + * For Vista, we perform this check to enable updating the application + * when the user has write access to the installation directory under the + * following scenarios: + * 1) the installation directory is not under Program Files + * (e.g. C:\Program Files) + * 2) UAC is turned off + * 3) UAC is turned on and the user is not an admin + * (e.g. the user does not have a split token) + * 4) UAC is turned on and the user is already elevated, so they can't be + * elevated again */ if (!userCanElevate) { // if we're unable to create the test file this will throw an exception. @@ -683,13 +626,11 @@ XPCOMUtils.defineLazyGetter(this, "gCanApplyUpdates", function aus_gCanApplyUpda catch (e) { LOG("gCanApplyUpdates - unable to apply updates. Exception: " + e); // No write privileges to install directory - submitHasPermissionsTelemetryPing(false); return false; } } // if (!useService) LOG("gCanApplyUpdates - able to apply updates"); - submitHasPermissionsTelemetryPing(true); return true; }); @@ -762,23 +703,6 @@ function getCanStageUpdates() { return canStageUpdatesSession; } -XPCOMUtils.defineLazyGetter(this, "gMetroUpdatesEnabled", function aus_gMetroUpdatesEnabled() { -#ifdef XP_WIN -#ifdef MOZ_METRO - if (Services.metro && Services.metro.immersive) { - let metroUpdate = getPref("getBoolPref", PREF_APP_UPDATE_METRO_ENABLED, true); - if (!metroUpdate) { - LOG("gMetroUpdatesEnabled - unable to automatically check for metro " + - "updates, disabled by pref"); - return false; - } - } -#endif -#endif - - return true; -}); - XPCOMUtils.defineLazyGetter(this, "gCanCheckForUpdates", function aus_gCanCheckForUpdates() { // If the administrator has disabled app update and locked the preference so // users can't check for updates. This preference check is ok in this lazy @@ -790,10 +714,6 @@ XPCOMUtils.defineLazyGetter(this, "gCanCheckForUpdates", function aus_gCanCheckF return false; } - if (!gMetroUpdatesEnabled) { - return false; - } - // If we don't know the binary platform we're updating, we can't update. if (!gABI) { LOG("gCanCheckForUpdates - unable to check for updates, unknown ABI"); @@ -1440,12 +1360,8 @@ function handleUpdateFailure(update, errorCode) { return true; } - if (update.errorCode == WRITE_ERROR || - update.errorCode == WRITE_ERROR_ACCESS_DENIED || - update.errorCode == WRITE_ERROR_SHARING_VIOLATION_SIGNALED || - update.errorCode == WRITE_ERROR_SHARING_VIOLATION_NOPROCESSFORPID || - update.errorCode == WRITE_ERROR_SHARING_VIOLATION_NOPID || - update.errorCode == WRITE_ERROR_CALLBACK_APP || + // Replace with Array.prototype.includes when it has stabilized. + if (WRITE_ERRORS.indexOf(update.errorCode) != -1 || update.errorCode == FILESYSTEM_MOUNT_READWRITE_ERROR) { Cc["@mozilla.org/updates/update-prompt;1"]. createInstance(Ci.nsIUpdatePrompt). @@ -1456,21 +1372,17 @@ function handleUpdateFailure(update, errorCode) { if (update.errorCode == ELEVATION_CANCELED) { writeStatusFile(getUpdatesDir(), update.state = STATE_PENDING); + let cancelations = getPref("getIntPref", PREF_APP_UPDATE_CANCELATIONS, 0); + cancelations++; + Services.prefs.setIntPref(PREF_APP_UPDATE_CANCELATIONS, cancelations); return true; } + if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_SERVICE_ERRORS)) { + Services.prefs.clearUserPref(PREF_APP_UPDATE_SERVICE_ERRORS); + } - if (update.errorCode == SERVICE_UPDATER_COULD_NOT_BE_STARTED || - update.errorCode == SERVICE_NOT_ENOUGH_COMMAND_LINE_ARGS || - update.errorCode == SERVICE_UPDATER_SIGN_ERROR || - update.errorCode == SERVICE_UPDATER_COMPARE_ERROR || - update.errorCode == SERVICE_UPDATER_IDENTITY_ERROR || - update.errorCode == SERVICE_STILL_APPLYING_ON_SUCCESS || - update.errorCode == SERVICE_STILL_APPLYING_ON_FAILURE || - update.errorCode == SERVICE_UPDATER_NOT_FIXED_DRIVE || - update.errorCode == SERVICE_COULD_NOT_LOCK_UPDATER || - update.errorCode == SERVICE_COULD_NOT_COPY_UPDATER || - update.errorCode == SERVICE_INSTALLDIR_ERROR) { - + // Replace with Array.prototype.includes when it has stabilized. + if (SERVICE_ERRORS.indexOf(update.errorCode) != -1) { var failCount = getPref("getIntPref", PREF_APP_UPDATE_SERVICE_ERRORS, 0); var maxFail = getPref("getIntPref", @@ -1490,22 +1402,8 @@ function handleUpdateFailure(update, errorCode) { } writeStatusFile(getUpdatesDir(), update.state = STATE_PENDING); - try { - Services.telemetry.getHistogramById("UPDATER_SERVICE_ERROR_CODE"). - add(update.errorCode); - } - catch (e) { - Cu.reportError(e); - } return true; } - - try { - Services.telemetry.getHistogramById("UPDATER_SERVICE_ERROR_CODE").add(0); - } - catch (e) { - Cu.reportError(e); - } return false; } @@ -1540,6 +1438,71 @@ function handleFallbackToCompleteUpdate(update, postStaging) { update.setProperty("patchingFailed", oldType); } +function pingStateAndStatusCodes(aUpdate, aStartup, aStatus) { + let patchType = AUSTLMY.PATCH_UNKNOWN; + if (aUpdate && aUpdate.selectedPatch && aUpdate.selectedPatch.type) { + if (aUpdate.selectedPatch.type == "complete") { + patchType = AUSTLMY.PATCH_COMPLETE; + } else if (aUpdate.selectedPatch.type == "partial") { + patchType = AUSTLMY.PATCH_PARTIAL; + } + } + + let suffix = patchType + "_" + (aStartup ? AUSTLMY.STARTUP : AUSTLMY.STAGE); + let stateCode = 0; + let parts = aStatus.split(":"); + if (parts.length > 0) { + switch (parts[0]) { + case STATE_NONE: + stateCode = 2; + break; + case STATE_DOWNLOADING: + stateCode = 3; + break; + case STATE_PENDING: + stateCode = 4; + parts[0] = STATE_FAILED; + parts.push(STAGE_FAIL_FALLBACK); + break; + case STATE_PENDING_SVC: + stateCode = 5; + break; + case STATE_APPLYING: + stateCode = 6; + break; + case STATE_APPLIED: + stateCode = 7; + break; + case STATE_APPLIED_OS: + stateCode = 8; + break; + case STATE_APPLIED_SVC: + stateCode = 9; + break; + case STATE_SUCCEEDED: + stateCode = 10; + break; + case STATE_DOWNLOAD_FAILED: + stateCode = 11; + break; + case STATE_FAILED: + stateCode = 12; + break; + default: + stateCode = 1; + } + + if (parts.length > 1) { + let statusErrorCode = INVALID_UPDATER_STATE_CODE; + if (parts[0] == STATE_FAILED) { + statusErrorCode = parseInt(parts[1]) || INVALID_UPDATER_STATUS_CODE; + } + AUSTLMY.pingStatusErrorCode(suffix, statusErrorCode); + } + } + AUSTLMY.pingStateCode(suffix, stateCode); +} + /** * Update Patch * @param patch @@ -2120,17 +2083,7 @@ UpdateService.prototype = { * notify the user of install success. */ _postUpdateProcessing: function AUS__postUpdateProcessing() { - // canCheckForUpdates will return false when metro-only updates are disabled - // from within metro. In that case we still want _postUpdateProcessing to - // run. gMetroUpdatesEnabled returns true on non Windows 8 platforms. - // We want _postUpdateProcessing to run so that it will update the history - // XML. Without updating the history XML, the about flyout will continue to - // have the "Restart to Apply Update" button (history xml indicates update - // is applied). - // TODO: I think this whole if-block should be removed since updates can - // always be applied via the about dialog, we should be running post update - // in those cases. - if (!this.canCheckForUpdates && gMetroUpdatesEnabled) { + if (!this.canCheckForUpdates) { LOG("UpdateService:_postUpdateProcessing - unable to check for " + "updates... returning early"); return; @@ -2145,18 +2098,19 @@ UpdateService.prototype = { return; } + var um = Cc["@mozilla.org/updates/update-manager;1"]. + getService(Ci.nsIUpdateManager); + var update = um.activeUpdate; var status = readStatusFile(getUpdatesDir()); - // STATE_NONE status means that the update.status file is present but a - // background download error occurred. + pingStateAndStatusCodes(update, true, status); + // STATE_NONE status typically means that the update.status file is present + // but a background download error occurred. if (status == STATE_NONE) { LOG("UpdateService:_postUpdateProcessing - no status, no update"); cleanupActiveUpdate(); return; } - var um = Cc["@mozilla.org/updates/update-manager;1"]. - getService(Ci.nsIUpdateManager); - #ifdef MOZ_WIDGET_GONK // This code is called very early in the boot process, before we've even // had a chance to setup the UI so we can give feedback to the user. @@ -2174,8 +2128,6 @@ UpdateService.prototype = { } #endif - var update = um.activeUpdate; - if (status == STATE_DOWNLOADING) { LOG("UpdateService:_postUpdateProcessing - patch found in downloading " + "state"); @@ -2259,7 +2211,6 @@ UpdateService.prototype = { createInstance(Ci.nsIUpdatePrompt); update.state = status; - this._sendStatusCodeTelemetryPing(status); if (status == STATE_SUCCEEDED) { update.statusText = gUpdateBundle.GetStringFromName("installSuccess"); @@ -2300,167 +2251,6 @@ UpdateService.prototype = { cleanUpMozUpdaterDirs(); }, - /** - * Submit a telemetry ping with the boolean value of a pref for a histogram - * - * @param pref - * The preference to report - * @param histogram - * The histogram ID to report to - */ - _sendBoolPrefTelemetryPing: function AUS__boolTelemetryPing(pref, histogram) { - try { - // The getPref is already wrapped in a try/catch but we never - // want telemetry pings breaking app update so we just put it - // inside the try to be safe. - let val = getPref("getBoolPref", pref, false); - Services.telemetry.getHistogramById(histogram).add(+val); - } catch(e) { - // Don't allow any exception to be propagated. - Cu.reportError(e); - } - }, - -#ifdef XP_WIN - /** - * Submit a telemetry ping with a boolean value which indicates if the service - * is installed. - * Also submits a telemetry ping with a boolean value which indicates if the - * service was at some point installed, but is now uninstalled. - */ - _sendServiceInstalledTelemetryPing: function AUS__svcInstallTelemetryPing() { - let installed = isServiceInstalled(); // Is the service installed? - let attempted = 0; - try { - let wrk = Cc["@mozilla.org/windows-registry-key;1"]. - createInstance(Ci.nsIWindowsRegKey); - wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE, - "SOFTWARE\\Mozilla\\MaintenanceService", - wrk.ACCESS_READ | wrk.WOW64_64); - // Was the service at some point installed, but is now uninstalled? - attempted = wrk.readIntValue("Attempted"); - wrk.close(); - } catch(e) { - } - try { - let h = Services.telemetry.getHistogramById("UPDATER_SERVICE_INSTALLED"); - h.add(Number(installed)); - } catch(e) { - // Don't allow any exception to be propagated. - Cu.reportError(e); - } - try { - let h = Services.telemetry.getHistogramById("UPDATER_SERVICE_MANUALLY_UNINSTALLED"); - h.add(!installed && attempted ? 1 : 0); - } catch(e) { - // Don't allow any exception to be propagated. - Cu.reportError(e); - } - }, -#endif - - /** - * Submit a telemetry ping with the int value of a pref for a histogram - * - * @param pref - * The preference to report - * @param histogram - * The histogram ID to report to - */ - _sendIntPrefTelemetryPing: function AUS__intTelemetryPing(pref, histogram) { - try { - // The getPref is already wrapped in a try/catch but we never - // want telemetry pings breaking app update so we just put it - // inside the try to be safe. - let val = getPref("getIntPref", pref, 0); - Services.telemetry.getHistogramById(histogram).add(val); - } catch(e) { - // Don't allow any exception to be propagated. - Cu.reportError(e); - } - }, - - - /** - * Submit the results of applying the update via telemetry. - * - * @param status - * The status of the update as read from the update.status file - */ - _sendStatusCodeTelemetryPing: function AUS__statusTelemetryPing(status) { - try { - let parts = status.split(":"); - if ((parts.length == 1 && status != STATE_SUCCEEDED) || - (parts.length > 1 && parts[0] != STATE_FAILED)) { - // Should also report STATE_DOWNLOAD_FAILED - return; - } - let result = 0; // 0 means success - if (parts.length > 1) { - result = parseInt(parts[1]) || INVALID_UPDATER_STATUS_CODE; - } - Services.telemetry.getHistogramById("UPDATER_STATUS_CODES").add(result); - } catch(e) { - // Don't allow any exception to be propagated. - Cu.reportError(e); - } - }, - - /** - * Submit the interval in days since the last notification for this background - * update check. - */ - _sendLastNotifyIntervalPing: function AUS__notifyIntervalPing() { - if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_LASTUPDATETIME)) { - let idSuffix = this._isNotify ? "NOTIFY" : "EXTERNAL"; - let lastUpdateTimeSeconds = getPref("getIntPref", - PREF_APP_UPDATE_LASTUPDATETIME, 0); - if (lastUpdateTimeSeconds) { - let currentTimeSeconds = Math.round(Date.now() / 1000); - if (lastUpdateTimeSeconds > currentTimeSeconds) { - try { - Services.telemetry. - getHistogramById("UPDATER_INVALID_LASTUPDATETIME_" + idSuffix). - add(1); - } catch(e) { - Cu.reportError(e); - } - } - else { - let intervalDays = (currentTimeSeconds - lastUpdateTimeSeconds) / - (60 * 60 * 24); - try { - Services.telemetry. - getHistogramById("UPDATER_INVALID_LASTUPDATETIME_" + idSuffix). - add(0); - Services.telemetry. - getHistogramById("UPDATER_LAST_NOTIFY_INTERVAL_DAYS_" + idSuffix). - add(intervalDays); - } catch(e) { - Cu.reportError(e); - } - } - } - } - }, - - /** - * Submit the result for the background update check. - * - * @param code - * An integer value as defined by the PING_BGUC_* constants. - */ - _backgroundUpdateCheckCodePing: function AUS__backgroundUpdateCheckCodePing(code) { - try { - let idSuffix = this._isNotify ? "NOTIFY" : "EXTERNAL"; - Services.telemetry. - getHistogramById("UPDATER_BACKGROUND_CHECK_CODE_" + idSuffix).add(code); - } - catch (e) { - Cu.reportError(e); - } - }, - /** * Register an observer when the network comes online, so we can short-circuit * the app.update.interval when there isn't connectivity @@ -2509,7 +2299,9 @@ UpdateService.prototype = { if (update.errorCode == NETWORK_ERROR_OFFLINE) { // Register an online observer to try again this._registerOnlineObserver(); - this._backgroundUpdateCheckCodePing(PING_BGUC_OFFLINE); + if (this._pingSuffix) { + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_OFFLINE); + } return; } @@ -2519,8 +2311,7 @@ UpdateService.prototype = { errCount++; Services.prefs.setIntPref(PREF_APP_UPDATE_CERT_ERRORS, errCount); maxErrors = getPref("getIntPref", PREF_APP_UPDATE_CERT_MAXERRORS, 5); - } - else { + } else { update.errorCode = BACKGROUNDCHECK_MULTIPLE_FAILURES; errCount = getPref("getIntPref", PREF_APP_UPDATE_BACKGROUNDERRORS, 0); errCount++; @@ -2529,7 +2320,7 @@ UpdateService.prototype = { 10); } - var pingCode; + let checkCode; if (errCount >= maxErrors) { var prompter = Cc["@mozilla.org/updates/update-prompt;1"]. createInstance(Ci.nsIUpdatePrompt); @@ -2537,28 +2328,29 @@ UpdateService.prototype = { switch (update.errorCode) { case CERT_ATTR_CHECK_FAILED_NO_UPDATE: - pingCode = PING_BGUC_CERT_ATTR_NO_UPDATE_NOTIFY; + checkCode = AUSTLMY.CHK_CERT_ATTR_NO_UPDATE_PROMPT; break; case CERT_ATTR_CHECK_FAILED_HAS_UPDATE: - pingCode = PING_BGUC_CERT_ATTR_WITH_UPDATE_NOTIFY; + checkCode = AUSTLMY.CHK_CERT_ATTR_WITH_UPDATE_PROMPT; break; default: - pingCode = PING_BGUC_GENERAL_ERROR_NOTIFY; + checkCode = AUSTLMY.CHK_GENERAL_ERROR_PROMPT; + AUSTLMY.pingCheckExError(this._pingSuffix, update.errorCode); } - } - else { + } else { switch (update.errorCode) { case CERT_ATTR_CHECK_FAILED_NO_UPDATE: - pingCode = PING_BGUC_CERT_ATTR_NO_UPDATE_SILENT; + checkCode = AUSTLMY.CHK_CERT_ATTR_NO_UPDATE_SILENT; break; case CERT_ATTR_CHECK_FAILED_HAS_UPDATE: - pingCode = PING_BGUC_CERT_ATTR_WITH_UPDATE_SILENT; + checkCode = AUSTLMY.CHK_CERT_ATTR_WITH_UPDATE_SILENT; break; default: - pingCode = PING_BGUC_GENERAL_ERROR_SILENT; + checkCode = AUSTLMY.CHK_GENERAL_ERROR_SILENT; + AUSTLMY.pingCheckExError(this._pingSuffix, update.errorCode); } } - this._backgroundUpdateCheckCodePing(pingCode); + AUSTLMY.pingCheckCode(this._pingSuffix, checkCode); }, /** @@ -2592,24 +2384,6 @@ UpdateService.prototype = { * The timer that fired */ notify: function AUS_notify(timer) { - // The telemetry below is specific to background notification. - this._sendBoolPrefTelemetryPing(PREF_APP_UPDATE_ENABLED, - "UPDATER_UPDATES_ENABLED"); - this._sendBoolPrefTelemetryPing(PREF_APP_UPDATE_METRO_ENABLED, - "UPDATER_UPDATES_METRO_ENABLED"); - this._sendBoolPrefTelemetryPing(PREF_APP_UPDATE_AUTO, - "UPDATER_UPDATES_AUTOMATIC"); - this._sendBoolPrefTelemetryPing(PREF_APP_UPDATE_STAGING_ENABLED, - "UPDATER_STAGE_ENABLED"); - -#ifdef XP_WIN - this._sendBoolPrefTelemetryPing(PREF_APP_UPDATE_SERVICE_ENABLED, - "UPDATER_SERVICE_ENABLED"); - this._sendIntPrefTelemetryPing(PREF_APP_UPDATE_SERVICE_ERRORS, - "UPDATER_SERVICE_ERRORS"); - this._sendServiceInstalledTelemetryPing(); -#endif - this._checkForBackgroundUpdates(true); }, @@ -2620,6 +2394,11 @@ UpdateService.prototype = { this._checkForBackgroundUpdates(false); }, + // The suffix used for background update check telemetry histogram ID's. + get _pingSuffix() { + return this._isNotify ? AUSTLMY.NOTIFY : AUSTLMY.EXTERNAL; + }, + /** * Checks for updates in the background. * @param isNotify @@ -2628,55 +2407,122 @@ UpdateService.prototype = { */ _checkForBackgroundUpdates: function AUS__checkForBackgroundUpdates(isNotify) { this._isNotify = isNotify; - // From this point on, the telemetry reported differentiates between a call - // to notify and a call to checkForBackgroundUpdates so they are reported - // separately. - this._sendLastNotifyIntervalPing(); + + // Histogram IDs: + // UPDATE_CANNOT_APPLY_EXTERNAL + // UPDATE_CANNOT_APPLY_NOTIFY + AUSTLMY.pingGeneric("UPDATE_CANNOT_APPLY_" + this._pingSuffix, + gCanApplyUpdates); + // Histogram IDs: + // UPDATE_CANNOT_STAGE_EXTERNAL + // UPDATE_CANNOT_STAGE_NOTIFY + AUSTLMY.pingGeneric("UPDATE_CANNOT_STAGE_" + this._pingSuffix, + getCanStageUpdates(), true); + // Histogram IDs: + // UPDATE_INVALID_LASTUPDATETIME_EXTERNAL + // UPDATE_INVALID_LASTUPDATETIME_NOTIFY + // UPDATE_LAST_NOTIFY_INTERVAL_DAYS_EXTERNAL + // UPDATE_LAST_NOTIFY_INTERVAL_DAYS_NOTIFY + AUSTLMY.pingLastUpdateTime(this._pingSuffix); + // Histogram IDs: + // UPDATE_NOT_PREF_UPDATE_ENABLED_EXTERNAL + // UPDATE_NOT_PREF_UPDATE_ENABLED_NOTIFY + AUSTLMY.pingBoolPref("UPDATE_NOT_PREF_UPDATE_ENABLED_" + this._pingSuffix, + PREF_APP_UPDATE_ENABLED, true, true); + // Histogram IDs: + // UPDATE_NOT_PREF_UPDATE_AUTO_EXTERNAL + // UPDATE_NOT_PREF_UPDATE_AUTO_NOTIFY + AUSTLMY.pingBoolPref("UPDATE_NOT_PREF_UPDATE_AUTO_" + this._pingSuffix, + PREF_APP_UPDATE_AUTO, true, true); + // Histogram IDs: + // UPDATE_NOT_PREF_UPDATE_STAGING_ENABLED_EXTERNAL + // UPDATE_NOT_PREF_UPDATE_STAGING_ENABLED_NOTIFY + AUSTLMY.pingBoolPref("UPDATE_NOT_PREF_UPDATE_STAGING_ENABLED_" + + this._pingSuffix, + PREF_APP_UPDATE_STAGING_ENABLED, true, true); +#ifdef XP_WIN + // Histogram IDs: + // UPDATE_PREF_UPDATE_CANCELATIONS_EXTERNAL + // UPDATE_PREF_UPDATE_CANCELATIONS_NOTIFY + AUSTLMY.pingIntPref("UPDATE_PREF_UPDATE_CANCELATIONS_" + this._pingSuffix, + PREF_APP_UPDATE_CANCELATIONS, 0, 0); +#ifdef MOZ_MAINTENANCE_SERVICE + // Histogram IDs: + // UPDATE_NOT_PREF_UPDATE_SERVICE_ENABLED_EXTERNAL + // UPDATE_NOT_PREF_UPDATE_SERVICE_ENABLED_NOTIFY + AUSTLMY.pingBoolPref("UPDATE_NOT_PREF_UPDATE_SERVICE_ENABLED_" + + this._pingSuffix, + PREF_APP_UPDATE_SERVICE_ENABLED, true); + // Histogram IDs: + // UPDATE_PREF_SERVICE_ERRORS_EXTERNAL + // UPDATE_PREF_SERVICE_ERRORS_NOTIFY + AUSTLMY.pingIntPref("UPDATE_PREF_SERVICE_ERRORS_" + this._pingSuffix, + PREF_APP_UPDATE_SERVICE_ERRORS, 0, 0); + // Histogram IDs: + // UPDATE_SERVICE_INSTALLED_EXTERNAL + // UPDATE_SERVICE_INSTALLED_NOTIFY + // UPDATE_SERVICE_MANUALLY_UNINSTALLED_EXTERNAL + // UPDATE_SERVICE_MANUALLY_UNINSTALLED_NOTIFY + AUSTLMY.pingServiceInstallStatus(this._pingSuffix, isServiceInstalled()); +#endif // MOZ_MAINTENANCE_SERVICE +#endif // XP_WIN + let prefType = Services.prefs.getPrefType(PREF_APP_UPDATE_URL_OVERRIDE); + let overridePrefHasValue = prefType != Ci.nsIPrefBranch.PREF_INVALID; + // Histogram IDs: + // UPDATE_HAS_PREF_URL_OVERRIDE_EXTERNAL + // UPDATE_HAS_PREF_URL_OVERRIDE_NOTIFY + AUSTLMY.pingGeneric("UPDATE_HAS_PREF_URL_OVERRIDE_" + this._pingSuffix, + overridePrefHasValue, false); // If a download is in progress or the patch has been staged do nothing. if (this.isDownloading) { - this._backgroundUpdateCheckCodePing(PING_BGUC_IS_DOWNLOADING); + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_IS_DOWNLOADING); return; } if (this._downloader && this._downloader.patchIsStaged) { - this._backgroundUpdateCheckCodePing(PING_BGUC_IS_STAGED); + let readState = readStatusFile(getUpdatesDir()); + if (readState == STATE_PENDING || readState == STATE_PENDING_SVC) { + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_IS_DOWNLOADED); + } else { + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_IS_STAGED); + } return; } - // The following checks will return early without notification in the call - // to checkForUpdates below. To simplify the background update check ping - // their values are checked here. + let validUpdateURL = true; try { - if (!this.backgroundChecker.getUpdateURL(false)) { - let prefs = Services.prefs; - if (!prefs.prefHasUserValue(PREF_APP_UPDATE_URL_OVERRIDE)) { - if (!prefs.prefHasUserValue(PREF_APP_UPDATE_URL)) { - this._backgroundUpdateCheckCodePing(PING_BGUC_INVALID_DEFAULT_URL); - } - else { - this._backgroundUpdateCheckCodePing(PING_BGUC_INVALID_CUSTOM_URL); - } - } - else { - this._backgroundUpdateCheckCodePing(PING_BGUC_INVALID_OVERRIDE_URL); - } - } - else if (!gMetroUpdatesEnabled) { - this._backgroundUpdateCheckCodePing(PING_BGUC_METRO_DISABLED); - } - else if (!getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true)) { - this._backgroundUpdateCheckCodePing(PING_BGUC_PREF_DISABLED); - } - else if (!(gCanCheckForUpdates && hasUpdateMutex())) { - this._backgroundUpdateCheckCodePing(PING_BGUC_UNABLE_TO_CHECK); - } - else if (!this.backgroundChecker._enabled) { - this._backgroundUpdateCheckCodePing(PING_BGUC_DISABLED_FOR_SESSION); - } + this.backgroundChecker.getUpdateURL(false); + } catch (e) { + validUpdateURL = false; } - catch (e) { - Cu.reportError(e); + // The following checks are done here so they can be differentiated from + // foreground checks. + if (!gOSVersion) { + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_NO_OS_VERSION); + } else if (!gABI) { + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_NO_OS_ABI); + } else if (!validUpdateURL) { + if (overridePrefHasValue) { + if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_URL_OVERRIDE)) { + AUSTLMY.pingCheckCode(this._pingSuffix, + AUSTLMY.CHK_INVALID_USER_OVERRIDE_URL); + } else { + AUSTLMY.pingCheckCode(this._pingSuffix, + AUSTLMY.CHK_INVALID_DEFAULT_OVERRIDE_URL); + } + } else { + AUSTLMY.pingCheckCode(this._pingSuffix, + AUSTLMY.CHK_INVALID_DEFAULT_URL); + } + } else if (!getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true)) { + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_PREF_DISABLED); + } else if (!hasUpdateMutex()) { + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_NO_MUTEX); + } else if (!gCanCheckForUpdates) { + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_UNABLE_TO_CHECK); + } else if (!this.backgroundChecker._enabled) { + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_DISABLED_FOR_SESSION); } this.backgroundChecker.checkForUpdates(this, false); @@ -2692,19 +2538,20 @@ UpdateService.prototype = { */ selectUpdate: function AUS_selectUpdate(updates) { if (updates.length == 0) { - this._backgroundUpdateCheckCodePing(PING_BGUC_NO_UPDATE_FOUND); + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_NO_UPDATE_FOUND); return null; } // The ping for unsupported is sent after the call to showPrompt. - if (updates.length == 1 && updates[0].unsupported) + if (updates.length == 1 && updates[0].unsupported) { return updates[0]; + } // Choose the newest of the available minor and major updates. var majorUpdate = null; var minorUpdate = null; var vc = Services.vc; - var lastPingCode = PING_BGUC_NO_COMPAT_UPDATE_FOUND; + let lastCheckCode = AUSTLMY.CHK_NO_COMPAT_UPDATE_FOUND; updates.forEach(function(aUpdate) { // Ignore updates for older versions of the application and updates for @@ -2715,7 +2562,7 @@ UpdateService.prototype = { LOG("UpdateService:selectUpdate - skipping update because the " + "update's application version is less than the current " + "application version"); - lastPingCode = PING_BGUC_UPDATE_PREVIOUS_VERSION; + lastCheckCode = AUSTLMY.CHK_UPDATE_PREVIOUS_VERSION; return; } @@ -2727,7 +2574,7 @@ UpdateService.prototype = { getPref("getBoolPref", neverPrefName, false)) { LOG("UpdateService:selectUpdate - skipping update because the " + "preference " + neverPrefName + " is true"); - lastPingCode = PING_BGUC_UPDATE_NEVER_PREF; + lastCheckCode = AUSTLMY.CHK_UPDATE_NEVER_PREF; return; } @@ -2747,14 +2594,15 @@ UpdateService.prototype = { default: LOG("UpdateService:selectUpdate - skipping unknown update type: " + aUpdate.type); - lastPingCode = PING_BGUC_UPDATE_INVALID_TYPE; + lastCheckCode = AUSTLMY.CHK_UPDATE_INVALID_TYPE; break; } }); var update = minorUpdate || majorUpdate; - if (!update) - this._backgroundUpdateCheckCodePing(lastPingCode); + if (!update) { + AUSTLMY.pingCheckCode(this._pingSuffix, lastCheckCode); + } return update; }, @@ -2782,23 +2630,18 @@ UpdateService.prototype = { // to show the prompt to make sure. this._showPrompt(um.activeUpdate); #endif - this._backgroundUpdateCheckCodePing(PING_BGUC_HAS_ACTIVEUPDATE); + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_HAS_ACTIVEUPDATE); return; } var updateEnabled = getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true); if (!updateEnabled) { - this._backgroundUpdateCheckCodePing(PING_BGUC_PREF_DISABLED); + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_PREF_DISABLED); LOG("UpdateService:_selectAndInstallUpdate - not prompting because " + "update is disabled"); return; } - if (!gMetroUpdatesEnabled) { - this._backgroundUpdateCheckCodePing(PING_BGUC_METRO_DISABLED); - return; - } - var update = this.selectUpdate(updates, updates.length); if (!update) { return; @@ -2812,15 +2655,15 @@ UpdateService.prototype = { "update is not supported for this system"); this._showPrompt(update); } - this._backgroundUpdateCheckCodePing(PING_BGUC_UNSUPPORTED); + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_UNSUPPORTED); return; } - if (!(gCanApplyUpdates && hasUpdateMutex())) { + if (!gCanApplyUpdates) { LOG("UpdateService:_selectAndInstallUpdate - the user is unable to " + "apply updates... prompting"); this._showPrompt(update); - this._backgroundUpdateCheckCodePing(PING_BGUC_UNABLE_TO_APPLY); + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_UNABLE_TO_APPLY); return; } @@ -2853,21 +2696,16 @@ UpdateService.prototype = { if (update.showPrompt) { LOG("UpdateService:_selectAndInstallUpdate - prompting because the " + "update snippet specified showPrompt"); + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_SHOWPROMPT_SNIPPET); this._showPrompt(update); - if (!Services.metro || !Services.metro.immersive) { - this._backgroundUpdateCheckCodePing(PING_BGUC_SHOWPROMPT_SNIPPET); - return; - } + return; } if (!getPref("getBoolPref", PREF_APP_UPDATE_AUTO, true)) { LOG("UpdateService:_selectAndInstallUpdate - prompting because silent " + "install is disabled"); + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_SHOWPROMPT_PREF); this._showPrompt(update); - if (!Services.metro || !Services.metro.immersive) { - this._backgroundUpdateCheckCodePing(PING_BGUC_SHOWPROMPT_PREF); - return; - } } if (getPref("getIntPref", PREF_APP_UPDATE_MODE, 1) == 0) { @@ -2877,7 +2715,7 @@ UpdateService.prototype = { var status = this.downloadUpdate(update, true); if (status == STATE_NONE) cleanupActiveUpdate(); - this._backgroundUpdateCheckCodePing(PING_BGUC_ADDON_PREF_DISABLED); + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_ADDON_PREF_DISABLED); return; } @@ -2891,10 +2729,11 @@ UpdateService.prototype = { LOG("UpdateService:_selectAndInstallUpdate - add-on compatibility " + "check not performed due to the update version being the same as " + "the current application version, just download the update"); - var status = this.downloadUpdate(update, true); - if (status == STATE_NONE) + let status = this.downloadUpdate(update, true); + if (status == STATE_NONE) { cleanupActiveUpdate(); - this._backgroundUpdateCheckCodePing(PING_BGUC_ADDON_SAME_APP_VER); + } + AUSTLMY.pingCheckCode(this._pingSuffix,AUSTLMY.CHK_ADDON_SAME_APP_VER); } }, @@ -2920,8 +2759,9 @@ UpdateService.prototype = { if (!("isCompatibleWith" in addon) || !("findUpdates" in addon)) { let errMsg = "Add-on doesn't implement either the isCompatibleWith " + "or the findUpdates method!"; - if (addon.id) + if (addon.id) { errMsg += " Add-on ID: " + addon.id; + } Cu.reportError(errMsg); return; } @@ -2942,10 +2782,10 @@ UpdateService.prototype = { addon.scope != AddonManager.SCOPE_APPLICATION && addon.isCompatible && !addon.isCompatibleWith(self._update.appVersion, - self._update.platformVersion)) + self._update.platformVersion)) { self._incompatibleAddons.push(addon); - } - catch (e) { + } + } catch (e) { Cu.reportError(e); } }); @@ -2987,7 +2827,7 @@ UpdateService.prototype = { if (status == STATE_NONE) cleanupActiveUpdate(); self._update = null; - self._backgroundUpdateCheckCodePing(PING_BGUC_CHECK_NO_INCOMPAT); + AUSTLMY.pingCheckCode(self._pingSuffix, AUSTLMY.CHK_ADDON_NO_INCOMPAT); } }); }, @@ -3027,12 +2867,16 @@ UpdateService.prototype = { if (--this._updateCheckCount > 0) return; - if (this._incompatibleAddons.length > 0 || - !(gCanApplyUpdates && hasUpdateMutex())) { + if (this._incompatibleAddons.length > 0 || !gCanApplyUpdates) { LOG("UpdateService:onUpdateEnded - prompting because there are " + "incompatible add-ons"); + if (this._incompatibleAddons.length > 0) { + AUSTLMY.pingCheckCode(this._pingSuffix, + AUSTLMY.CHK_ADDON_HAVE_INCOMPAT); + } else { + AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_UNABLE_TO_APPLY); + } this._showPrompt(this._update); - this._backgroundUpdateCheckCodePing(PING_BGUC_ADDON_HAVE_INCOMPAT); } else { LOG("UpdateService:_selectAndInstallUpdate - updates for all " + @@ -3040,7 +2884,8 @@ UpdateService.prototype = { var status = this.downloadUpdate(this._update, true); if (status == STATE_NONE) cleanupActiveUpdate(); - this._backgroundUpdateCheckCodePing(PING_BGUC_ADDON_UPDATES_FOR_INCOMPAT); + AUSTLMY.pingCheckCode(this._pingSuffix, + AUSTLMY.CHK_ADDON_UPDATES_FOR_INCOMPAT); } this._update = null; }, @@ -3208,6 +3053,8 @@ UpdateService.prototype = { if (!osApplyToDir) { LOG("UpdateService:applyOsUpdate - Error: osApplyToDir is not defined" + "in the nsIUpdate!"); + pingStateAndStatusCodes(aUpdate, false, + STATE_FAILED + ": " + FOTA_FILE_OPERATION_ERROR); handleUpdateFailure(aUpdate, FOTA_FILE_OPERATION_ERROR); return; } @@ -3217,6 +3064,8 @@ UpdateService.prototype = { if (!updateFile.exists()) { LOG("UpdateService:applyOsUpdate - Error: OS update is not found at " + updateFile.path); + pingStateAndStatusCodes(aUpdate, false, + STATE_FAILED + ": " + FOTA_FILE_OPERATION_ERROR); handleUpdateFailure(aUpdate, FOTA_FILE_OPERATION_ERROR); return; } @@ -3231,6 +3080,8 @@ UpdateService.prototype = { } catch (e) { LOG("UpdateService:applyOsUpdate - Error: Couldn't reboot into recovery" + " to apply FOTA update " + updateFile.path); + pingStateAndStatusCodes(aUpdate, false, + STATE_FAILED + ": " + FOTA_RECOVERY_ERROR); writeStatusFile(getUpdatesDir(), aUpdate.state = STATE_APPLIED); handleUpdateFailure(aUpdate, FOTA_RECOVERY_ERROR); } @@ -3526,11 +3377,13 @@ UpdateManager.prototype = { } var updateSucceeded = true; var status = readStatusFile(getUpdatesDir()); - var ary = status.split(":"); - update.state = ary[0]; - if (update.state == STATE_FAILED && ary[1]) { + pingStateAndStatusCodes(update, false, status); + var parts = status.split(":"); + update.state = parts[0]; + + if (update.state == STATE_FAILED && parts[1]) { updateSucceeded = false; - if (!handleUpdateFailure(update, ary[1])) { + if (!handleUpdateFailure(update, parts[1])) { handleFallbackToCompleteUpdate(update, true); } } @@ -3859,10 +3712,6 @@ Checker.prototype = { */ _enabled: true, get enabled() { - if (!gMetroUpdatesEnabled) { - return false; - } - return getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true) && gCanCheckForUpdates && hasUpdateMutex() && this._enabled; }, @@ -3962,6 +3811,8 @@ Downloader.prototype = { _verifyDownload: function Downloader__verifyDownload() { LOG("Downloader:_verifyDownload called"); if (!this._request) { + AUSTLMY.pingDownloadCode(this.isCompleteUpdate, + AUSTLMY.DWNLD_ERR_VERIFY_NO_REQUEST); return false; } @@ -3970,6 +3821,8 @@ Downloader.prototype = { // Ensure that the file size matches the expected file size. if (destination.fileSize != this._patch.size) { LOG("Downloader:_verifyDownload downloaded size != expected size."); + AUSTLMY.pingDownloadCode(this.isCompleteUpdate, + AUSTLMY.DWNLD_ERR_VERIFY_PATCH_SIZE_NOT_EQUAL); return false; } @@ -4007,6 +3860,8 @@ Downloader.prototype = { } LOG("Downloader:_verifyDownload hashes do not match. "); + AUSTLMY.pingDownloadCode(this.isCompleteUpdate, + AUSTLMY.DWNLD_ERR_VERIFY_NO_HASH_MATCH); return false; }, @@ -4150,8 +4005,10 @@ Downloader.prototype = { */ downloadUpdate: function Downloader_downloadUpdate(update) { LOG("UpdateService:_downloadUpdate"); - if (!update) + if (!update) { + AUSTLMY.pingDownloadCode(undefined, AUSTLMY.DWNLD_ERR_NO_UPDATE); throw Cr.NS_ERROR_NULL_POINTER; + } var updateDir = getUpdatesDir(); @@ -4162,6 +4019,7 @@ Downloader.prototype = { this._patch = this._selectPatch(update, updateDir); if (!this._patch) { LOG("Downloader:downloadUpdate - no patch to download"); + AUSTLMY.pingDownloadCode(undefined, AUSTLMY.DWNLD_ERR_NO_UPDATE_PATCH); return readStatusFile(updateDir); } this.isCompleteUpdate = this._patch.type == "complete"; @@ -4227,6 +4085,8 @@ Downloader.prototype = { patchFile = this._getUpdateArchiveFile(); } if (!patchFile) { + AUSTLMY.pingDownloadCode(this.isCompleteUpdate, + AUSTLMY.DWNLD_ERR_NO_PATCH_FILE); return STATE_NONE; } @@ -4344,6 +4204,8 @@ Downloader.prototype = { // It's important that we use a different code than // NS_ERROR_CORRUPTED_CONTENT so that tests can verify the difference // between a hash error and a wrong download error. + AUSTLMY.pingDownloadCode(this.isCompleteUpdate, + AUSTLMY.DWNLD_ERR_PATCH_SIZE_LARGER); this.cancel(Cr.NS_ERROR_UNEXPECTED); return; } @@ -4354,6 +4216,8 @@ Downloader.prototype = { // It's important that we use a different code than // NS_ERROR_CORRUPTED_CONTENT so that tests can verify the difference // between a hash error and a wrong download error. + AUSTLMY.pingDownloadCode(this.isCompleteUpdate, + AUSTLMY.DWNLD_ERR_PATCH_SIZE_NOT_EQUAL); this.cancel(Cr.NS_ERROR_UNEXPECTED); return; } @@ -4426,6 +4290,7 @@ Downloader.prototype = { if (this.background) { shouldShowPrompt = !getCanStageUpdates(); } + AUSTLMY.pingDownloadCode(this.isCompleteUpdate, AUSTLMY.DWNLD_SUCCESS); // Tell the updater.exe we're ready to apply. writeStatusFile(getUpdatesDir(), state); @@ -4456,6 +4321,8 @@ Downloader.prototype = { // calling downloadUpdate on the active update which continues // downloading the file from where it was. LOG("Downloader:onStopRequest - offline, register online observer: true"); + AUSTLMY.pingDownloadCode(this.isCompleteUpdate, + AUSTLMY.DWNLD_RETRY_OFFLINE); shouldRegisterOnlineObserver = true; deleteActiveUpdate = false; // Each of NS_ERROR_NET_TIMEOUT, ERROR_CONNECTION_REFUSED, and @@ -4467,12 +4334,27 @@ Downloader.prototype = { status == Cr.NS_ERROR_NET_RESET) && this.updateService._consecutiveSocketErrors < maxFail) { LOG("Downloader:onStopRequest - socket error, shouldRetrySoon: true"); + let dwnldCode = AUSTLMY.DWNLD_RETRY_CONNECTION_REFUSED; + if (status == Cr.NS_ERROR_NET_TIMEOUT) { + dwnldCode = AUSTLMY.DWNLD_RETRY_NET_TIMEOUT; + } else if (status == Cr.NS_ERROR_NET_RESET) { + dwnldCode = AUSTLMY.DWNLD_RETRY_NET_RESET; + } + AUSTLMY.pingDownloadCode(this.isCompleteUpdate, dwnldCode); shouldRetrySoon = true; deleteActiveUpdate = false; } else if (status != Cr.NS_BINDING_ABORTED && status != Cr.NS_ERROR_ABORT && status != Cr.NS_ERROR_DOCUMENT_NOT_CACHED) { LOG("Downloader:onStopRequest - non-verification failure"); + let dwnldCode = AUSTLMY.DWNLD_ERR_DOCUMENT_NOT_CACHED; + if (status == Cr.NS_BINDING_ABORTED) { + dwnldCode = AUSTLMY.DWNLD_ERR_BINDING_ABORTED; + } else if (status == Cr.NS_ERROR_ABORT) { + dwnldCode = AUSTLMY.DWNLD_ERR_ABORT; + } + AUSTLMY.pingDownloadCode(this.isCompleteUpdate, dwnldCode); + // Some sort of other failure, log this in the |statusText| property state = STATE_DOWNLOAD_FAILED; @@ -4504,8 +4386,9 @@ Downloader.prototype = { um.activeUpdate = null; } else { - if (um.activeUpdate) + if (um.activeUpdate) { um.activeUpdate.state = state; + } } um.saveUpdates(); @@ -4734,14 +4617,10 @@ UpdatePrompt.prototype = { this._getAltUpdateWindow()) return; - // In some cases, we want to just show a simple alert dialog: + // In some cases, we want to just show a simple alert dialog. + // Replace with Array.prototype.includes when it has stabilized. if (update.state == STATE_FAILED && - (update.errorCode == WRITE_ERROR || - update.errorCode == WRITE_ERROR_ACCESS_DENIED || - update.errorCode == WRITE_ERROR_SHARING_VIOLATION_SIGNALED || - update.errorCode == WRITE_ERROR_SHARING_VIOLATION_NOPROCESSFORPID || - update.errorCode == WRITE_ERROR_SHARING_VIOLATION_NOPID || - update.errorCode == WRITE_ERROR_CALLBACK_APP || + (WRITE_ERRORS.indexOf(update.errorCode) != -1 || update.errorCode == FILESYSTEM_MOUNT_READWRITE_ERROR || update.errorCode == FOTA_GENERAL_ERROR || update.errorCode == FOTA_FILE_OPERATION_ERROR || diff --git a/toolkit/mozapps/update/nsUpdateServiceStub.js b/toolkit/mozapps/update/nsUpdateServiceStub.js index 44dbbdeb17d..92d12673738 100644 --- a/toolkit/mozapps/update/nsUpdateServiceStub.js +++ b/toolkit/mozapps/update/nsUpdateServiceStub.js @@ -5,8 +5,8 @@ const { classes: Cc, interfaces: Ci, utils: Cu } = Components; -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/FileUtils.jsm"); +Cu.import("resource://gre/modules/XPCOMUtils.jsm", this); +Cu.import("resource://gre/modules/FileUtils.jsm", this); const DIR_UPDATES = "updates"; const FILE_UPDATE_STATUS = "update.status"; diff --git a/toolkit/mozapps/update/nsUpdateTimerManager.js b/toolkit/mozapps/update/nsUpdateTimerManager.js index 184dd6fcf91..2f6041a795f 100644 --- a/toolkit/mozapps/update/nsUpdateTimerManager.js +++ b/toolkit/mozapps/update/nsUpdateTimerManager.js @@ -2,8 +2,8 @@ * 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/. */ -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); -Components.utils.import("resource://gre/modules/Services.jsm"); +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm", this); +Components.utils.import("resource://gre/modules/Services.jsm", this); const Cc = Components.classes; const Ci = Components.interfaces; diff --git a/toolkit/mozapps/update/tests/chrome/chrome.ini b/toolkit/mozapps/update/tests/chrome/chrome.ini index a73c24a1ca2..64fa0754f08 100644 --- a/toolkit/mozapps/update/tests/chrome/chrome.ini +++ b/toolkit/mozapps/update/tests/chrome/chrome.ini @@ -67,6 +67,8 @@ reason = Bug 918029 - timeout caused by copying too many files. [test_0103_background_restartNotification_stagingService.xul] skip-if = os != 'win' reason = only Windows has the maintenance service. +[test_0104_background_restartNotification_NoIncompatAddons.xul] +[test_0105_background_restartNotification_VersionCompatAddons.xul] [test_0111_neverButton_basic.xul] [test_0112_neverButton_billboard.xul] [test_0113_showNeverForVersionRemovedWithPref.xul] diff --git a/toolkit/mozapps/update/tests/chrome/test_0104_background_restartNotification_NoIncompatAddons.xul b/toolkit/mozapps/update/tests/chrome/test_0104_background_restartNotification_NoIncompatAddons.xul new file mode 100644 index 00000000000..979df6db105 --- /dev/null +++ b/toolkit/mozapps/update/tests/chrome/test_0104_background_restartNotification_NoIncompatAddons.xul @@ -0,0 +1,51 @@ + + + + + + + + + + +

+ +

+
+
diff --git a/toolkit/mozapps/update/tests/chrome/test_0105_background_restartNotification_VersionCompatAddons.xul b/toolkit/mozapps/update/tests/chrome/test_0105_background_restartNotification_VersionCompatAddons.xul new file mode 100644 index 00000000000..6ee7acce2f8 --- /dev/null +++ b/toolkit/mozapps/update/tests/chrome/test_0105_background_restartNotification_VersionCompatAddons.xul @@ -0,0 +1,50 @@ + + + + + + + + + + +

+ +

+
+
diff --git a/toolkit/mozapps/update/tests/chrome/utils.js b/toolkit/mozapps/update/tests/chrome/utils.js index 1dbba9cbb23..088841594de 100644 --- a/toolkit/mozapps/update/tests/chrome/utils.js +++ b/toolkit/mozapps/update/tests/chrome/utils.js @@ -102,11 +102,17 @@ * updatecompatibility * the add-on is compatible with the current toolkit version and has a * compatibility update to make it compatible with the update's toolkit - * version. + * version. Tests that need to have add-ons compatible for the application + * update without updating the add-on's compatibility information can disable + * this add-on by setting the gDisableUpdateCompatibilityAddon variable to + * true. * * updateversion * the add-on is compatible with the current toolkit version and has a version - * update to make it compatible with the update's toolkit version. + * update to make it compatible with the update's toolkit version. Tests that + * need to have add-ons compatible for the application update without updating + * the add-on's to a new version that is compatible can disable this add-on by + * setting the gDisableUpdateVersionAddon variable to true. * * userdisabled * disabled by the user and compatible with the current toolkit version but @@ -119,8 +125,8 @@ const { classes: Cc, interfaces: Ci, manager: Cm, results: Cr, utils: Cu } = Components; -Cu.import("resource://gre/modules/AddonManager.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/AddonManager.jsm", this); +Cu.import("resource://gre/modules/Services.jsm", this); const IS_MACOSX = ("nsILocalFileMac" in Ci); @@ -151,6 +157,8 @@ const URL_HOST = "http://example.com"; const URL_PATH_UPDATE_XML = "/chrome/toolkit/mozapps/update/tests/chrome/update.sjs"; const REL_PATH_DATA = "chrome/toolkit/mozapps/update/tests/data"; +// These two URLs must not contain parameters since tests add their own +// test specific parameters. const URL_HTTP_UPDATE_XML = URL_HOST + URL_PATH_UPDATE_XML; const URL_HTTPS_UPDATE_XML = "https://example.com" + URL_PATH_UPDATE_XML; @@ -202,6 +210,8 @@ var gWin; var gDocElem; var gPrefToCheck; var gDisableNoUpdateAddon = false; +var gDisableUpdateCompatibilityAddon = false; +var gDisableUpdateVersionAddon = false; // Set to true to log additional information for debugging. To log additional // information for an individual test set DEBUG_AUS_TEST to true in the test's @@ -1125,21 +1135,27 @@ function setupAddons(aCallback) { function setNoUpdateAddonsDisabledState() { AddonManager.getAllAddons(function(aAddons) { aAddons.forEach(function(aAddon) { - if (aAddon.name.indexOf("appdisabled") == 0) { + if (aAddon.name.startsWith("appdisabled")) { if (!aAddon.userDisabled) { aAddon.userDisabled = true; } } - if (aAddon.name.indexOf("noupdate") == 0) { - if (gDisableNoUpdateAddon) { - if (!aAddon.userDisabled) { - aAddon.userDisabled = true; - } - } else { - if (aAddon.userDisabled) { - aAddon.userDisabled = false; - } + if (aAddon.name.startsWith("noupdate")) { + if (aAddon.userDisabled != gDisableNoUpdateAddon) { + aAddon.userDisabled = gDisableNoUpdateAddon; + } + } + + if (aAddon.name.startsWith("updatecompatibility")) { + if (aAddon.userDisabled != gDisableUpdateCompatibilityAddon) { + aAddon.userDisabled = gDisableUpdateCompatibilityAddon; + } + } + + if (aAddon.name.startsWith("updateversion")) { + if (aAddon.userDisabled != gDisableUpdateVersionAddon) { + aAddon.userDisabled = gDisableUpdateVersionAddon; } } }); diff --git a/toolkit/mozapps/update/tests/data/partial_log_failure b/toolkit/mozapps/update/tests/data/partial_log_failure index 8cea74a757a..729da410eb8 100644 --- a/toolkit/mozapps/update/tests/data/partial_log_failure +++ b/toolkit/mozapps/update/tests/data/partial_log_failure @@ -182,5 +182,5 @@ FINISH REMOVEFILE 3/3text1 backup_restore: backup file doesn't exist: 3/3text1.moz-backup FINISH REMOVEFILE 3/3text0 backup_restore: backup file doesn't exist: 3/3text0.moz-backup -failed: 42 +failed: 2 calling QuitProgressUI diff --git a/toolkit/mozapps/update/tests/data/partial_log_failure_mac b/toolkit/mozapps/update/tests/data/partial_log_failure_mac index e76115144ae..8b0db834cf7 100644 --- a/toolkit/mozapps/update/tests/data/partial_log_failure_mac +++ b/toolkit/mozapps/update/tests/data/partial_log_failure_mac @@ -182,5 +182,5 @@ FINISH REMOVEFILE Contents/Resources/3/3text1 backup_restore: backup file doesn't exist: Contents/Resources/3/3text1.moz-backup FINISH REMOVEFILE Contents/Resources/3/3text0 backup_restore: backup file doesn't exist: Contents/Resources/3/3text0.moz-backup -failed: 42 +failed: 2 calling QuitProgressUI diff --git a/toolkit/mozapps/update/tests/data/sharedUpdateXML.js b/toolkit/mozapps/update/tests/data/sharedUpdateXML.js index 70552aa9063..d930e84943f 100644 --- a/toolkit/mozapps/update/tests/data/sharedUpdateXML.js +++ b/toolkit/mozapps/update/tests/data/sharedUpdateXML.js @@ -35,11 +35,12 @@ const STATE_SUCCEEDED = "succeeded"; const STATE_DOWNLOAD_FAILED = "download-failed"; const STATE_FAILED = "failed"; -const STATE_FAILED_READ_ERROR = STATE_FAILED + ": 6"; -const STATE_FAILED_WRITE_ERROR = STATE_FAILED + ": 7"; -const STATE_FAILED_CHANNEL_MISMATCH_ERROR = STATE_FAILED + ": 22"; -const STATE_FAILED_VERSION_DOWNGRADE_ERROR = STATE_FAILED + ": 23"; -const STATE_FAILED_UNEXPECTED_FILE_OPERATION_ERROR = STATE_FAILED + ": 42"; +const STATE_FAILED_LOADSOURCE_ERROR_WRONG_SIZE = STATE_FAILED + ": 2"; +const STATE_FAILED_READ_ERROR = STATE_FAILED + ": 6"; +const STATE_FAILED_WRITE_ERROR = STATE_FAILED + ": 7"; +const STATE_FAILED_CHANNEL_MISMATCH_ERROR = STATE_FAILED + ": 22"; +const STATE_FAILED_VERSION_DOWNGRADE_ERROR = STATE_FAILED + ": 23"; +const STATE_FAILED_WRITE_ERROR_FILE_COPY = STATE_FAILED + ": 61"; /** * Constructs a string representing a remote update xml file. diff --git a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js index 465b3fc4b7e..2d59ddc7323 100644 --- a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js +++ b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js @@ -9,7 +9,8 @@ const { classes: Cc, interfaces: Ci, manager: Cm, results: Cr, load("../data/xpcshellConstantsPP.js"); -Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/Services.jsm", this); +Cu.import("resource://gre/modules/ctypes.jsm", this); const DIR_MACOS = IS_MACOSX ? "Contents/MacOS/" : ""; const DIR_RESOURCES = IS_MACOSX ? "Contents/Resources/" : ""; @@ -1196,7 +1197,6 @@ function getSpecialFolderDir(aCSIDL) { do_throw("Windows only function called by a different platform!"); } - Cu.import("resource://gre/modules/ctypes.jsm"); let lib = ctypes.open("shell32"); let SHGetSpecialFolderPath = lib.declare("SHGetSpecialFolderPathW", ctypes.winapi_abi, @@ -1531,8 +1531,13 @@ function runUpdate(aExpectedExitValue, aExpectedStatus, aCallback) { } let updateLog = getUpdatesPatchDir(); updateLog.append(FILE_UPDATE_LOG); - logTestInfo("contents of " + updateLog.path + ":\n" + - readFileBytes(updateLog).replace(/\r\n/g, "\n")); + // xpcshell tests won't display the entire contents so log each line. + let contents = readFileBytes(updateLog).replace(/\r\n/g, "\n"); + let aryLogContents = contents.split("\n"); + logTestInfo("contents of " + updateLog.path + ":"); + aryLogContents.forEach(function RU_LC_FE(aLine) { + logTestInfo(aLine); + }); } debugDump("testing updater binary process exitValue against expected " + "exit value"); @@ -2075,7 +2080,7 @@ function runUpdateUsingService(aInitialStatus, aExpectedStatus, aCheckSvcLog) { function timerCallback(aTimer) { // Wait for the expected status - let status = readStatusState(); + let status = readStatusFile(); // status will probably always be equal to STATE_APPLYING but there is a // race condition where it would be possible on slower machines where status // could be equal to STATE_PENDING_SVC. @@ -2098,8 +2103,13 @@ function runUpdateUsingService(aInitialStatus, aExpectedStatus, aCheckSvcLog) { logTestInfo("update.status contents: " + readStatusFile()); let updateLog = getUpdatesPatchDir(); updateLog.append(FILE_UPDATE_LOG); - logTestInfo("contents of " + updateLog.path + ":\n" + - readFileBytes(updateLog).replace(/\r\n/g, "\n")); + // xpcshell tests won't display the entire contents so log each line. + let contents = readFileBytes(updateLog).replace(/\r\n/g, "\n"); + let aryLogContents = contents.split("\n"); + logTestInfo("contents of " + updateLog.path + ":"); + aryLogContents.forEach(function RUUS_TC_LC_FE(aLine) { + logTestInfo(aLine); + }); } debugDump("testing update status against expected status"); do_check_eq(status, aExpectedStatus); @@ -2470,7 +2480,22 @@ function checkUpdateLogContents(aCompareLogFile, aExcludeDistributionDir) { do_check_true(true); } else { logTestInfo("log contents are not correct"); - do_check_eq(compareLogContents, updateLogContents); + let aryLog = updateLogContents.split("\n"); + let aryCompare = compareLogContents.split("\n"); + // Pushing an empty string to both arrays makes it so either array's length + // can be used in the for loop below without going out of bounds. + aryLog.push(""); + aryCompare.push(""); + // xpcshell tests won't display the entire contents so log the incorrect + // line. + for (let i = 0; i < aryLog.length; ++i) { + if (aryCompare[i] != aryLog[i]) { + logTestInfo("the first incorrect line in the log is: " + aryLog[i]); + do_check_eq(aryCompare[i], aryLog[i]); + } + } + // This should never happen! + do_throw("Unable to find incorrect log contents!"); } } @@ -2489,7 +2514,6 @@ function checkUpdateLogContains(aCheckString) { do_check_true(true); } else { logTestInfo("log file does not contain: " + aCheckString); - logTestInfo("log file contents:\n" + updateLogContents); do_check_true(false); } } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marAppApplyDirLockedStageFailure_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marAppApplyDirLockedStageFailure_win.js index e85933b1534..3bc892f6c42 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marAppApplyDirLockedStageFailure_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marAppApplyDirLockedStageFailure_win.js @@ -89,5 +89,6 @@ function finishTest() { do_check_eq(readStatusState(), STATE_PENDING); checkFilesAfterUpdateFailure(getApplyDirFile, false, false); unlockDirectory(getAppBaseDir()); + standardInit(); waitForFilesInUse(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseFallbackStageFailureComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseFallbackStageFailureComplete_win.js index c379239c9d1..6bd118481ff 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseFallbackStageFailureComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseFallbackStageFailureComplete_win.js @@ -40,5 +40,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageFailureComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageFailureComplete_win.js index e9c2d9387ff..3b1ed83e24b 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageFailureComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageFailureComplete_win.js @@ -41,5 +41,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, true, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js index e583a7cce1a..431baa4f827 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js @@ -113,6 +113,7 @@ function checkUpdate() { checkSymlink(); } checkUpdateLogContents(LOG_COMPLETE_SUCCESS); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseSuccessComplete.js b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseSuccessComplete.js index a5807612041..b90bd4106a3 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseSuccessComplete.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseSuccessComplete.js @@ -53,5 +53,6 @@ function checkUpdate() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); checkUpdateLogContents(LOG_COMPLETE_SUCCESS); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppStageSuccessComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppStageSuccessComplete_win.js index dd19b8d3ce0..8bfa06d85be 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppStageSuccessComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppStageSuccessComplete_win.js @@ -23,5 +23,6 @@ function run_test() { function checkUpdateApplied() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppStageSuccessPartial_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppStageSuccessPartial_win.js index 7d483381fdc..e8cc9bca8db 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppStageSuccessPartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppStageSuccessPartial_win.js @@ -23,5 +23,6 @@ function run_test() { function checkUpdateApplied() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppSuccessComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppSuccessComplete_win.js index d147dd9cef0..a0ecb235503 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppSuccessComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppSuccessComplete_win.js @@ -17,5 +17,6 @@ function run_test() { function checkUpdateApplied() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppSuccessPartial_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppSuccessPartial_win.js index f1f153c562a..a80d1aeb4db 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppSuccessPartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppSuccessPartial_win.js @@ -17,5 +17,6 @@ function run_test() { function checkUpdateApplied() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFailurePartial.js b/toolkit/mozapps/update/tests/unit_base_updater/marFailurePartial.js index 4b14973f0e4..2549b36499d 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFailurePartial.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFailurePartial.js @@ -26,7 +26,7 @@ function run_test() { } // Note that on platforms where we use execv, we cannot trust the return code. - runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_UNEXPECTED_FILE_OPERATION_ERROR); + runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_LOADSOURCE_ERROR_WRONG_SIZE); } /** @@ -50,5 +50,6 @@ function checkUpdateApplied() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContents(LOG_PARTIAL_FAILURE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseFallbackStageFailureComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseFallbackStageFailureComplete_win.js index 4ff0fcc23d3..ce98564706c 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseFallbackStageFailureComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseFallbackStageFailureComplete_win.js @@ -41,5 +41,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseFallbackStageFailurePartial_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseFallbackStageFailurePartial_win.js index 7b19ca4c84a..9d0b7b70875 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseFallbackStageFailurePartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseFallbackStageFailurePartial_win.js @@ -41,5 +41,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailureComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailureComplete_win.js index 357e3e16dc6..17fb0c7a02e 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailureComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailureComplete_win.js @@ -42,5 +42,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, true, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailurePartial_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailurePartial_win.js index cc92115c5d2..8df2f1ea86e 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailurePartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailurePartial_win.js @@ -42,5 +42,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, true, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessComplete_win.js index e1ecaa66b1a..42b36d2fbfb 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessComplete_win.js @@ -5,9 +5,6 @@ /* File in use complete MAR file patch apply success test */ function run_test() { - // Set to true due to bug 1123503 - DEBUG_AUS_TEST = true; - setupTestCommon(); gTestFiles = gTestFilesCompleteSuccess; gTestDirs = gTestDirsCompleteSuccess; @@ -37,5 +34,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, true); checkUpdateLogContains(ERR_BACKUP_DISCARD); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessPartial_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessPartial_win.js index 8f33de09f3a..3db36ab0813 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessPartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessPartial_win.js @@ -34,5 +34,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, true); checkUpdateLogContains(ERR_BACKUP_DISCARD); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailureComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailureComplete_win.js index 7c80e74d1b2..58f04ea3595 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailureComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailureComplete_win.js @@ -44,5 +44,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailurePartial_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailurePartial_win.js index 2511bfacd8a..92b25036638 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailurePartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailurePartial_win.js @@ -44,5 +44,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_UNABLE_OPEN_DEST); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFallbackStageFailureComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFallbackStageFailureComplete_win.js index 7cdc732beb2..0e90452912b 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFallbackStageFailureComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFallbackStageFailureComplete_win.js @@ -35,7 +35,7 @@ function run_test() { } function doUpdate() { - runUpdate(1, STATE_FAILED_WRITE_ERROR, null); + runUpdate(1, STATE_FAILED_WRITE_ERROR_FILE_COPY, null); // Switch the application to the staged application that was updated. gStageUpdate = false; @@ -50,5 +50,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFallbackStageFailurePartial_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFallbackStageFailurePartial_win.js index 1b424c2045f..8f1c1bbd5a7 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFallbackStageFailurePartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFallbackStageFailurePartial_win.js @@ -35,7 +35,7 @@ function run_test() { } function doUpdate() { - runUpdate(1, STATE_FAILED_WRITE_ERROR, null); + runUpdate(1, STATE_FAILED_WRITE_ERROR_FILE_COPY, null); // Switch the application to the staged application that was updated. gStageUpdate = false; @@ -50,5 +50,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailureComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailureComplete_win.js index 33b547c6d9b..e65451663d9 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailureComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailureComplete_win.js @@ -35,7 +35,7 @@ function run_test() { } function doUpdate() { - runUpdate(1, STATE_FAILED_WRITE_ERROR, null); + runUpdate(1, STATE_FAILED_WRITE_ERROR_FILE_COPY, null); // Switch the application to the staged application that was updated. gStageUpdate = false; @@ -51,5 +51,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, true, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailurePartial_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailurePartial_win.js index d23ca0affdf..916830f902a 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailurePartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailurePartial_win.js @@ -35,7 +35,7 @@ function run_test() { } function doUpdate() { - runUpdate(1, STATE_FAILED_WRITE_ERROR, null); + runUpdate(1, STATE_FAILED_WRITE_ERROR_FILE_COPY, null); // Switch the application to the staged application that was updated. gStageUpdate = false; @@ -51,5 +51,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, true, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseFallbackStageFailureComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseFallbackStageFailureComplete_win.js index a57b085e538..326dac1e0df 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseFallbackStageFailureComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseFallbackStageFailureComplete_win.js @@ -52,5 +52,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseFallbackStageFailurePartial_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseFallbackStageFailurePartial_win.js index 8550e310132..7e2ec9ced6a 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseFallbackStageFailurePartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseFallbackStageFailurePartial_win.js @@ -50,5 +50,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseStageFailureComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseStageFailureComplete_win.js index 5a53240c332..6cee739c544 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseStageFailureComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseStageFailureComplete_win.js @@ -53,5 +53,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, true, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseStageFailurePartial_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseStageFailurePartial_win.js index d7aeee18de9..78304a92306 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseStageFailurePartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseStageFailurePartial_win.js @@ -51,5 +51,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, true, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseSuccessComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseSuccessComplete_win.js index 0b9a825f01f..7e1e9cb10c4 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseSuccessComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseSuccessComplete_win.js @@ -44,5 +44,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, true); checkUpdateLogContains(ERR_BACKUP_DISCARD); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseSuccessPartial_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseSuccessPartial_win.js index 9b9fb7d0e0c..1f972900859 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseSuccessPartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseSuccessPartial_win.js @@ -42,5 +42,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, true); checkUpdateLogContains(ERR_BACKUP_DISCARD); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marStageFailurePartial.js b/toolkit/mozapps/update/tests/unit_base_updater/marStageFailurePartial.js index 12feb4ab6be..73c31d30eab 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marStageFailurePartial.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marStageFailurePartial.js @@ -26,7 +26,7 @@ function run_test() { applyToDir.lastModifiedTime = yesterday; } - runUpdate(1, STATE_FAILED_UNEXPECTED_FILE_OPERATION_ERROR); + runUpdate(1, STATE_FAILED_LOADSOURCE_ERROR_WRONG_SIZE); } /** @@ -41,5 +41,6 @@ function checkUpdateApplied() { checkFilesAfterUpdateFailure(getApplyDirFile, true, false); checkUpdateLogContents(LOG_PARTIAL_FAILURE); + standardInit(); waitForFilesInUse(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js index 4359682f2ad..d4d9bf43ec8 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js @@ -118,6 +118,7 @@ function finishCheckUpdateApplied() { } checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); checkUpdateLogContents(LOG_COMPLETE_SUCCESS); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessPartial.js b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessPartial.js index 23affc98eea..905ec6f4197 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessPartial.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessPartial.js @@ -111,5 +111,6 @@ function finishCheckUpdateApplied() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); checkUpdateLogContents(LOG_PARTIAL_SUCCESS, true); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marSuccessComplete.js b/toolkit/mozapps/update/tests/unit_base_updater/marSuccessComplete.js index 5e49994e6c4..a25c4179647 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marSuccessComplete.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marSuccessComplete.js @@ -91,5 +91,6 @@ function finishCheckUpdateApplied() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); checkUpdateLogContents(LOG_COMPLETE_SUCCESS, true); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartial.js b/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartial.js index fad354b16c9..f7caf2d8128 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartial.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartial.js @@ -81,5 +81,6 @@ function finishCheckUpdateApplied() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); checkUpdateLogContents(LOG_PARTIAL_SUCCESS); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marVersionDowngrade.js b/toolkit/mozapps/update/tests/unit_base_updater/marVersionDowngrade.js index 0dce2aa5d3c..993b3aec9ed 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marVersionDowngrade.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marVersionDowngrade.js @@ -37,5 +37,6 @@ function checkUpdateApplied() { } checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); + standardInit(); doTestFinish(); } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannel.js b/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannel.js index 7552e4ddbbf..ee96fe3848f 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannel.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannel.js @@ -37,5 +37,6 @@ function checkUpdateApplied() { } checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); + standardInit(); doTestFinish(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marAppApplyDirLockedStageFailureSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marAppApplyDirLockedStageFailureSvc_win.js index 0dfc0985dcf..d1ac6a88780 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marAppApplyDirLockedStageFailureSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marAppApplyDirLockedStageFailureSvc_win.js @@ -95,5 +95,6 @@ function finishTest() { do_check_eq(readStatusState(), STATE_PENDING); checkFilesAfterUpdateFailure(getApplyDirFile, false, false); unlockDirectory(getAppBaseDir()); + standardInit(); waitForFilesInUse(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marAppInUseFallbackStageFailureCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marAppInUseFallbackStageFailureCompleteSvc_win.js index 5231beabe2d..3b2ccdcc6a1 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marAppInUseFallbackStageFailureCompleteSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marAppInUseFallbackStageFailureCompleteSvc_win.js @@ -50,5 +50,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marAppInUseStageFailureCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marAppInUseStageFailureCompleteSvc_win.js index d027b4802ad..903a1cfed0d 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marAppInUseStageFailureCompleteSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marAppInUseStageFailureCompleteSvc_win.js @@ -51,5 +51,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, true, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marAppInUseSuccessCompleteSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/marAppInUseSuccessCompleteSvc.js index 817da6c20bd..8db42bb1628 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marAppInUseSuccessCompleteSvc.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marAppInUseSuccessCompleteSvc.js @@ -61,5 +61,6 @@ function checkUpdate() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); checkUpdateLogContents(LOG_COMPLETE_SUCCESS); + standardInit(); checkCallbackServiceLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppStageSuccessCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppStageSuccessCompleteSvc_win.js index 281cec306b8..4664425b7c5 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppStageSuccessCompleteSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppStageSuccessCompleteSvc_win.js @@ -5,9 +5,6 @@ /* Replace app binary complete MAR file staged patch apply success test */ function run_test() { - // Set to true due to bug 1037599 - DEBUG_AUS_TEST = true; - if (!shouldRunServiceTest()) { return; } @@ -36,5 +33,6 @@ function checkUpdateFinished() { function checkUpdateApplied() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppStageSuccessPartialSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppStageSuccessPartialSvc_win.js index ab1d753e489..d827ec4f9a3 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppStageSuccessPartialSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppStageSuccessPartialSvc_win.js @@ -33,5 +33,6 @@ function checkUpdateFinished() { function checkUpdateApplied() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppSuccessCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppSuccessCompleteSvc_win.js index c09ac63fc86..a06d49078cc 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppSuccessCompleteSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppSuccessCompleteSvc_win.js @@ -25,5 +25,6 @@ function setupAppFilesFinished() { function checkUpdateFinished() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); + standardInit(); checkCallbackServiceLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppSuccessPartialSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppSuccessPartialSvc_win.js index 639743f3c3a..d8cbf8a310b 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppSuccessPartialSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppSuccessPartialSvc_win.js @@ -25,5 +25,6 @@ function setupAppFilesFinished() { function checkUpdateFinished() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); + standardInit(); checkCallbackServiceLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marFailurePartialSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/marFailurePartialSvc.js index 04b8fc19a03..9d7f2296498 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFailurePartialSvc.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFailurePartialSvc.js @@ -33,7 +33,8 @@ function run_test() { } function setupAppFilesFinished() { - runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED); + runUpdateUsingService(STATE_PENDING_SVC, + STATE_FAILED_LOADSOURCE_ERROR_WRONG_SIZE); } /** @@ -59,5 +60,6 @@ function checkUpdateFinished() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContents(LOG_PARTIAL_FAILURE); + standardInit(); checkCallbackServiceLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseFallbackStageFailureCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseFallbackStageFailureCompleteSvc_win.js index fcaccf936d7..94b81307e60 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseFallbackStageFailureCompleteSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseFallbackStageFailureCompleteSvc_win.js @@ -51,5 +51,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseFallbackStageFailurePartialSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseFallbackStageFailurePartialSvc_win.js index 5e45415dc47..b39b2446739 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseFallbackStageFailurePartialSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseFallbackStageFailurePartialSvc_win.js @@ -51,5 +51,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailureCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailureCompleteSvc_win.js index 7c8860be895..3cac10b65ed 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailureCompleteSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailureCompleteSvc_win.js @@ -52,5 +52,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, true, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailurePartialSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailurePartialSvc_win.js index 7c5be9ba625..ac2e98d85b9 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailurePartialSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailurePartialSvc_win.js @@ -52,5 +52,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, true, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessCompleteSvc_win.js index 56e2ad27ae0..d35d6dbb994 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessCompleteSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessCompleteSvc_win.js @@ -42,5 +42,6 @@ function checkUpdateFinished() { function checkUpdate() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, true); checkUpdateLogContains(ERR_BACKUP_DISCARD); + standardInit(); checkCallbackServiceLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessPartialSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessPartialSvc_win.js index 071d517926f..ae34168f100 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessPartialSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessPartialSvc_win.js @@ -42,5 +42,6 @@ function checkUpdateFinished() { function checkUpdate() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, true); checkUpdateLogContains(ERR_BACKUP_DISCARD); + standardInit(); checkCallbackServiceLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailureCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailureCompleteSvc_win.js index 3f48bddd71d..77afda10265 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailureCompleteSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailureCompleteSvc_win.js @@ -42,7 +42,7 @@ function setupAppFilesFinished() { } function doUpdate() { - runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED); + runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED_WRITE_ERROR); } function checkUpdateFinished() { @@ -52,5 +52,6 @@ function checkUpdateFinished() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackServiceLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailurePartialSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailurePartialSvc_win.js index ba32bb68732..9a2fac75181 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailurePartialSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailurePartialSvc_win.js @@ -42,7 +42,7 @@ function setupAppFilesFinished() { } function doUpdate() { - runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED); + runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED_READ_ERROR); } function checkUpdateFinished() { @@ -52,5 +52,6 @@ function checkUpdateFinished() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_UNABLE_OPEN_DEST); + standardInit(); checkCallbackServiceLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFallbackStageFailureCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFallbackStageFailureCompleteSvc_win.js index 3abfcd1e162..cedd87da842 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFallbackStageFailureCompleteSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFallbackStageFailureCompleteSvc_win.js @@ -43,7 +43,7 @@ function setupAppFilesFinished() { } function doUpdate() { - runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED); + runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED_WRITE_ERROR_FILE_COPY); } function checkUpdateFinished() { @@ -60,5 +60,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFallbackStageFailurePartialSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFallbackStageFailurePartialSvc_win.js index 807bba799f6..4427d0c1e0d 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFallbackStageFailurePartialSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFallbackStageFailurePartialSvc_win.js @@ -43,7 +43,7 @@ function setupAppFilesFinished() { } function doUpdate() { - runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED); + runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED_WRITE_ERROR_FILE_COPY); } function checkUpdateFinished() { @@ -60,5 +60,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailureCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailureCompleteSvc_win.js index 3140821155a..2f3b81f5212 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailureCompleteSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailureCompleteSvc_win.js @@ -43,7 +43,7 @@ function setupAppFilesFinished() { } function doUpdate() { - runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED); + runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED_WRITE_ERROR_FILE_COPY); } function checkUpdateFinished() { @@ -61,5 +61,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, true, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailurePartialSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailurePartialSvc_win.js index d05f0eb2f08..004ae67d354 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailurePartialSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailurePartialSvc_win.js @@ -43,7 +43,7 @@ function setupAppFilesFinished() { } function doUpdate() { - runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED); + runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED_WRITE_ERROR_FILE_COPY); } function checkUpdateFinished() { @@ -61,5 +61,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, true, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseFallbackStageFailureCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseFallbackStageFailureCompleteSvc_win.js index 3bedffb952f..ffa72bac9a1 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseFallbackStageFailureCompleteSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseFallbackStageFailureCompleteSvc_win.js @@ -6,9 +6,6 @@ fallback test */ function run_test() { - // Set to true due to bug 1123503 - DEBUG_AUS_TEST = true; - if (!shouldRunServiceTest()) { return; } @@ -65,5 +62,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseFallbackStageFailurePartialSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseFallbackStageFailurePartialSvc_win.js index 8349a49e51d..21d177c4855 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseFallbackStageFailurePartialSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseFallbackStageFailurePartialSvc_win.js @@ -6,9 +6,6 @@ fallback test */ function run_test() { - // Set to true due to bug 1112284 - DEBUG_AUS_TEST = true; - if (!shouldRunServiceTest()) { return; } @@ -63,5 +60,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, false, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseStageFailureCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseStageFailureCompleteSvc_win.js index a699e8ac5fd..47d7563e5e4 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseStageFailureCompleteSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseStageFailureCompleteSvc_win.js @@ -6,9 +6,6 @@ test */ function run_test() { - // Set to true due to bug 1123503 - DEBUG_AUS_TEST = true; - if (!shouldRunServiceTest()) { return; } @@ -66,5 +63,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, true, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseStageFailurePartialSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseStageFailurePartialSvc_win.js index 5429ffb7c87..00a41759550 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseStageFailurePartialSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseStageFailurePartialSvc_win.js @@ -6,9 +6,6 @@ test */ function run_test() { - // Set to true due to bug 1112284 - DEBUG_AUS_TEST = true; - if (!shouldRunServiceTest()) { return; } @@ -64,5 +61,6 @@ function checkUpdateApplied() { function checkUpdate() { checkFilesAfterUpdateFailure(getApplyDirFile, true, false); checkUpdateLogContains(ERR_RENAME_FILE); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseSuccessCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseSuccessCompleteSvc_win.js index 2dd3e4cb0ea..a46caeca7dc 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseSuccessCompleteSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseSuccessCompleteSvc_win.js @@ -52,5 +52,6 @@ function checkUpdateFinished() { function checkUpdate() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, true); checkUpdateLogContains(ERR_BACKUP_DISCARD); + standardInit(); checkCallbackServiceLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseSuccessPartialSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseSuccessPartialSvc_win.js index 027f3ee0862..04f71aab190 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseSuccessPartialSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseSuccessPartialSvc_win.js @@ -50,5 +50,6 @@ function checkUpdateFinished() { function checkUpdate() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, true); checkUpdateLogContains(ERR_BACKUP_DISCARD); + standardInit(); checkCallbackServiceLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marStageFailurePartialSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/marStageFailurePartialSvc.js index 3a975affd6f..5b48bc28f10 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marStageFailurePartialSvc.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marStageFailurePartialSvc.js @@ -6,9 +6,6 @@ /* General Partial MAR File Staged Patch Apply Failure Test */ function run_test() { - // Set to true due to bug 1109219 - DEBUG_AUS_TEST = true; - if (!shouldRunServiceTest()) { return; } @@ -37,7 +34,8 @@ function run_test() { } function setupAppFilesFinished() { - runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED); + runUpdateUsingService(STATE_PENDING_SVC, + STATE_FAILED_LOADSOURCE_ERROR_WRONG_SIZE); } /** @@ -54,5 +52,6 @@ function checkUpdateFinished() { checkFilesAfterUpdateFailure(getApplyDirFile, true, false); checkUpdateLogContents(LOG_PARTIAL_FAILURE); + standardInit(); waitForFilesInUse(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js index 19dc39d67c7..f6a2c0def72 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js @@ -116,6 +116,7 @@ function finishCheckUpdateApplied() { } checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); checkUpdateLogContents(LOG_COMPLETE_SUCCESS); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessPartialSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessPartialSvc.js index 110384831b2..28562b765ed 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessPartialSvc.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessPartialSvc.js @@ -6,9 +6,6 @@ /* General Partial MAR File Staged Patch Apply Test */ function run_test() { - // Set to true due to bug 1083653 - DEBUG_AUS_TEST = true; - if (!shouldRunServiceTest()) { return; } @@ -96,5 +93,6 @@ function finishCheckUpdateApplied() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); checkUpdateLogContents(LOG_PARTIAL_SUCCESS); + standardInit(); checkCallbackAppLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marSuccessCompleteSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/marSuccessCompleteSvc.js index 6ab71585f91..ae9e53ba3af 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marSuccessCompleteSvc.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marSuccessCompleteSvc.js @@ -63,5 +63,6 @@ function finishCheckUpdateFinished() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); checkUpdateLogContents(LOG_COMPLETE_SUCCESS); + standardInit(); checkCallbackServiceLog(); } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marSuccessPartialSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/marSuccessPartialSvc.js index 355489cfb1a..7e6032c3ea1 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marSuccessPartialSvc.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marSuccessPartialSvc.js @@ -69,5 +69,6 @@ function finishCheckUpdateFinished() { checkFilesAfterUpdateSuccess(getApplyDirFile, false, false); checkUpdateLogContents(LOG_PARTIAL_SUCCESS); + standardInit(); checkCallbackServiceLog(); } diff --git a/toolkit/mozapps/update/updater/archivereader.cpp b/toolkit/mozapps/update/updater/archivereader.cpp index f0e6ea33faf..5192f71f0a2 100644 --- a/toolkit/mozapps/update/updater/archivereader.cpp +++ b/toolkit/mozapps/update/updater/archivereader.cpp @@ -308,7 +308,7 @@ ArchiveReader::ExtractItemToStream(const MarItem *item, FILE *fp) outlen = outbuf_size - strm.avail_out; if (outlen) { if (fwrite(outbuf, outlen, 1, fp) != 1) { - ret = WRITE_ERROR; + ret = WRITE_ERROR_EXTRACT; break; } } diff --git a/toolkit/mozapps/update/updater/bspatch.cpp b/toolkit/mozapps/update/updater/bspatch.cpp index 64a730280bd..e632fe3d3df 100644 --- a/toolkit/mozapps/update/updater/bspatch.cpp +++ b/toolkit/mozapps/update/updater/bspatch.cpp @@ -149,7 +149,7 @@ MBS_ApplyPatch(const MBSPatchHeader *header, FILE* patchFile, diffsrc[i] += fbuffer[i]; } if ((uint32_t) fwrite(diffsrc, 1, ctrlsrc->x, file) != ctrlsrc->x) { - rv = WRITE_ERROR; + rv = WRITE_ERROR_PATCH_FILE; goto end; } fbuffer += ctrlsrc->x; @@ -162,7 +162,7 @@ MBS_ApplyPatch(const MBSPatchHeader *header, FILE* patchFile, goto end; } if ((uint32_t) fwrite(extrasrc, 1, ctrlsrc->y, file) != ctrlsrc->y) { - rv = WRITE_ERROR; + rv = WRITE_ERROR_PATCH_FILE; goto end; } extrasrc += ctrlsrc->y; diff --git a/toolkit/mozapps/update/updater/updater.cpp b/toolkit/mozapps/update/updater/updater.cpp index 134ec839fc9..4d020029dd3 100644 --- a/toolkit/mozapps/update/updater/updater.cpp +++ b/toolkit/mozapps/update/updater/updater.cpp @@ -640,9 +640,9 @@ static int ensure_copy(const NS_tchar *path, const NS_tchar *dest) if (!result) { LOG(("ensure_copy: failed to copy the file " LOG_S " over to " LOG_S ", lasterr: %x", path, dest, GetLastError())); - return WRITE_ERROR; + return WRITE_ERROR_FILE_COPY; } - return 0; + return OK; #else struct NS_tstat_t ss; int rv = NS_tlstat(path, &ss); @@ -706,7 +706,7 @@ static int ensure_copy(const NS_tchar *path, const NS_tchar *dest) LOG(("ensure_copy: failed to write the file: " LOG_S ", err: %d", dest, errno)); free(buffer); - return WRITE_ERROR; + return WRITE_ERROR_FILE_COPY; } written += chunkWritten; @@ -822,7 +822,7 @@ static int rename_file(const NS_tchar *spath, const NS_tchar *dpath, if (allowDirs && !S_ISDIR(spathInfo.st_mode)) { LOG(("rename_file: path present, but not a file: " LOG_S ", err: %d", spath, errno)); - return UNEXPECTED_FILE_OPERATION_ERROR; + return RENAME_ERROR_EXPECTED_FILE; } else { LOG(("rename_file: proceeding to rename the directory")); } @@ -832,7 +832,7 @@ static int rename_file(const NS_tchar *spath, const NS_tchar *dpath, if (ensure_remove(dpath)) { LOG(("rename_file: destination file exists and could not be " \ "removed: " LOG_S, dpath)); - return WRITE_ERROR; + return WRITE_ERROR_DELETE_FILE; } } @@ -894,7 +894,7 @@ static int backup_discard(const NS_tchar *path) if (rename_file(backup, path)) { LOG(("backup_discard: failed to rename file:" LOG_S ", dst:" LOG_S, backup, path)); - return WRITE_ERROR; + return WRITE_ERROR_DELETE_BACKUP; } // The MoveFileEx call to remove the file on OS reboot will fail if the // process doesn't have write access to the HKEY_LOCAL_MACHINE registry key @@ -911,7 +911,7 @@ static int backup_discard(const NS_tchar *path) } #else if (rv) - return WRITE_ERROR; + return WRITE_ERROR_DELETE_BACKUP; #endif return OK; @@ -1009,7 +1009,7 @@ RemoveFile::Prepare() if (!S_ISREG(fileInfo.st_mode)) { LOG(("path present, but not a file: " LOG_S, mFile)); - return UNEXPECTED_FILE_OPERATION_ERROR; + return DELETE_ERROR_EXPECTED_FILE; } NS_tchar *slash = (NS_tchar *) NS_tstrrchr(mFile, NS_T('/')); @@ -1023,7 +1023,7 @@ RemoveFile::Prepare() if (rv) { LOG(("access failed: %d", errno)); - return WRITE_ERROR; + return WRITE_ERROR_FILE_ACCESS_DENIED; } return OK; @@ -1118,13 +1118,13 @@ RemoveDir::Prepare() if (!S_ISDIR(dirInfo.st_mode)) { LOG(("path present, but not a directory: " LOG_S, mDir)); - return UNEXPECTED_FILE_OPERATION_ERROR; + return DELETE_ERROR_EXPECTED_DIR; } rv = NS_taccess(mDir, W_OK); if (rv) { LOG(("access failed: %d, %d", rv, errno)); - return WRITE_ERROR; + return WRITE_ERROR_DIR_ACCESS_DENIED; } return OK; @@ -1310,7 +1310,7 @@ PatchFile::LoadSourceFile(FILE* ofile) if (uint32_t(os.st_size) != header.slen) { LOG(("LoadSourceFile: destination file size %d does not match expected size %d", uint32_t(os.st_size), header.slen)); - return UNEXPECTED_FILE_OPERATION_ERROR; + return LOADSOURCE_ERROR_WRONG_SIZE; } buf = (unsigned char *) malloc(header.slen); @@ -1461,7 +1461,7 @@ PatchFile::Execute() // Creating the file, setting the size, and then closing the file handle // lessens fragmentation more than any other method tested. Other methods that // have been tested are: - // 1. _chsize / _chsize_s reduced fragmentation but though not completely. + // 1. _chsize / _chsize_s reduced fragmentation though not completely. // 2. _get_osfhandle and then setting the size reduced fragmentation though // not completely. There are also reports of _get_osfhandle failing on // mingw. @@ -1482,7 +1482,8 @@ PatchFile::Execute() CloseHandle(hfile); } - AutoFile ofile(ensure_open(mFile, shouldTruncate ? NS_T("wb+") : NS_T("rb+"), ss.st_mode)); + AutoFile ofile(ensure_open(mFile, shouldTruncate ? NS_T("wb+") : NS_T("rb+"), + ss.st_mode)); #elif defined(XP_MACOSX) AutoFile ofile(ensure_open(mFile, NS_T("wb+"), ss.st_mode)); // Modified code from FileUtils.cpp @@ -1504,7 +1505,7 @@ PatchFile::Execute() if (ofile == nullptr) { LOG(("unable to create new file: " LOG_S ", err: %d", mFile, errno)); - return WRITE_ERROR; + return WRITE_ERROR_OPEN_PATCH_FILE; } #ifdef XP_WIN @@ -1942,7 +1943,8 @@ ProcessReplaceRequest() // name, so that if the user has used a different case when launching the // application, the installation directory's name does not change. NS_tchar destDir[MAXPATHLEN]; - if (!GetLongPathNameW(gInstallDirPath, destDir, sizeof(destDir)/sizeof(destDir[0]))) { + if (!GetLongPathNameW(gInstallDirPath, destDir, + sizeof(destDir)/sizeof(destDir[0]))) { return NO_INSTALLDIR_ERROR; } #else @@ -1990,6 +1992,8 @@ ProcessReplaceRequest() } #endif if (rv) { + // The status file will have 'pending' written to it so there is no value in + // returning an error specific for this failure. LOG(("Moving destDir to tmpDir failed, err: %d", rv)); return rv; } @@ -2013,6 +2017,8 @@ ProcessReplaceRequest() if (rv2) { LOG(("Moving tmpDir back to destDir failed, err: %d", rv2)); } + // The status file will be have 'pending' written to it so there is no value + // in returning an error specific for this failure. return rv; } @@ -2084,7 +2090,8 @@ ReadMARChannelIDs(const NS_tchar *path, MARChannelStringTable *results) static int GetUpdateFileName(NS_tchar *fileName, int maxChars) { -#if defined(MOZ_WIDGET_GONK) // If an update.link file exists, then it will contain the name +#if defined(MOZ_WIDGET_GONK) + // If an update.link file exists, then it will contain the name // of the update file (terminated by a newline). NS_tchar linkFileName[MAXPATHLEN]; @@ -2226,7 +2233,8 @@ UpdateThreadFunc(void *param) // staged directory as it won't be useful any more. ensure_remove_recursive(gWorkingDirPath); WriteStatusFile(sUsingService ? "pending-service" : "pending"); - putenv(const_cast("MOZ_PROCESS_UPDATES=")); // We need to use --process-updates again in the tests + // We need to use --process-updates again in the tests + putenv(const_cast("MOZ_PROCESS_UPDATES=")); reportRealResults = false; // pretend success } @@ -2439,7 +2447,8 @@ int NS_main(int argc, NS_tchar **argv) fprintf(fs, "%d", oomScoreAdj); fclose(fs); } else { - LOG(("Unable to open /proc/self/oom_score_adj for writing, errno = %d", errno)); + LOG(("Unable to open /proc/self/oom_score_adj for writing, errno = %d", + errno)); } } } @@ -2623,7 +2632,8 @@ int NS_main(int argc, NS_tchar **argv) // are available. If not don't use the service. if (useService) { WCHAR maintenanceServiceKey[MAX_PATH + 1]; - if (CalculateRegistryPathFromFilePath(gInstallDirPath, maintenanceServiceKey)) { + if (CalculateRegistryPathFromFilePath(gInstallDirPath, + maintenanceServiceKey)) { HKEY baseKey = nullptr; if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, maintenanceServiceKey, 0, @@ -2712,7 +2722,8 @@ int NS_main(int argc, NS_tchar **argv) bool updateStatusSucceeded = false; if (IsUpdateStatusSucceeded(updateStatusSucceeded) && updateStatusSucceeded) { - if (!LaunchWinPostProcess(gInstallDirPath, gPatchDirPath, false, nullptr)) { + if (!LaunchWinPostProcess(gInstallDirPath, gPatchDirPath, false, + nullptr)) { fprintf(stderr, "The post update process which runs as the user" " for service update could not be launched."); } @@ -2855,7 +2866,7 @@ int NS_main(int argc, NS_tchar **argv) sizeof(applyDirLongPath)/sizeof(applyDirLongPath[0]))) { LOG(("NS_main: unable to find apply to dir: " LOG_S, gWorkingDirPath)); LogFinish(); - WriteStatusFile(WRITE_ERROR); + WriteStatusFile(WRITE_ERROR_APPLY_DIR_PATH); EXIT_WHEN_ELEVATED(elevatedLockFilePath, updateLockFileHandle, 1); if (argc > callbackIndex) { LaunchCallbackApp(argv[5], argc - callbackIndex, @@ -2900,14 +2911,15 @@ int NS_main(int argc, NS_tchar **argv) size_t callbackPrefixLength = PathCommonPrefixW(argv[callbackIndex], installDir, nullptr); - NS_tstrncpy(p, argv[callbackIndex] + std::max(callbackPrefixLength, commonPrefixLength), bufferLeft); + NS_tstrncpy(p, argv[callbackIndex] + std::max(callbackPrefixLength, + commonPrefixLength), bufferLeft); targetPath = buffer; } if (!GetLongPathNameW(targetPath, callbackLongPath, sizeof(callbackLongPath)/sizeof(callbackLongPath[0]))) { LOG(("NS_main: unable to find callback file: " LOG_S, targetPath)); LogFinish(); - WriteStatusFile(WRITE_ERROR); + WriteStatusFile(WRITE_ERROR_CALLBACK_PATH); EXIT_WHEN_ELEVATED(elevatedLockFilePath, updateLockFileHandle, 1); if (argc > callbackIndex) { LaunchCallbackApp(argv[5], @@ -3187,7 +3199,7 @@ ActionList::Prepare() // actually done. See bug 327140. if (mCount == 0) { LOG(("empty action list")); - return UNEXPECTED_MAR_ERROR; + return MAR_ERROR_EMPTY_ACTION_LIST; } Action *a = mFirst; @@ -3297,7 +3309,8 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list) Action *action = new RemoveFile(); rv = action->Parse(quotedpath); if (rv) { - LOG(("add_dir_entries Parse error on recurse: " LOG_S ", err: %d", quotedpath, rv)); + LOG(("add_dir_entries Parse error on recurse: " LOG_S ", err: %d", + quotedpath, rv)); return rv; } @@ -3315,7 +3328,8 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list) Action *action = new RemoveDir(); rv = action->Parse(quotedpath); if (rv) - LOG(("add_dir_entries Parse error on close: " LOG_S ", err: %d", quotedpath, rv)); + LOG(("add_dir_entries Parse error on close: " LOG_S ", err: %d", + quotedpath, rv)); else list->Append(action); }