Bug 648599: When an add-on changes from being softblocked to unblocked it should become enabled. r=robstrong

This commit is contained in:
Dave Townsend 2011-05-19 11:04:44 -07:00
Родитель 39501915da
Коммит 7e7f82f879
33 изменённых файлов: 2477 добавлений и 114 удалений

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

@ -42,9 +42,10 @@ const Ci = Components.interfaces;
const Cr = Components.results;
const PREF_BLOCKLIST_PINGCOUNTVERSION = "extensions.blocklist.pingCountVersion";
const PREF_EM_UPDATE_ENABLED = "extensions.update.enabled";
const PREF_EM_LAST_APP_VERSION = "extensions.lastAppVersion";
const PREF_EM_AUTOUPDATE_DEFAULT = "extensions.update.autoUpdateDefault";
const PREF_EM_UPDATE_ENABLED = "extensions.update.enabled";
const PREF_EM_LAST_APP_VERSION = "extensions.lastAppVersion";
const PREF_EM_LAST_PLATFORM_VERSION = "extensions.lastPlatformVersion";
const PREF_EM_AUTOUPDATE_DEFAULT = "extensions.update.autoUpdateDefault";
Components.utils.import("resource://gre/modules/Services.jsm");
@ -231,9 +232,16 @@ var AddonManagerInternal = {
let appChanged = undefined;
let oldAppVersion = null;
try {
appChanged = Services.appinfo.version !=
Services.prefs.getCharPref(PREF_EM_LAST_APP_VERSION);
oldAppVersion = Services.prefs.getCharPref(PREF_EM_LAST_APP_VERSION);
appChanged = Services.appinfo.version != oldAppVersion;
}
catch (e) { }
let oldPlatformVersion = null;
try {
oldPlatformVersion = Services.prefs.getCharPref(PREF_EM_LAST_PLATFORM_VERSION);
}
catch (e) { }
@ -241,6 +249,8 @@ var AddonManagerInternal = {
LOG("Application has been upgraded");
Services.prefs.setCharPref(PREF_EM_LAST_APP_VERSION,
Services.appinfo.version);
Services.prefs.setCharPref(PREF_EM_LAST_PLATFORM_VERSION,
Services.appinfo.platformVersion);
Services.prefs.setIntPref(PREF_BLOCKLIST_PINGCOUNTVERSION,
(appChanged === undefined ? 0 : -1));
}
@ -273,7 +283,8 @@ var AddonManagerInternal = {
}
this.providers.forEach(function(provider) {
callProvider(provider, "startup", null, appChanged);
callProvider(provider, "startup", null, appChanged, oldAppVersion,
oldPlatformVersion);
});
gStarted = true;
},

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

@ -386,6 +386,7 @@ function parseRDFManifest(aId, aType, aUpdateKey, aRequest) {
}
let result = {
id: aId,
version: version,
updateURL: getProperty(ds, targetApp, "updateLink"),
updateHash: getProperty(ds, targetApp, "updateHash"),
@ -684,10 +685,17 @@ var AddonUpdateChecker = {
if (!aPlatformVersion)
aPlatformVersion = Services.appinfo.platformVersion;
let blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
getService(Ci.nsIBlocklistService);
let newest = null;
for (let i = 0; i < aUpdates.length; i++) {
if (!aUpdates[i].updateURL)
continue;
let state = blocklist.getAddonBlocklistState(aUpdates[i].id, aUpdates[i].version,
aAppVersion, aPlatformVersion);
if (state != Ci.nsIBlocklistService.STATE_NOT_BLOCKED)
continue;
if ((newest == null || (Services.vc.compare(newest.version, aUpdates[i].version) < 0)) &&
matchesVersions(aUpdates[i], aAppVersion, aPlatformVersion))
newest = aUpdates[i];

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

@ -115,7 +115,7 @@ const TOOLKIT_ID = "toolkit@mozilla.org";
const BRANCH_REGEXP = /^([^\.]+\.[0-9]+[a-z]*).*/gi;
const DB_SCHEMA = 3;
const DB_SCHEMA = 4;
const REQ_VERSION = 2;
// Properties that exist in the install manifest
@ -130,7 +130,8 @@ const PROP_TARGETAPP = ["id", "minVersion", "maxVersion"];
const DB_METADATA = ["installDate", "updateDate", "size", "sourceURI",
"releaseNotesURI", "applyBackgroundUpdates"];
const DB_BOOL_METADATA = ["visible", "active", "userDisabled", "appDisabled",
"pendingUninstall", "bootstrap", "skinnable"];
"pendingUninstall", "bootstrap", "skinnable",
"softDisabled"];
const BOOTSTRAP_REASONS = {
APP_STARTUP : 1,
@ -412,6 +413,61 @@ function findClosestLocale(aLocales) {
return null;
}
/**
* Sets the userDisabled and softDisabled properties of an add-on based on what
* values those properties had for a previous instance of the add-on. The
* previous instance may be a previous install or in the case of an application
* version change the same add-on.
*
* @param aOldAddon
* The previous instance of the add-on
* @param aNewAddon
* The new instance of the add-on
* @param aAppVersion
* The optional application version to use when checking the blocklist
* or undefined to use the current application
* @param aPlatformVersion
* The optional platform version to use when checking the blocklist or
* undefined to use the current platform
*/
function applyBlocklistChanges(aOldAddon, aNewAddon, aOldAppVersion,
aOldPlatformVersion) {
// Copy the properties by default
aNewAddon.userDisabled = aOldAddon.userDisabled;
aNewAddon.softDisabled = aOldAddon.softDisabled;
let bs = Cc["@mozilla.org/extensions/blocklist;1"].
getService(Ci.nsIBlocklistService);
let oldBlocklistState = bs.getAddonBlocklistState(aOldAddon.id,
aOldAddon.version,
aOldAppVersion,
aOldPlatformVersion);
let newBlocklistState = bs.getAddonBlocklistState(aNewAddon.id,
aNewAddon.version);
// If the blocklist state hasn't changed then the properties don't need to
// change
if (newBlocklistState == oldBlocklistState)
return;
if (newBlocklistState == Ci.nsIBlocklistService.STATE_SOFTBLOCKED) {
if (aNewAddon.type != "theme") {
// The add-on has become softblocked, set softDisabled if it isn't already
// userDisabled
aNewAddon.softDisabled = !aNewAddon.userDisabled;
}
else {
// Themes just get userDisabled to switch back to the default theme
aNewAddon.userDisabled = true;
}
}
else {
// If the new add-on is not softblocked then it cannot be softDisabled
aNewAddon.softDisabled = false;
}
}
/**
* Calculates whether an add-on should be appDisabled or not.
*
@ -445,6 +501,10 @@ function isUsableAddon(aAddon) {
return true;
}
function isAddonDisabled(aAddon) {
return aAddon.appDisabled || aAddon.softDisabled || aAddon.userDisabled;
}
this.__defineGetter__("gRDF", function() {
delete this.gRDF;
return this.gRDF = Cc["@mozilla.org/rdf/rdf-service;1"].
@ -704,7 +764,8 @@ function loadManifestFromRDF(aUri, aStream) {
addon.internalName != XPIProvider.selectedSkin;
}
else {
addon.userDisabled = addon.blocklistState == Ci.nsIBlocklistService.STATE_SOFTBLOCKED;
addon.userDisabled = false;
addon.softDisabled = addon.blocklistState == Ci.nsIBlocklistService.STATE_SOFTBLOCKED;
}
addon.appDisabled = !isUsableAddon(addon);
@ -957,7 +1018,8 @@ function verifyZipSigning(aZip, aPrincipal) {
*/
function escapeAddonURI(aAddon, aUri, aUpdateType, aAppVersion)
{
var addonStatus = aAddon.userDisabled ? "userDisabled" : "userEnabled";
var addonStatus = aAddon.userDisabled || aAddon.softDisabled ? "userDisabled"
: "userEnabled";
if (!aAddon.isCompatible)
addonStatus += ",incompatible";
@ -1272,6 +1334,17 @@ var Prefs = {
catch (e) {
}
return defaultValue;
},
/**
* Clears a preference if it has a user value
*
* @param aName
* The name of the preference
*/
clearUserPref: function(aName) {
if (Services.prefs.prefHasUserValue(aName))
Services.prefs.clearUserPref(aName);
}
}
@ -1329,8 +1402,14 @@ var XPIProvider = {
* last used with an application with a different version number,
* false means that the profile was last used by this version of the
* application.
* @param aOldAppVersion
* The version of the application last run with this profile or null
* if it is a new profile or the version is unknown
* @param aOldPlatformVersion
* The version of the platform last run with this profile or null
* if it is a new profile or the version is unknown
*/
startup: function XPI_startup(aAppChanged) {
startup: function XPI_startup(aAppChanged, aOldAppVersion, aOldPlatformVersion) {
LOG("startup");
this.installs = [];
this.installLocations = [];
@ -1431,7 +1510,8 @@ var XPIProvider = {
Services.prefs.addObserver(this.checkCompatibilityPref, this, false);
Services.prefs.addObserver(PREF_EM_CHECK_UPDATE_SECURITY, this, false);
let flushCaches = this.checkForChanges(aAppChanged);
let flushCaches = this.checkForChanges(aAppChanged, aOldAppVersion,
aOldPlatformVersion);
// Changes to installed extensions may have changed which theme is selected
this.applyThemeChange();
@ -2059,6 +2139,12 @@ var XPIProvider = {
* @param aUpdateCompatibility
* true to update add-ons appDisabled property when the application
* version has changed
* @param aOldAppVersion
* The version of the application last run with this profile or null
* if it is a new profile or the version is unknown
* @param aOldPlatformVersion
* The version of the platform last run with this profile or null
* if it is a new profile or the version is unknown
* @param aMigrateData
* an object generated from a previous version of the database
* holding information about what add-ons were previously userDisabled
@ -2071,6 +2157,8 @@ var XPIProvider = {
*/
processFileChanges: function XPI_processFileChanges(aState, aManifests,
aUpdateCompatibility,
aOldAppVersion,
aOldPlatformVersion,
aMigrateData,
aActiveBundles) {
let visibleAddons = {};
@ -2103,8 +2191,7 @@ var XPIProvider = {
if (!newAddon) {
let file = aInstallLocation.getLocationForID(aOldAddon.id);
newAddon = loadManifestFromFile(file);
// Carry over the userDisabled setting for add-ons that just appeared
newAddon.userDisabled = aOldAddon.userDisabled;
applyBlocklistChanges(aOldAddon, newAddon);
}
// The ID in the manifest that was loaded must match the ID of the old
@ -2136,6 +2223,11 @@ var XPIProvider = {
if (newAddon.visible) {
visibleAddons[newAddon.id] = newAddon;
// If this was the active theme and it is now disabled then enable the
// default theme
if (aOldAddon.active && isAddonDisabled(newAddon))
XPIProvider.enableDefaultTheme();
// If the new add-on is bootstrapped and active then call its install method
if (newAddon.active && newAddon.bootstrap) {
let installReason = Services.vc.compare(aOldAddon.version, newAddon.version) < 0 ?
@ -2193,7 +2285,7 @@ var XPIProvider = {
// If it should be active then mark it as active otherwise unload
// its scope
if (!aOldAddon.appDisabled && !aOldAddon.userDisabled) {
if (!isAddonDisabled(aOldAddon)) {
aOldAddon.active = true;
XPIDatabase.updateAddonActive(aOldAddon);
}
@ -2210,26 +2302,40 @@ var XPIProvider = {
// App version changed, we may need to update the appDisabled property.
if (aUpdateCompatibility) {
let appDisabled = !isUsableAddon(aOldAddon);
let userDisabled = aOldAddon.userDisabled;
// Create a basic add-on object for the new state to save reproducing
// the applyBlocklistChanges code
let newAddon = new AddonInternal();
newAddon.id = aOldAddon.id;
newAddon.version = aOldAddon.version;
newAddon.type = aOldAddon.type;
newAddon.appDisabled = !isUsableAddon(aOldAddon);
// Sync the userDisabled flag to the selectedSkin
if (aOldAddon.type == "theme")
userDisabled = aOldAddon.internalName != XPIProvider.selectedSkin;
let wasDisabled = aOldAddon.appDisabled || aOldAddon.userDisabled;
let isDisabled = appDisabled || userDisabled;
newAddon.userDisabled = aOldAddon.internalName != XPIProvider.selectedSkin;
applyBlocklistChanges(aOldAddon, newAddon, aOldAppVersion,
aOldPlatformVersion);
let wasDisabled = isAddonDisabled(aOldAddon);
let isDisabled = isAddonDisabled(newAddon);
// Remember add-ons that became appDisabled by the application change
if (aOldAddon.visible && appDisabled && !aOldAddon.appDisabled)
if (aOldAddon.visible && newAddon.appDisabled && !aOldAddon.appDisabled)
XPIProvider.startupChanges.appDisabled.push(aOldAddon.id);
// If either property has changed update the database.
if (appDisabled != aOldAddon.appDisabled ||
userDisabled != aOldAddon.userDisabled) {
if (newAddon.appDisabled != aOldAddon.appDisabled ||
newAddon.userDisabled != aOldAddon.userDisabled ||
newAddon.softDisabled != aOldAddon.softDisabled) {
LOG("Add-on " + aOldAddon.id + " changed appDisabled state to " +
appDisabled + " and userDisabled state to " + userDisabled);
newAddon.appDisabled + ", userDisabled state to " +
newAddon.userDisabled + " and softDisabled state to " +
newAddon.softDisabled);
XPIDatabase.setAddonProperties(aOldAddon, {
appDisabled: appDisabled,
userDisabled: userDisabled
appDisabled: newAddon.appDisabled,
userDisabled: newAddon.userDisabled,
softDisabled: newAddon.softDisabled
});
}
@ -2347,6 +2453,8 @@ var XPIProvider = {
newAddon.userDisabled = aMigrateData.userDisabled;
if ("installDate" in aMigrateData)
newAddon.installDate = aMigrateData.installDate;
if ("softDisabled" in aMigrateData)
newAddon.softDisabled = aMigrateData.softDisabled;
// Some properties should only be migrated if the add-on hasn't changed.
// The version property isn't a perfect check for this but covers the
@ -2355,24 +2463,33 @@ var XPIProvider = {
if ("targetApplications" in aMigrateData)
newAddon.applyCompatibilityUpdate(aMigrateData, true);
}
// Since the DB schema has changed make sure softDisabled is correct
applyBlocklistChanges(newAddon, newAddon, aOldAppVersion,
aOldPlatformVersion);
}
// If we have a list of what add-ons should be marked as active then use it
if (aActiveBundles) {
// If we have a list of what add-ons should be marked as active then use
// it to guess at migration data
// For themes we know which is active by the current skin setting
if (newAddon.type == "theme")
newAddon.active = newAddon.internalName == XPIProvider.currentSkin;
else
newAddon.active = aActiveBundles.indexOf(aAddonState.descriptor) != -1;
// If the add-on isn't active and it isn't appDisabled then it is
// probably userDisabled
if (!newAddon.active && newAddon.visible && !newAddon.appDisabled)
newAddon.userDisabled = true;
// If the add-on wasn't active and it isn't already disabled in some way
// then it was probably either softDisabled or userDisabled
if (!newAddon.active && newAddon.visible && !isAddonDisabled(newAddon)) {
// If the add-on is softblocked then assume it is softDisabled
if (newAddon.blocklistState == Ci.nsIBlocklistService.STATE_SOFTBLOCKED)
newAddon.softDisabled = true;
else
newAddon.userDisabled = true;
}
}
else {
newAddon.active = (newAddon.visible && !newAddon.userDisabled &&
!newAddon.appDisabled)
newAddon.active = (newAddon.visible && !isAddonDisabled(newAddon))
}
try {
@ -2553,9 +2670,16 @@ var XPIProvider = {
* last used with an application with a different version number,
* false means that the profile was last used by this version of the
* application.
* @param aOldAppVersion
* The version of the application last run with this profile or null
* if it is a new profile or the version is unknown
* @param aOldPlatformVersion
* The version of the platform last run with this profile or null
* if it is a new profile or the version is unknown
* @return true if a change requiring a restart was detected
*/
checkForChanges: function XPI_checkForChanges(aAppChanged) {
checkForChanges: function XPI_checkForChanges(aAppChanged, aOldAppVersion,
aOldPlatformVersion) {
LOG("checkForChanges");
// Import the website installation permissions if the application has changed
@ -2632,6 +2756,8 @@ var XPIProvider = {
try {
extensionListChanged = this.processFileChanges(state, manifests,
aAppChanged,
aOldAppVersion,
aOldPlatformVersion,
migrateData, null);
}
catch (e) {
@ -2644,7 +2770,7 @@ var XPIProvider = {
// compatible otherwise switch back the default
if (this.currentSkin != this.defaultSkin) {
let oldSkin = XPIDatabase.getVisibleAddonForInternalName(this.currentSkin);
if (!oldSkin || oldSkin.appDisabled)
if (!oldSkin || isAddonDisabled(oldSkin))
this.enableDefaultTheme();
}
@ -2946,10 +3072,27 @@ var XPIProvider = {
enableDefaultTheme: function XPI_enableDefaultTheme() {
LOG("Activating default theme");
let addon = XPIDatabase.getVisibleAddonForInternalName(this.defaultSkin);
if (addon)
this.updateAddonDisabledState(addon, false);
else
if (addon) {
if (addon.userDisabled) {
this.updateAddonDisabledState(addon, false);
}
else if (!this.extensionsActive) {
// During startup we may end up trying to enable the default theme when
// the database thinks it is already enabled (see f.e. bug 638847). In
// this case just force the theme preferences to be correct
Services.prefs.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN,
addon.internalName);
this.currentSkin = this.selectedSkin = addon.internalName;
Prefs.clearUserPref(PREF_DSS_SKIN_TO_SELECT);
Prefs.clearUserPref(PREF_DSS_SWITCHPENDING);
}
else {
WARN("Attempting to activate an already active default theme");
}
}
else {
WARN("Unable to activate the default theme");
}
},
/**
@ -3091,7 +3234,7 @@ var XPIProvider = {
// If the add-on is not going to be active after installation then it
// doesn't require a restart to install.
if (aAddon.userDisabled || aAddon.appDisabled)
if (isAddonDisabled(aAddon))
return false;
// Themes will require a restart (even if dynamic switching is enabled due
@ -3272,29 +3415,49 @@ var XPIProvider = {
* @param aUserDisabled
* Value for the userDisabled property. If undefined the value will
* not change
* @param aSoftDisabled
* Value for the softDisabled property. If undefined the value will
* not change. If true this will force userDisabled to be true
* @throws if addon is not a DBAddonInternal
*/
updateAddonDisabledState: function XPI_updateAddonDisabledState(aAddon,
aUserDisabled) {
aUserDisabled,
aSoftDisabled) {
if (!(aAddon instanceof DBAddonInternal))
throw new Error("Can only update addon states for installed addons.");
if (aUserDisabled !== undefined && aSoftDisabled !== undefined) {
throw new Error("Cannot change userDisabled and softDisabled at the " +
"same time");
}
if (aUserDisabled === undefined)
if (aUserDisabled === undefined) {
aUserDisabled = aAddon.userDisabled;
}
else if (!aUserDisabled) {
// If enabling the add-on then remove softDisabled
aSoftDisabled = false;
}
// If not changing softDisabled or the add-on is already userDisabled then
// use the existing value for softDisabled
if (aSoftDisabled === undefined || aUserDisabled)
aSoftDisabled = aAddon.softDisabled;
let appDisabled = !isUsableAddon(aAddon);
// No change means nothing to do here
if (aAddon.userDisabled == aUserDisabled &&
aAddon.appDisabled == appDisabled)
aAddon.appDisabled == appDisabled &&
aAddon.softDisabled == aSoftDisabled)
return;
let wasDisabled = aAddon.userDisabled || aAddon.appDisabled;
let isDisabled = aUserDisabled || appDisabled;
let wasDisabled = isAddonDisabled(aAddon);
let isDisabled = aUserDisabled || aSoftDisabled || appDisabled;
// Update the properties in the database
XPIDatabase.setAddonProperties(aAddon, {
userDisabled: aUserDisabled,
appDisabled: appDisabled
appDisabled: appDisabled,
softDisabled: aSoftDisabled
});
// If the add-on is not visible or the add-on is not changing state then
@ -3413,8 +3576,7 @@ var XPIProvider = {
let wrappedAddon = createWrapper(aAddon);
AddonManagerPrivate.callAddonListeners("onInstalling", wrappedAddon, false);
if (!aAddon.userDisabled && !aAddon.appDisabled &&
!XPIProvider.enableRequiresRestart(aAddon)) {
if (!isAddonDisabled(aAddon) && !XPIProvider.enableRequiresRestart(aAddon)) {
aAddon.active = true;
XPIDatabase.updateAddonActive(aAddon);
}
@ -3495,7 +3657,7 @@ const FIELDS_ADDON = "internal_id, id, location, version, type, internalName, "
"icon64URL, defaultLocale, visible, active, userDisabled, " +
"appDisabled, pendingUninstall, descriptor, installDate, " +
"updateDate, applyBackgroundUpdates, bootstrap, skinnable, " +
"size, sourceURI, releaseNotesURI";
"size, sourceURI, releaseNotesURI, softDisabled";
/**
* A helper function to log an SQL error.
@ -3640,7 +3802,7 @@ var XPIDatabase = {
":userDisabled, :appDisabled, :pendingUninstall, " +
":descriptor, :installDate, :updateDate, " +
":applyBackgroundUpdates, :bootstrap, :skinnable, " +
":size, :sourceURI, :releaseNotesURI)",
":size, :sourceURI, :releaseNotesURI, :softDisabled)",
addAddonMetadata_addon_locale: "INSERT INTO addon_locale VALUES " +
"(:internal_id, :name, :locale)",
addAddonMetadata_locale: "INSERT INTO locale (name, description, creator, " +
@ -3683,11 +3845,12 @@ var XPIDatabase = {
makeAddonVisible: "UPDATE addon SET visible=1 WHERE internal_id=:internal_id",
removeAddonMetadata: "DELETE FROM addon WHERE internal_id=:internal_id",
// Equates to active = visible && !userDisabled && !appDisabled
// Equates to active = visible && !userDisabled && !softDisabled && !appDisabled
setActiveAddons: "UPDATE addon SET active=MIN(visible, 1 - userDisabled, " +
"1 - appDisabled)",
"1 - softDisabled, 1 - appDisabled)",
setAddonProperties: "UPDATE addon SET userDisabled=:userDisabled, " +
"appDisabled=:appDisabled, " +
"softDisabled=:softDisabled, " +
"pendingUninstall=:pendingUninstall, " +
"applyBackgroundUpdates=:applyBackgroundUpdates WHERE " +
"internal_id=:internal_id",
@ -3850,7 +4013,8 @@ var XPIDatabase = {
this.beginTransaction();
try {
let state = XPIProvider.getInstallLocationStates();
XPIProvider.processFileChanges(state, {}, false, migrateData, activeBundles)
XPIProvider.processFileChanges(state, {}, false, undefined, undefined,
migrateData, activeBundles)
// Make sure to update the active add-ons and add-ons list on shutdown
Services.prefs.setBoolPref(PREF_PENDING_OPERATIONS, true);
this.commitTransaction();
@ -3998,10 +4162,28 @@ var XPIDatabase = {
// Attempt to migrate data from a different (even future!) version of the
// database
try {
var stmt = this.connection.createStatement("SELECT internal_id, id, " +
"location, userDisabled, " +
"installDate, version " +
"FROM addon");
// Build a list of sql statements that might recover useful data from this
// and future versions of the schema
var sql = [];
sql.push("SELECT internal_id, id, location, userDisabled, " +
"softDisabled, installDate, version FROM addon");
sql.push("SELECT internal_id, id, location, userDisabled, installDate, " +
"version FROM addon");
var stmt = null;
if (!sql.some(function(aSql) {
try {
stmt = this.connection.createStatement(aSql);
return true;
}
catch (e) {
return false;
}
}, this)) {
ERROR("Unable to read anything useful from the database");
return migrateData;
}
for (let row in resultRows(stmt)) {
if (!(row.location in migrateData))
migrateData[row.location] = {};
@ -4012,6 +4194,9 @@ var XPIDatabase = {
userDisabled: row.userDisabled == 1,
targetApplications: []
};
if ("softDisabled" in row)
migrateData[row.location][row.id].softDisabled = row.softDisabled == 1;
}
var taStmt = this.connection.createStatement("SELECT id, minVersion, " +
@ -4131,7 +4316,8 @@ var XPIDatabase = {
"applyBackgroundUpdates INTEGER, " +
"bootstrap INTEGER, skinnable INTEGER, " +
"size INTEGER, sourceURI TEXT, " +
"releaseNotesURI TEXT, UNIQUE (id, location)");
"releaseNotesURI TEXT, softDisabled INTEGER, " +
"UNIQUE (id, location)");
this.connection.createTable("targetApplication",
"addon_internal_id INTEGER, " +
"id TEXT, minVersion TEXT, maxVersion TEXT, " +
@ -4892,7 +5078,7 @@ var XPIDatabase = {
let stmt = this.getStatement("setAddonProperties");
stmt.params.internal_id = aAddon._internal_id;
["userDisabled", "appDisabled",
["userDisabled", "appDisabled", "softDisabled",
"pendingUninstall"].forEach(function(aProp) {
if (aProp in aProperties) {
stmt.params[aProp] = convertBoolean(aProperties[aProp]);
@ -5103,7 +5289,7 @@ function AddonInstall(aCallback, aInstallLocation, aUrl, aHash, aName, aType,
XPIDatabase.getVisibleAddonForID(self.addon.id, function(aAddon) {
self.existingAddon = aAddon;
if (aAddon)
self.addon.userDisabled = aAddon.userDisabled;
applyBlocklistChanges(aAddon, self.addon);
self.addon.updateDate = Date.now();
self.addon.installDate = aAddon ? aAddon.installDate : self.addon.updateDate;
@ -5808,8 +5994,8 @@ AddonInstall.prototype = {
if (self.existingAddon) {
self.addon.existingAddonID = self.existingAddon.id;
self.addon.userDisabled = self.existingAddon.userDisabled;
self.addon.installDate = self.existingAddon.installDate;
applyBlocklistChanges(self.existingAddon, self.addon);
}
else {
self.addon.installDate = self.addon.updateDate;
@ -5979,8 +6165,7 @@ AddonInstall.prototype = {
}
else {
this.addon.installDate = this.addon.updateDate;
this.addon.active = (this.addon.visible && !this.addon.userDisabled &&
!this.addon.appDisabled)
this.addon.active = (this.addon.visible && !isAddonDisabled(this.addon))
XPIDatabase.addAddonMetadata(this.addon, file.persistentDescriptor);
}
@ -6330,6 +6515,7 @@ AddonInternal.prototype = {
visible: false,
userDisabled: false,
appDisabled: false,
softDisabled: false,
sourceURI: null,
releaseNotesURI: null,
@ -6576,7 +6762,7 @@ function AddonWrapper(aAddon) {
["id", "version", "type", "isCompatible", "isPlatformCompatible",
"providesUpdatesSecurely", "blocklistState", "appDisabled",
"userDisabled", "skinnable", "size"].forEach(function(aProp) {
"softDisabled", "skinnable", "size"].forEach(function(aProp) {
this.__defineGetter__(aProp, function() aAddon[aProp]);
}, this);
@ -6763,9 +6949,9 @@ function AddonWrapper(aAddon) {
pending |= AddonManager.PENDING_UNINSTALL;
}
if (aAddon.active && (aAddon.userDisabled || aAddon.appDisabled))
if (aAddon.active && isAddonDisabled(aAddon))
pending |= AddonManager.PENDING_DISABLE;
else if (!aAddon.active && (!aAddon.userDisabled && !aAddon.appDisabled))
else if (!aAddon.active && !isAddonDisabled(aAddon))
pending |= AddonManager.PENDING_ENABLE;
if (aAddon.pendingUpgrade)
@ -6796,7 +6982,7 @@ function AddonWrapper(aAddon) {
return permissions;
if (!aAddon.appDisabled) {
if (aAddon.userDisabled)
if (this.userDisabled)
permissions |= AddonManager.PERM_CAN_ENABLE;
else if (aAddon.type != "theme")
permissions |= AddonManager.PERM_CAN_DISABLE;
@ -6820,8 +7006,11 @@ function AddonWrapper(aAddon) {
return aAddon.active;
});
this.__defineGetter__("userDisabled", function() {
return aAddon.softDisabled || aAddon.userDisabled;
});
this.__defineSetter__("userDisabled", function(val) {
if (val == aAddon.userDisabled)
if (val == this.userDisabled)
return val;
if (aAddon instanceof DBAddonInternal) {
@ -6836,6 +7025,33 @@ function AddonWrapper(aAddon) {
}
else {
aAddon.userDisabled = val;
// When enabling remove the softDisabled flag
if (!val)
aAddon.softDisabled = false;
}
return val;
});
this.__defineSetter__("softDisabled", function(val) {
if (val == aAddon.softDisabled)
return val;
if (aAddon instanceof DBAddonInternal) {
// When softDisabling a theme just enable the active theme
if (aAddon.type == "theme" && val && !aAddon.userDisabled) {
if (aAddon.internalName == XPIProvider.defaultSkin)
throw new Error("Cannot disable the default theme");
XPIProvider.enableDefaultTheme();
}
else {
XPIProvider.updateAddonDisabledState(aAddon, undefined, val);
}
}
else {
// Only set softDisabled if not already disabled
if (!aAddon.userDisabled)
aAddon.softDisabled = val;
}
return val;

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

@ -511,6 +511,7 @@ Blocklist.prototype = {
return;
}
LOG("Blocklist::notify: Requesting " + uri.spec);
var request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
createInstance(Ci.nsIXMLHttpRequest);
request.open("GET", uri.spec, true);
@ -859,19 +860,23 @@ Blocklist.prototype = {
LOG("Blocklist state for " + addons[i].id + " changed from " +
oldState + " to " + state);
// Don't warn about add-ons becoming unblocked.
if (state == 0)
continue;
// We don't want to re-warn about add-ons
if (state == oldState)
continue;
// Ensure that softDisabled is false if the add-on is not soft blocked
if (state != Ci.nsIBlocklistService.STATE_SOFTBLOCKED)
addons[i].softDisabled = false;
// Don't warn about add-ons becoming unblocked.
if (state == Ci.nsIBlocklistService.STATE_NOT_BLOCKED)
continue;
// If an add-on has dropped from hard to soft blocked just mark it as
// user disabled and don't warn about it.
// soft disabled and don't warn about it.
if (state == Ci.nsIBlocklistService.STATE_SOFTBLOCKED &&
oldState == Ci.nsIBlocklistService.STATE_BLOCKED) {
addons[i].userDisabled = true;
addons[i].softDisabled = true;
continue;
}
@ -929,8 +934,10 @@ Blocklist.prototype = {
plugins[i].blocklisted = state == Ci.nsIBlocklistService.STATE_BLOCKED;
}
if (addonList.length == 0)
if (addonList.length == 0) {
Services.obs.notifyObservers(self, "blocklist-updated", "");
return;
}
if ("@mozilla.org/addons/blocklist-prompt;1" in Cc) {
try {
@ -940,6 +947,7 @@ Blocklist.prototype = {
} catch (e) {
LOG(e);
}
Services.obs.notifyObservers(self, "blocklist-updated", "");
return;
}
@ -962,11 +970,13 @@ Blocklist.prototype = {
if (addonList[i].item instanceof Ci.nsIPluginTag)
addonList[i].item.disabled = true;
else
addonList[i].item.userDisabled = true;
addonList[i].item.softDisabled = true;
}
if (args.restart)
restartApp();
Services.obs.notifyObservers(self, "blocklist-updated", "");
});
},

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>hardblock@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:name>Hardblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update1.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>hardblock@tests.mozilla.org</em:id>
<em:version>2.0</em:version>
<em:name>Hardblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update2.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>hardblock@tests.mozilla.org</em:id>
<em:version>3.0</em:version>
<em:name>Hardblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update3.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>softblock1@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:name>Softblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update1.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>softblock1@tests.mozilla.org</em:id>
<em:version>2.0</em:version>
<em:name>Softblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update2.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>softblock1@tests.mozilla.org</em:id>
<em:version>3.0</em:version>
<em:name>Softblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update3.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>softblock2@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:name>Softblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update1.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>softblock2@tests.mozilla.org</em:id>
<em:version>2.0</em:version>
<em:name>Softblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update2.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>softblock2@tests.mozilla.org</em:id>
<em:version>3.0</em:version>
<em:name>Softblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update3.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>softblock3@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:name>Softblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update1.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>softblock3@tests.mozilla.org</em:id>
<em:version>2.0</em:version>
<em:name>Softblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update2.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>softblock3@tests.mozilla.org</em:id>
<em:version>3.0</em:version>
<em:name>Softblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update3.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>softblock4@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:name>Softblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update1.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>softblock4@tests.mozilla.org</em:id>
<em:version>2.0</em:version>
<em:name>Softblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update2.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>softblock4@tests.mozilla.org</em:id>
<em:version>3.0</em:version>
<em:name>Softblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update3.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>softblock5@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:name>Softblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update1.rdf</em:updateURL>
<em:internalName>test/1.0</em:internalName>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>softblock5@tests.mozilla.org</em:id>
<em:version>2.0</em:version>
<em:name>Softblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update2.rdf</em:updateURL>
<em:internalName>test/1.0</em:internalName>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>softblock5@tests.mozilla.org</em:id>
<em:version>3.0</em:version>
<em:name>Softblocked add-on</em:name>
<em:updateURL>http://localhost:4444/data/addon_update3.rdf</em:updateURL>
<em:internalName>test/1.0</em:internalName>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">
<emItems>
<emItem id="softblock1@tests.mozilla.org">
<versionRange severity="1" minVersion="2" maxVersion="3"/>
</emItem>
<emItem id="softblock2@tests.mozilla.org">
<versionRange severity="1" minVersion="2" maxVersion="3"/>
</emItem>
<emItem id="softblock3@tests.mozilla.org">
<versionRange severity="1" minVersion="2" maxVersion="3"/>
</emItem>
<emItem id="softblock4@tests.mozilla.org">
<versionRange severity="1" minVersion="2" maxVersion="3"/>
</emItem>
<emItem id="softblock5@tests.mozilla.org">
<versionRange severity="1" minVersion="2" maxVersion="3"/>
</emItem>
<emItem id="hardblock@tests.mozilla.org">
<versionRange minVersion="2" maxVersion="3"/>
</emItem>
</emItems>
</blocklist>

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

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<RDF:Description about="urn:mozilla:extension:softblock1@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>2</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_soft1_2.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:softblock2@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>2</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_soft2_2.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:softblock3@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>2</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_soft3_2.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:softblock4@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>2</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_soft4_2.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:theme:softblock5@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>2</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_soft5_2.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:hardblock@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>2</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_hard1_2.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
</RDF:RDF>

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

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<RDF:Description about="urn:mozilla:extension:softblock1@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>3</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_soft1_3.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:softblock2@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>3</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_soft2_3.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:softblock3@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>3</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_soft3_3.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:softblock4@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>3</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_soft4_3.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:theme:softblock5@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>3</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_soft5_3.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:hardblock@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>3</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_hard1_3.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
</RDF:RDF>

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

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<RDF:Description about="urn:mozilla:extension:softblock1@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>4</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_soft1_1.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:softblock2@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>4</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_soft2_1.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:softblock3@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>4</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_soft3_1.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:softblock4@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>4</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_soft4_1.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:theme:softblock5@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>4</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_soft5_1.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:hardblock@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>4</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://localhost:4444/addons/blocklist_hard1_1.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
</RDF:RDF>

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

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">
<emItems>
<emItem id="softblock1@tests.mozilla.org">
<versionRange severity="1">
<targetApplication id="xpcshell@tests.mozilla.org">
<versionRange minVersion="2" maxVersion="2.*"/>
</targetApplication>
</versionRange>
</emItem>
<emItem id="softblock2@tests.mozilla.org">
<versionRange severity="1">
<targetApplication id="xpcshell@tests.mozilla.org">
<versionRange minVersion="2" maxVersion="2.*"/>
</targetApplication>
</versionRange>
</emItem>
<emItem id="softblock3@tests.mozilla.org">
<versionRange severity="1">
<targetApplication id="xpcshell@tests.mozilla.org">
<versionRange minVersion="2" maxVersion="2.*"/>
</targetApplication>
</versionRange>
</emItem>
<emItem id="softblock4@tests.mozilla.org">
<versionRange severity="1">
<targetApplication id="xpcshell@tests.mozilla.org">
<versionRange minVersion="2" maxVersion="2.*"/>
</targetApplication>
</versionRange>
</emItem>
<emItem id="softblock5@tests.mozilla.org">
<versionRange severity="1">
<targetApplication id="xpcshell@tests.mozilla.org">
<versionRange minVersion="2" maxVersion="2.*"/>
</targetApplication>
</versionRange>
</emItem>
<emItem id="hardblock@tests.mozilla.org">
<versionRange>
<targetApplication id="xpcshell@tests.mozilla.org">
<versionRange minVersion="2" maxVersion="2.*"/>
</targetApplication>
</versionRange>
</emItem>
</emItems>
</blocklist>

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

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist"/>

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

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">
<emItems>
<emItem id="softblock1@tests.mozilla.org">
<versionRange severity="1"/>
</emItem>
<emItem id="softblock2@tests.mozilla.org">
<versionRange severity="1"/>
</emItem>
<emItem id="softblock3@tests.mozilla.org">
<versionRange severity="1"/>
</emItem>
<emItem id="softblock4@tests.mozilla.org">
<versionRange severity="1"/>
</emItem>
<emItem id="softblock5@tests.mozilla.org">
<versionRange severity="1"/>
</emItem>
<emItem id="hardblock@tests.mozilla.org"/>
</emItems>
</blocklist>

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

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">
<emItems>
<emItem id="softblock1@tests.mozilla.org">
<versionRange severity="1" minVersion="1" maxVersion="2"/>
</emItem>
<emItem id="softblock2@tests.mozilla.org">
<versionRange severity="1" minVersion="1" maxVersion="2"/>
</emItem>
<emItem id="softblock3@tests.mozilla.org">
<versionRange severity="1" minVersion="1" maxVersion="2"/>
</emItem>
<emItem id="softblock4@tests.mozilla.org">
<versionRange severity="1" minVersion="1" maxVersion="2"/>
</emItem>
<emItem id="softblock5@tests.mozilla.org">
<versionRange severity="1" minVersion="1" maxVersion="2"/>
</emItem>
<emItem id="hardblock@tests.mozilla.org">
<versionRange minVersion="1" maxVersion="2"/>
</emItem>
</emItems>
</blocklist>

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

@ -27,7 +27,7 @@ function createAppInfo(id, name, version, platformVersion) {
ID: id,
version: version,
appBuildID: "2007010101",
platformVersion: platformVersion,
platformVersion: platformVersion ? platformVersion : "1.0",
platformBuildID: "2007010101",
// nsIXULRuntime
@ -613,6 +613,22 @@ function setExtensionModifiedTime(aExt, aTime) {
}
}
/**
* Gets the nsIFile for where an add-on is installed. It may point to a file or
* a directory depending on whether add-ons are being installed unpacked or not.
*
* @param aDir
* The nsIFile for the install location
* @param aId
* The ID of the add-on
* @return an nsIFile
*/
function getFileForAddon(aDir, aId) {
var dir = aDir.clone();
dir.append(do_get_expected_addon_name(aId));
return dir;
}
function registerDirectory(aKey, aDir) {
var dirProvider = {
getFile: function(aProp, aPersistent) {

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -239,7 +239,7 @@ function load_blocklist(file) {
}
function check_addon_state(addon) {
return addon.userDisabled + "," + addon.appDisabled;
return addon.userDisabled + "," + addon.softDisabled + "," + addon.appDisabled;
}
function check_plugin_state(plugin) {
@ -278,13 +278,13 @@ function run_test() {
// Before every main test this is the state the add-ons are meant to be in
function check_initial_state(callback) {
AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(addons) {
do_check_eq(check_addon_state(addons[0]), "true,false");
do_check_eq(check_addon_state(addons[1]), "false,false");
do_check_eq(check_addon_state(addons[2]), "false,false");
do_check_eq(check_addon_state(addons[3]), "true,false");
do_check_eq(check_addon_state(addons[4]), "false,false");
do_check_eq(check_addon_state(addons[5]), "false,true");
do_check_eq(check_addon_state(addons[6]), "false,true");
do_check_eq(check_addon_state(addons[0]), "true,false,false");
do_check_eq(check_addon_state(addons[1]), "false,false,false");
do_check_eq(check_addon_state(addons[2]), "false,false,false");
do_check_eq(check_addon_state(addons[3]), "true,true,false");
do_check_eq(check_addon_state(addons[4]), "false,false,false");
do_check_eq(check_addon_state(addons[5]), "false,false,true");
do_check_eq(check_addon_state(addons[6]), "false,false,true");
do_check_eq(check_plugin_state(PLUGINS[0]), "true,false");
do_check_eq(check_plugin_state(PLUGINS[1]), "false,false");
@ -307,17 +307,17 @@ function check_test_pt1() {
do_throw("Addon " + (i + 1) + " did not get installed correctly");
}
do_check_eq(check_addon_state(addons[0]), "false,false");
do_check_eq(check_addon_state(addons[1]), "false,false");
do_check_eq(check_addon_state(addons[2]), "false,false");
do_check_eq(check_addon_state(addons[0]), "false,false,false");
do_check_eq(check_addon_state(addons[1]), "false,false,false");
do_check_eq(check_addon_state(addons[2]), "false,false,false");
// Warn add-ons should be user disabled automatically
do_check_eq(check_addon_state(addons[3]), "true,false");
do_check_eq(check_addon_state(addons[4]), "true,false");
// Warn add-ons should be soft disabled automatically
do_check_eq(check_addon_state(addons[3]), "true,true,false");
do_check_eq(check_addon_state(addons[4]), "true,true,false");
// Blocked and incompatible should be app disabled only
do_check_eq(check_addon_state(addons[5]), "false,true");
do_check_eq(check_addon_state(addons[6]), "false,true");
do_check_eq(check_addon_state(addons[5]), "false,false,true");
do_check_eq(check_addon_state(addons[6]), "false,false,true");
// We've overridden the plugin host so we cannot tell what that would have
// initialised the plugins as
@ -376,19 +376,19 @@ function check_test_pt2() {
AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(addons) {
// Should have disabled this add-on as requested
do_check_eq(check_addon_state(addons[2]), "true,false");
do_check_eq(check_addon_state(addons[2]), "true,true,false");
do_check_eq(check_plugin_state(PLUGINS[2]), "true,false");
// The blocked add-on should have changed to user disabled
do_check_eq(check_addon_state(addons[5]), "true,false");
// The blocked add-on should have changed to soft disabled
do_check_eq(check_addon_state(addons[5]), "true,true,false");
do_check_eq(check_plugin_state(PLUGINS[5]), "true,false");
// These should have been unchanged
do_check_eq(check_addon_state(addons[0]), "true,false");
do_check_eq(check_addon_state(addons[1]), "false,false");
do_check_eq(check_addon_state(addons[3]), "true,false");
do_check_eq(check_addon_state(addons[4]), "false,false");
do_check_eq(check_addon_state(addons[6]), "false,true");
do_check_eq(check_addon_state(addons[0]), "true,false,false");
do_check_eq(check_addon_state(addons[1]), "false,false,false");
do_check_eq(check_addon_state(addons[3]), "true,true,false");
do_check_eq(check_addon_state(addons[4]), "false,false,false");
do_check_eq(check_addon_state(addons[6]), "false,false,true");
do_check_eq(check_plugin_state(PLUGINS[0]), "true,false");
do_check_eq(check_plugin_state(PLUGINS[1]), "false,false");
do_check_eq(check_plugin_state(PLUGINS[3]), "true,false");
@ -460,20 +460,22 @@ function check_test_pt3() {
AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(addons) {
// All should have gained the blocklist state, user disabled as previously
do_check_eq(check_addon_state(addons[0]), "true,true");
do_check_eq(check_addon_state(addons[1]), "false,true");
do_check_eq(check_addon_state(addons[2]), "false,true");
do_check_eq(check_addon_state(addons[3]), "true,true");
do_check_eq(check_addon_state(addons[4]), "false,true");
do_check_eq(check_addon_state(addons[0]), "true,false,true");
do_check_eq(check_addon_state(addons[1]), "false,false,true");
do_check_eq(check_addon_state(addons[2]), "false,false,true");
do_check_eq(check_addon_state(addons[4]), "false,false,true");
do_check_eq(check_plugin_state(PLUGINS[0]), "true,true");
do_check_eq(check_plugin_state(PLUGINS[1]), "false,true");
do_check_eq(check_plugin_state(PLUGINS[2]), "false,true");
do_check_eq(check_plugin_state(PLUGINS[3]), "true,true");
do_check_eq(check_plugin_state(PLUGINS[4]), "false,true");
// Should have gained the blocklist state but no longer be soft disabled
do_check_eq(check_addon_state(addons[3]), "false,false,true");
// Shouldn't be changed
do_check_eq(check_addon_state(addons[5]), "false,true");
do_check_eq(check_addon_state(addons[6]), "false,true");
do_check_eq(check_addon_state(addons[5]), "false,false,true");
do_check_eq(check_addon_state(addons[6]), "false,false,true");
do_check_eq(check_plugin_state(PLUGINS[5]), "false,true");
// Back to starting state
@ -511,16 +513,18 @@ function check_test_pt4() {
AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(addons) {
// This should have become unblocked
do_check_eq(check_addon_state(addons[5]), "false,false");
do_check_eq(check_addon_state(addons[5]), "false,false,false");
do_check_eq(check_plugin_state(PLUGINS[5]), "false,false");
// Should get re-enabled
do_check_eq(check_addon_state(addons[3]), "false,false,false");
// No change for anything else
do_check_eq(check_addon_state(addons[0]), "true,false");
do_check_eq(check_addon_state(addons[1]), "false,false");
do_check_eq(check_addon_state(addons[2]), "false,false");
do_check_eq(check_addon_state(addons[3]), "true,false");
do_check_eq(check_addon_state(addons[4]), "false,false");
do_check_eq(check_addon_state(addons[6]), "false,true");
do_check_eq(check_addon_state(addons[0]), "true,false,false");
do_check_eq(check_addon_state(addons[1]), "false,false,false");
do_check_eq(check_addon_state(addons[2]), "false,false,false");
do_check_eq(check_addon_state(addons[4]), "false,false,false");
do_check_eq(check_addon_state(addons[6]), "false,false,true");
do_check_eq(check_plugin_state(PLUGINS[0]), "true,false");
do_check_eq(check_plugin_state(PLUGINS[1]), "false,false");
do_check_eq(check_plugin_state(PLUGINS[2]), "false,false");