Bug 595078 - Where possible, remove the possibility of other components breaking app update. r=mossop, a=approval2.0

This commit is contained in:
Robert Strong 2011-01-13 11:36:36 -08:00
parent 6730a4355a
commit 0fc8a61c77
3 changed files with 69 additions and 21 deletions

View File

@ -369,6 +369,17 @@ appUpdater.prototype =
self.addons = [];
self.addonsCheckedCount = 0;
aAddons.forEach(function(aAddon) {
// Protect against code that overrides the add-ons manager and doesn't
// implement the isCompatibleWith or the findUpdates method.
if (!("isCompatibleWith" in aAddon) || !("findUpdates" in aAddon)) {
let errMsg = "Add-on doesn't implement either the isCompatibleWith " +
"or the findUpdates method!";
if (aAddon.id)
errMsg += " Add-on ID: " + aAddon.id;
Components.utils.reportError(errMsg);
return;
}
// If an add-on isn't appDisabled and isn't userDisabled then it is
// either active now or the user expects it to be active after the
// restart. If that is the case and the add-on is not installed by the
@ -378,6 +389,7 @@ appUpdater.prototype =
// checking plugins compatibility information isn't supported and
// getting the scope property of a plugin breaks in some environments
// (see bug 566787).
try {
if (aAddon.type != "plugin" &&
!aAddon.appDisabled && !aAddon.userDisabled &&
aAddon.scope != AddonManager.SCOPE_APPLICATION &&
@ -385,6 +397,10 @@ appUpdater.prototype =
!aAddon.isCompatibleWith(self.update.appVersion,
self.update.platformVersion))
self.addons.push(aAddon);
}
catch (e) {
Components.utils.reportError(e);
}
});
self.addonsTotalCount = self.addons.length;
if (self.addonsTotalCount == 0) {

View File

@ -525,6 +525,17 @@ var gUpdates = {
AddonManager.getAllAddons(function(addons) {
self.addons = [];
addons.forEach(function(addon) {
// Protect against code that overrides the add-ons manager and doesn't
// implement the isCompatibleWith or the findUpdates method.
if (!("isCompatibleWith" in addon) || !("findUpdates" in addon)) {
let errMsg = "Add-on doesn't implement either the isCompatibleWith " +
"or the findUpdates method!";
if (addon.id)
errMsg += " Add-on ID: " + addon.id;
Components.utils.reportError(errMsg);
return;
}
// If an add-on isn't appDisabled and isn't userDisabled then it is
// either active now or the user expects it to be active after the
// restart. If that is the case and the add-on is not installed by the
@ -534,6 +545,7 @@ var gUpdates = {
// checking plugins compatibility information isn't supported and
// getting the scope property of a plugin breaks in some environments
// (see bug 566787).
try {
if (addon.type != "plugin" &&
!addon.appDisabled && !addon.userDisabled &&
addon.scope != AddonManager.SCOPE_APPLICATION &&
@ -541,6 +553,10 @@ var gUpdates = {
!addon.isCompatibleWith(self.update.appVersion,
self.update.platformVersion))
self.addons.push(addon);
}
catch (e) {
Components.utils.reportError(e);
}
});
aCallback(self.addons.length != 0);

View File

@ -1515,6 +1515,17 @@ UpdateService.prototype = {
AddonManager.getAllAddons(function(addons) {
self._incompatibleAddons = [];
addons.forEach(function(addon) {
// Protect against code that overrides the add-ons manager and doesn't
// implement the isCompatibleWith or the findUpdates method.
if (!("isCompatibleWith" in addon) || !("findUpdates" in addon)) {
let errMsg = "Add-on doesn't implement either the isCompatibleWith " +
"or the findUpdates method!";
if (addon.id)
errMsg += " Add-on ID: " + addon.id;
Components.utils.reportError(errMsg);
return;
}
// If an add-on isn't appDisabled and isn't userDisabled then it is
// either active now or the user expects it to be active after the
// restart. If that is the case and the add-on is not installed by the
@ -1524,6 +1535,7 @@ UpdateService.prototype = {
// checking plugins compatibility information isn't supported and
// getting the scope property of a plugin breaks in some environments
// (see bug 566787).
try {
if (addon.type != "plugin" &&
!addon.appDisabled && !addon.userDisabled &&
addon.scope != AddonManager.SCOPE_APPLICATION &&
@ -1531,6 +1543,10 @@ UpdateService.prototype = {
!addon.isCompatibleWith(self._update.appVersion,
self._update.platformVersion))
self._incompatibleAddons.push(addon);
}
catch (e) {
Components.utils.reportError(e);
}
});
if (self._incompatibleAddons.length > 0) {