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
Родитель 3b00aa08e6
Коммит 743c20cd30
3 изменённых файлов: 69 добавлений и 21 удалений

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

@ -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,13 +389,18 @@ appUpdater.prototype =
// checking plugins compatibility information isn't supported and
// getting the scope property of a plugin breaks in some environments
// (see bug 566787).
if (aAddon.type != "plugin" &&
!aAddon.appDisabled && !aAddon.userDisabled &&
aAddon.scope != AddonManager.SCOPE_APPLICATION &&
aAddon.isCompatible &&
!aAddon.isCompatibleWith(self.update.appVersion,
self.update.platformVersion))
self.addons.push(aAddon);
try {
if (aAddon.type != "plugin" &&
!aAddon.appDisabled && !aAddon.userDisabled &&
aAddon.scope != AddonManager.SCOPE_APPLICATION &&
aAddon.isCompatible &&
!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) {

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

@ -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,13 +545,18 @@ var gUpdates = {
// checking plugins compatibility information isn't supported and
// getting the scope property of a plugin breaks in some environments
// (see bug 566787).
if (addon.type != "plugin" &&
!addon.appDisabled && !addon.userDisabled &&
addon.scope != AddonManager.SCOPE_APPLICATION &&
addon.isCompatible &&
!addon.isCompatibleWith(self.update.appVersion,
self.update.platformVersion))
self.addons.push(addon);
try {
if (addon.type != "plugin" &&
!addon.appDisabled && !addon.userDisabled &&
addon.scope != AddonManager.SCOPE_APPLICATION &&
addon.isCompatible &&
!addon.isCompatibleWith(self.update.appVersion,
self.update.platformVersion))
self.addons.push(addon);
}
catch (e) {
Components.utils.reportError(e);
}
});
aCallback(self.addons.length != 0);

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

@ -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,13 +1535,18 @@ UpdateService.prototype = {
// checking plugins compatibility information isn't supported and
// getting the scope property of a plugin breaks in some environments
// (see bug 566787).
if (addon.type != "plugin" &&
!addon.appDisabled && !addon.userDisabled &&
addon.scope != AddonManager.SCOPE_APPLICATION &&
addon.isCompatible &&
!addon.isCompatibleWith(self._update.appVersion,
self._update.platformVersion))
self._incompatibleAddons.push(addon);
try {
if (addon.type != "plugin" &&
!addon.appDisabled && !addon.userDisabled &&
addon.scope != AddonManager.SCOPE_APPLICATION &&
addon.isCompatible &&
!addon.isCompatibleWith(self._update.appVersion,
self._update.platformVersion))
self._incompatibleAddons.push(addon);
}
catch (e) {
Components.utils.reportError(e);
}
});
if (self._incompatibleAddons.length > 0) {