Bug 299716 - Need for em:targetApplication marker for 'the toolkit'. patch=ajvincent, r=dtownsend, r=rstrong

This commit is contained in:
rob_strong@exchangecode.com 2007-08-29 01:16:15 -07:00
Родитель 7a4ce65d7f
Коммит dd0789ea57
29 изменённых файлов: 2883 добавлений и 1574 удалений

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

@ -140,3 +140,5 @@ goOnlineButtonAccesskey=G
newUpdateWindowTitle=%S Add-on Updates
newUpdatesAvailableMsg=There are new updates available for your add-ons.
toolkitName=Gecko Toolkit

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

@ -809,7 +809,7 @@ XPInstallDownloadManager.prototype = {
var type = isTheme ? nsIUpdateItem.TYPE_THEME : nsIUpdateItem.TYPE_EXTENSION;
var item = Components.classes["@mozilla.org/updates/item;1"]
.createInstance(Components.interfaces.nsIUpdateItem);
item.init(url, " ", "app-profile", "", "", displayName, url, "", iconURL, "", type);
item.init(url, " ", "app-profile", "", "", displayName, url, "", iconURL, "", type, "");
items.push(item);
// Advance the enumerator
@ -1755,6 +1755,7 @@ var gExtensionsViewController = {
// Update the view
setRestartMessage(aSelectedItem);
}
// Flush preference change to disk
gPref.QueryInterface(Components.interfaces.nsIPrefService)
.savePrefFile(null);

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

@ -200,7 +200,7 @@ var gVersionInfoPage = {
var em = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(nsIExtensionManager);
// Retrieve the remaining incompatible items.
gUpdateWizard.items = em.getIncompatibleItemList(null, null,
gUpdateWizard.items = em.getIncompatibleItemList(null, null, null,
nsIUpdateItem.TYPE_ADDON,
true, { });
if (gUpdateWizard.items.length > 0) {
@ -545,4 +545,3 @@ var gNoUpdatesPage = {
document.documentElement.getButton("finish").focus();
}
};

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

@ -21,6 +21,7 @@
* Contributor(s):
* Ben Goodger <ben@mozilla.org> (Google Inc.)
* Robert Strong <robert.bugzilla@gmail.com>
* Alexander J. Vincent <ajvincent@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -197,7 +198,7 @@ interface nsIInstallLocation : nsISupports
* XXXben - Some of this stuff should go into a management-ey interface,
* some into an app-startup-ey interface.
*/
[scriptable, uuid(f5c34a77-3487-4b70-a65a-6727fa066324)]
[scriptable, uuid(feccf1ac-df58-43c1-bef0-b86dc768b906)]
interface nsIExtensionManager : nsISupports
{
/**
@ -301,6 +302,8 @@ interface nsIExtensionManager : nsISupports
* @param listener
* An nsIAddonUpdateCheckListener object which will be notified during
* the update check process.
*
* @throws NS_ERROR_ILLEGAL_VALUE if any item is invalid, or if itemCount == 0.
*/
void update([array, size_is(itemCount)] in nsIUpdateItem items,
in unsigned long itemCount,
@ -336,8 +339,10 @@ interface nsIExtensionManager : nsISupports
* with the supplied parameters.
* @param id
* The id of the application to check compatibility against
* @param version
* @param appVersion
* The version of the application to check compatibility against
* @param platformVersion
* The version of the toolkit to check compatibility against
* @param type
* The type of item to return
* @param includeDisabled
@ -348,7 +353,8 @@ interface nsIExtensionManager : nsISupports
* @returns An array of incompatible nsIUpdateItems.
*/
void getIncompatibleItemList(in AString id,
in AString version,
in AString appVersion,
in AString platformVersion,
in unsigned long type,
in boolean includeDisabled,
out unsigned long itemCount,
@ -371,6 +377,8 @@ interface nsIExtensionManager : nsISupports
* @param fromChrome
* true when called from chrome
* false when not called from chrome (e.g. web page)
*
* @throws NS_ERROR_ILLEGAL_VALUE if any item is invalid, or if itemCount == 0.
*/
void addDownloads([array, size_is(itemCount)] in nsIUpdateItem items,
in unsigned long itemCount, in boolean fromChrome);
@ -470,7 +478,7 @@ interface nsIExtensionManager : nsISupports
* XXXben work in progress, the name of this interface will change after the
* update system is complete, probably to nsIAddon
*/
[scriptable, uuid(7f952767-427f-402b-8114-f80c95d1980d)]
[scriptable, uuid(a15390e0-2ad6-422c-9596-94f95286c16f)]
interface nsIUpdateItem : nsISupports
{
/**
@ -540,6 +548,15 @@ interface nsIUpdateItem : nsISupports
*/
readonly attribute long type;
/**
* The target application ID used for checking compatibility for this item.
*
* @note Add-ons can specify a targetApplication id of toolkit@mozilla.org in
* their install manifest for compatibility with all apps using a
* specific release of the toolkit.
*/
readonly attribute AString targetAppID;
/**
* Initializes this Item object.
*/
@ -547,7 +564,7 @@ interface nsIUpdateItem : nsISupports
in AString installLocationKey, in AString minAppVersion,
in AString maxAppVersion, in AString name,
in AString downloadURL, in AString xpiHash, in AString iconURL,
in AString updateURL, in long type);
in AString updateURL, in long type, in AString targetAppID);
/**
* Returns a JS Object source representing an nsIUpdateItem.
@ -622,6 +639,8 @@ interface nsIAddonUpdateCheckListener : nsISupports
* Update for an individual addon has begun
* @param addon
* A nsIUpdateItem object representing the addon being updated
*
* @throws NS_ERROR_ILLEGAL_VALUE if the addon is invalid.
*/
void onAddonUpdateStarted(in nsIUpdateItem addon);
@ -631,6 +650,8 @@ interface nsIAddonUpdateCheckListener : nsISupports
* A nsIUpdateItem object representing the addon being updated
* @param status
* The success or failure code of the update operation
*
* @throws NS_ERROR_ILLEGAL_VALUE if the addon is invalid.
*/
void onAddonUpdateEnded(in nsIUpdateItem addon, in long status);
};
@ -666,4 +687,3 @@ interface nsIAddonUpdateCheckListener : nsISupports
#define EM_ITEM_CANCEL "item-cancel-action"
%}

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

@ -384,7 +384,7 @@ Blocklist.prototype = {
# <versionRange minVersion="1.7" maxVersion="1.7.*"/>
# </targetApplication>
# <targetApplication id="toolkit@mozilla.org">
# <versionRange minVersion="1.8" maxVersion="1.8.*"/>
# <versionRange minVersion="1.9" maxVersion="1.9.*"/>
# </targetApplication>
# </versionRange>
# <versionRange minVersion="3.0" maxVersion="3.0.*">
@ -392,7 +392,7 @@ Blocklist.prototype = {
# <versionRange minVersion="1.5" maxVersion="1.5.*"/>
# </targetApplication>
# <targetApplication id="toolkit@mozilla.org">
# <versionRange minVersion="1.8" maxVersion="1.8.*"/>
# <versionRange minVersion="1.9" maxVersion="1.9.*"/>
# </targetApplication>
# </versionRange>
# </emItem>

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

@ -26,6 +26,7 @@
# Robert Strong <robert.bugzilla@gmail.com>
# Dave Townsend <dave.townsend@blueprintit.co.uk>
# Daniel Veditz <dveditz@mozilla.com>
# Alexander J. Vincent <ajvincent@gmail.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@ -218,6 +219,19 @@ var BundleManager = {
this._appName = brandBundle.GetStringFromName("brandShortName");
}
return this._appName;
},
_toolkitName: "",
/**
* The toolkit's display name.
*/
get toolkitName() {
if (!this._toolkitName) {
var brandBundle = this.getBundle(URI_EXTENSIONS_PROPERTIES)
this._toolkitName = brandBundle.GetStringFromName("toolkitName");
}
return this._toolkitName;
}
};
@ -301,11 +315,10 @@ function getResourceForID(id) {
* ...
*/
function makeItem(id, version, locationKey, minVersion, maxVersion, name,
updateURL, updateHash, iconURL, updateRDF, type) {
var item = Components.classes["@mozilla.org/updates/item;1"]
.createInstance(Components.interfaces.nsIUpdateItem);
updateURL, updateHash, iconURL, updateRDF, type, targetAppID) {
var item = new UpdateItem();
item.init(id, version, locationKey, minVersion, maxVersion, name,
updateURL, updateHash, iconURL, updateRDF, type);
updateURL, updateHash, iconURL, updateRDF, type, targetAppID);
return item;
}
@ -699,8 +712,20 @@ function showIncompatibleError(installData) {
params, params.length);
var message;
var targetAppData = installData.currentApp;
var targetAppName;
var targetVersion;
if (targetAppData &&
(targetAppData.id == TOOLKIT_ID)) {
targetAppName = BundleManager.toolkitName;
targetVersion = gApp.platformVersion;
} else {
targetAppName = BundleManager.appName;
targetVersion = gApp.version;
}
if (!targetAppData) {
params = [installData.name, installData.version, BundleManager.appName];
params = [installData.name, installData.version, targetAppName];
message = extensionStrings.formatStringFromName("incompatibleMessageNoApp",
params, params.length);
}
@ -708,18 +733,19 @@ function showIncompatibleError(installData) {
// If the min target app version and the max target app version are the same, don't show
// a message like, "Foo is only compatible with Firefox versions 0.7 to 0.7", rather just
// show, "Foo is only compatible with Firefox 0.7"
params = [installData.name, installData.version, BundleManager.appName, gApp.version,
installData.name, installData.version, BundleManager.appName,
params = [installData.name, installData.version, targetAppName, targetVersion,
installData.name, installData.version, targetAppName,
targetAppData.minVersion];
message = extensionStrings.formatStringFromName("incompatibleMsgSingleAppVersion",
params, params.length);
}
else {
params = [installData.name, installData.version, BundleManager.appName, gApp.version,
installData.name, installData.version, BundleManager.appName,
params = [installData.name, installData.version, targetAppName, targetVersion,
installData.name, installData.version, targetAppName,
targetAppData.minVersion, targetAppData.maxVersion];
message = extensionStrings.formatStringFromName("incompatibleMsg", params, params.length);
}
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
ps.alert(null, title, message);
@ -1492,7 +1518,6 @@ Installer.prototype = {
* The XPI/JAR file to install from.
*/
_installExtensionFiles: function(file) {
var installer = this;
/**
* Callback for |safeInstallOperation| that performs file level installation
* steps for an Extension.
@ -1545,7 +1570,6 @@ Installer.prototype = {
zipReader.close();
}
var installer = this;
/**
* Callback for |safeInstallOperation| that performs file level installation
* steps for a Theme.
@ -1626,6 +1650,7 @@ Installer.prototype = {
}
}
var installer = this;
var callback = extractExtensionFiles;
if (this._type == nsIUpdateItem.TYPE_THEME)
callback = extractThemeFiles;
@ -2721,7 +2746,8 @@ ExtensionManager.prototype = {
"", /* XPI Update Hash */
getManifestProperty(installManifest, "iconURL"),
getManifestProperty(installManifest, "updateURL"),
installData.type);
installData.type,
targetAppInfo ? targetAppInfo.appID : gApp.ID);
}
return null;
},
@ -3318,6 +3344,7 @@ ExtensionManager.prototype = {
// If there is updated app compatibility info update the data sources.
for (i = 0; i < updatedTargetAppInfos.length; ++i)
ds.updateTargetAppInfo(updatedTargetAppInfos[i].id,
updatedTargetAppInfos[i].targetAppID,
updatedTargetAppInfos[i].minVersion,
updatedTargetAppInfos[i].maxVersion);
@ -3656,7 +3683,8 @@ ExtensionManager.prototype = {
if (targetApp instanceof Components.interfaces.nsIRDFResource) {
try {
var foundAppID = stringData(oldExtensionsDS.GetTarget(targetApp, EM_R("id"), true));
if (foundAppID != currAppID) // Different target application
// Different target application? (Note: v1.0 didn't support toolkit app ID)
if (foundAppID != currAppID)
continue;
updatedMinVersion = stringData(oldExtensionsDS.GetTarget(targetApp, EM_R("minVersion"), true));
@ -3666,7 +3694,7 @@ ExtensionManager.prototype = {
// in the version 1.0 extensions datasource makes it compatible
if (versionChecker.compare(currAppVersion, updatedMinVersion) >= 0 &&
versionChecker.compare(currAppVersion, updatedMaxVersion) <= 0)
ds.updateTargetAppInfo(item.id, updatedMinVersion, updatedMaxVersion);
ds.updateTargetAppInfo(item.id, foundAppID, updatedMinVersion, updatedMaxVersion);
break;
}
@ -3862,7 +3890,8 @@ ExtensionManager.prototype = {
minVersion: readTAProperty(targetApp, "minVersion"),
maxVersion: readTAProperty(targetApp, "maxVersion") };
installData.targetApps.push(data);
if (data.id == gApp.ID)
if ((data.id == gApp.ID) ||
(data.id == TOOLKIT_ID) && !installData.currentApp)
installData.currentApp = data;
}
catch (e) {
@ -4035,7 +4064,7 @@ ExtensionManager.prototype = {
function stageXPIForOtherApps(xpiFile, installData) {
for (var i = 0; i < installData.targetApps.length; ++i) {
var targetApp = installData.targetApps[i];
if (targetApp.id != gApp.ID) {
if (targetApp.id != gApp.ID && targetApp.id != TOOLKIT_ID) {
/* XXXben uncomment when this works!
var settingsThingy = Components.classes[]
.getService(Components.interfaces.nsIXULRunnerSettingsThingy);
@ -4158,7 +4187,8 @@ ExtensionManager.prototype = {
"", /* XPI Update Hash */
"", /* Icon URL */
installData.updateURL || "",
installData.type);
installData.type,
installData.currentApp.id);
em.update([item], 1, nsIExtensionManager.UPDATE_CHECK_COMPATIBILITY, this);
},
@ -4182,6 +4212,9 @@ ExtensionManager.prototype = {
* See nsIExtensionManager.idl
*/
onAddonUpdateStarted: function(addon) {
if (!addon)
throw Components.results.NS_ERROR_INVALID_ARG;
LOG("Phone Home Listener: Update For " + addon.id + " started");
em.datasource.addIncompatibleUpdateItem(addon.name, this._xpi.path,
addon.type, addon.version);
@ -4191,6 +4224,9 @@ ExtensionManager.prototype = {
* See nsIExtensionManager.idl
*/
onAddonUpdateEnded: function(addon, status) {
if (!addon)
throw Components.results.NS_ERROR_INVALID_ARG;
LOG("Phone Home Listener: Update For " + addon.id + " ended, status = " + status);
em.datasource.removeDownload(this._xpi.path);
LOG("Version Check Phone Home Completed");
@ -4198,6 +4234,7 @@ ExtensionManager.prototype = {
// supported
if (status == nsIAddonUpdateCheckListener.STATUS_VERSIONINFO) {
em.datasource.setTargetApplicationInfo(addon.id,
addon.targetAppID,
addon.minAppVersion,
addon.maxAppVersion,
this._installManifest);
@ -4208,13 +4245,17 @@ ExtensionManager.prototype = {
// Add the updated compatibility info to the datasource if done
if (StartupCache.entries[aInstallLocationKey][addon.id].op == OP_NONE) {
em.datasource.updateTargetAppInfo(addon.id, addon.minAppVersion,
em.datasource.updateTargetAppInfo(addon.id,
addon.targetAppID,
addon.minAppVersion,
addon.maxAppVersion);
}
else { // needs a restart
// Add updatedMinVersion and updatedMaxVersion so it can be used
// to update the data sources during the installation or upgrade.
em.datasource.setUpdatedTargetAppInfo(addon.id, addon.minAppVersion,
em.datasource.setUpdatedTargetAppInfo(addon.id,
addon.targetAppID,
addon.minAppVersion,
addon.maxAppVersion);
}
// Prevent the datasource file from being lazily recreated after
@ -5055,6 +5096,15 @@ ExtensionManager.prototype = {
* See nsIExtensionManager.idl
*/
update: function(items, itemCount, updateCheckType, listener) {
if (itemCount == 0)
throw Components.results.NS_ERROR_ILLEGAL_VALUE;
for (i = 0; i < itemCount; ++i) {
var currItem = items[i];
if (!currItem)
throw Components.results.NS_ERROR_ILLEGAL_VALUE;
}
var appID = gApp.ID;
var appVersion = gApp.version;
@ -5151,12 +5201,11 @@ ExtensionManager.prototype = {
return this.datasource.getItemList(type, countRef);
},
/**
* See nsIExtensionManager.idl
*/
getIncompatibleItemList: function(id, version, type, includeDisabled,
/* See nsIExtensionManager.idl */
getIncompatibleItemList: function(id, appVersion, platformVersion, type, includeDisabled,
countRef) {
var items = this.datasource.getIncompatibleItemList(id, version ? version : undefined,
var items = this.datasource.getIncompatibleItemList(id, appVersion ? appVersion : undefined,
platformVersion ? platformVersion : undefined,
type, includeDisabled);
countRef.value = items.length;
return items;
@ -5303,18 +5352,17 @@ ExtensionManager.prototype = {
return rv == 1;
},
/**
* Adds a set of Item Downloads to the Manager and starts the download
* operation.
* @param items
* An array of nsIUpdateItems to begin downlading.
* @param itemCount
* The length of |items|
* @param fromChrome
* true when called from chrome
* false when not called from chrome (e.g. web page)
*/
/* See nsIExtensionManager.idl */
addDownloads: function(items, itemCount, fromChrome) {
if (itemCount == 0)
throw Components.results.NS_ERROR_ILLEGAL_VALUE;
for (i = 0; i < itemCount; ++i) {
var currItem = items[i];
if (!currItem)
throw Components.results.NS_ERROR_ILLEGAL_VALUE;
}
var ds = this.datasource;
// Add observers only if they aren't already added for an active download
if (this._downloadCount == 0) {
@ -5328,6 +5376,7 @@ ExtensionManager.prototype = {
var txn = new ItemDownloadTransaction(this);
for (var i = 0; i < itemCount; ++i) {
var currItem = items[i];
var txnID = Math.round(Math.random() * 100);
txn.addDownload(currItem, txnID);
this._transactions.push(txn);
@ -5527,13 +5576,12 @@ ExtensionManager.prototype = {
return Components.interfaces.nsIClassInfo.SINGLETON;
},
/**
* See nsISupports.idl
*/
/* See nsISupports.idl */
QueryInterface: function(iid) {
if (!iid.equals(Components.interfaces.nsIExtensionManager) &&
!iid.equals(Components.interfaces.nsITimerCallback) &&
!iid.equals(Components.interfaces.nsIObserver) &&
!iid.equals(Components.interfaces.nsIClassInfo) &&
!iid.equals(Components.interfaces.nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
@ -5761,7 +5809,9 @@ ExtensionItemUpdater.prototype = {
if (gVersionChecker.compare(targetAppInfo.maxVersion, aRemoteItem.maxAppVersion) < 0) {
// Remotely specified maxVersion is newer than the maxVersion
// for the installed Extension. Apply that change to the datasources.
this._emDS.updateTargetAppInfo(aLocalItem.id, aRemoteItem.minAppVersion,
this._emDS.updateTargetAppInfo(aLocalItem.id,
aRemoteItem.targetAppID,
aRemoteItem.minAppVersion,
aRemoteItem.maxAppVersion);
// If we got here through |checkForMismatches|, this extension has
@ -5773,7 +5823,9 @@ ExtensionItemUpdater.prototype = {
return true;
}
else if (this._updateCheckType == nsIExtensionManager.UPDATE_SYNC_COMPATIBILITY)
this._emDS.updateTargetAppInfo(aLocalItem.id, aRemoteItem.minAppVersion,
this._emDS.updateTargetAppInfo(aLocalItem.id,
aRemoteItem.targetAppID,
aRemoteItem.minAppVersion,
aRemoteItem.maxAppVersion);
return false;
},
@ -5782,30 +5834,31 @@ ExtensionItemUpdater.prototype = {
* Checks whether a discovered update is valid for install
* @param aLocalItem
* The already installed nsIUpdateItem that the update is for
* @param aVersion
* The updated version of the add-on
* @param aMinAppVersion
* The minimum application version that the update supports
* @param aMaxApVersion
* The maximum application version that the update supports
* @param aRemoteItem
* The nsIUpdateItem we are trying to update to
*
* @returns true if the item is compatible and is not blocklisted.
* false if the item is not compatible or is blocklisted.
*/
_isValidUpdate: function(aLocalItem, aVersion, aMinAppVersion, aMaxAppVersion) {
var appExtensionsVersion = gApp.version;
_isValidUpdate: function _isValidUpdate(aLocalItem, aRemoteItem) {
var appExtensionsVersion = (aRemoteItem.targetAppID != TOOLKIT_ID) ?
gApp.version :
gApp.platformVersion;
// Check if the update will only run on a newer version of Firefox.
if (aMinAppVersion &&
gVersionChecker.compare(appExtensionsVersion, aMinAppVersion) < 0)
var min = aRemoteItem.minAppVersion;
var max = aRemoteItem.maxAppVersion;
// Check if the update will only run on a newer version of the application.
if (min && gVersionChecker.compare(appExtensionsVersion, min) < 0)
return false;
// Check if the update will only run on an older version of Firefox.
if (aMaxAppVersion &&
gVersionChecker.compare(appExtensionsVersion, aMaxAppVersion) > 0)
// Check if the update will only run on an older version of the application.
if (max && gVersionChecker.compare(appExtensionsVersion, max) > 0)
return false;
if (!gBlocklist)
gBlocklist = Components.classes["@mozilla.org/extensions/blocklist;1"]
.getService(Components.interfaces.nsIBlocklistService);
if (gBlocklist.isAddonBlocklisted(aLocalItem.id, aVersion,
if (gBlocklist.isAddonBlocklisted(aLocalItem.id, aRemoteItem.version,
undefined, undefined))
return false;
@ -5973,7 +6026,8 @@ RDFItemUpdater.prototype = {
uri.spec + ", item = " + aItem.objectSource);
var request = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance(Components.interfaces.nsIXMLHttpRequest);
.createInstance(Components.interfaces.nsIXMLHttpRequest)
.QueryInterface(Components.interfaces.nsIJSXMLHttpRequest);
request.open("GET", uri.spec, true);
request.channel.notificationCallbacks = new BadCertHandler();
request.overrideMimeType("text/xml");
@ -6112,11 +6166,11 @@ RDFItemUpdater.prototype = {
" type (text/xml)");
}
// Parse the response RDF
function UpdateData() {};
UpdateData.prototype = { version: "0.0", updateLink: null, updateHash: null,
minVersion: "0.0", maxVersion: "0.0", found: false };
minVersion: "0.0", maxVersion: "0.0",
appID: null, found: false };
var versionUpdate = new UpdateData();
var newestUpdate = new UpdateData();
@ -6143,7 +6197,8 @@ RDFItemUpdater.prototype = {
newestUpdate.updateHash,
"", /* Icon URL */
"", /* RDF Update URL */
aLocalItem.type);
aLocalItem.type,
newestUpdate.appID);
++this._updater._updateCount;
}
}
@ -6166,7 +6221,8 @@ RDFItemUpdater.prototype = {
"", /* XPI Update Hash */
"", /* Icon URL */
"", /* RDF Update URL */
aLocalItem.type);
aLocalItem.type,
versionUpdate.appID);
// Install-time updates are not written to the DS because there is no
// entry yet, EM just uses the notifications to ascertain (by hand)
// whether or not there is a remote maxVersion tweak that makes the
@ -6270,8 +6326,8 @@ RDFItemUpdater.prototype = {
var targetApps = aDataSource.GetTargets(aUpdateResource, taArc, true);
while (targetApps.hasMoreElements()) {
var targetApp = targetApps.getNext().QueryInterface(Components.interfaces.nsIRDFResource);
var id = this._getPropertyFromResource(aDataSource, targetApp, "id", aLocalItem);
if (id != this._updater._appID)
var appID = this._getPropertyFromResource(aDataSource, targetApp, "id", aLocalItem);
if (appID != this._updater._appID && appID != TOOLKIT_ID)
continue;
/* If we are looking for new versions then test whether this discovered
@ -6279,15 +6335,17 @@ RDFItemUpdater.prototype = {
* if this update is for the same version as we have installed. */
var result = gVersionChecker.compare(version, aUpdateData.version);
if (aUpdateCheckType == nsIExtensionManager.UPDATE_CHECK_NEWVERSION ? result > 0 : result == 0) {
var maxAppVersion = this._getPropertyFromResource(aDataSource, targetApp, "maxVersion", aLocalItem);
var minAppVersion = this._getPropertyFromResource(aDataSource, targetApp, "minVersion", aLocalItem);
if (this._updater._isValidUpdate(aLocalItem, version, minAppVersion, maxAppVersion)) {
aUpdateData.found = true;
aUpdateData.version = version;
aUpdateData.updateLink = this._getPropertyFromResource(aDataSource, targetApp, "updateLink", aLocalItem);
aUpdateData.updateHash = this._getPropertyFromResource(aDataSource, targetApp, "updateHash", aLocalItem);
aUpdateData.minVersion = minAppVersion;
aUpdateData.maxVersion = maxAppVersion;
aUpdateData.appID = appID;
aUpdateData.version = version;
aUpdateData.minVersion = this._getPropertyFromResource(aDataSource, targetApp, "minVersion", aLocalItem);
aUpdateData.maxVersion = this._getPropertyFromResource(aDataSource, targetApp, "maxVersion", aLocalItem);
aUpdateData.updateLink = this._getPropertyFromResource(aDataSource, targetApp, "updateLink", aLocalItem);
aUpdateData.updateHash = this._getPropertyFromResource(aDataSource, targetApp, "updateHash", aLocalItem);
aUpdateData.found = this._updater._isValidUpdate(aLocalItem, aUpdateData);
if (appID == this._updater._appID) {
// App takes precedence over toolkit. If we found the app, bail out.
return;
}
}
}
@ -6372,39 +6430,50 @@ ExtensionsDataSource.prototype = {
* datasource or an Install Manifest.
* @param source
* The RDF Resource of the item to inspect for compatibility.
* @param version
* @param appVersion
* The version of the application we are checking for compatibility
* against. If this parameter is undefined, the version of the running
* application is used.
* @param platformVersion
* The version of the toolkit to check compatibility against
* @returns true if the item is compatible with this version of the
* application, false, otherwise.
*/
isCompatible: function (datasource, source, version) {
isCompatible: function (datasource, source, appVersion, platformVersion) {
// The Default Theme is always compatible.
if (source.EqualsNode(this._defaultTheme))
return true;
if (version === undefined) {
version = gApp.version;
}
var appID = gApp.ID;
if (appVersion === undefined)
appVersion = gApp.version;
if (platformVersion === undefined)
var platformVersion = gApp.platformVersion;
var targets = datasource.GetTargets(source, EM_R("targetApplication"), true);
var idRes = EM_R("id");
var minVersionRes = EM_R("minVersion");
var maxVersionRes = EM_R("maxVersion");
var versionChecker = getVersionChecker();
var rv = false;
while (targets.hasMoreElements()) {
var targetApp = targets.getNext().QueryInterface(Components.interfaces.nsIRDFResource);
var id = stringData(datasource.GetTarget(targetApp, idRes, true));
var minVersion = stringData(datasource.GetTarget(targetApp, minVersionRes, true));
var maxVersion = stringData(datasource.GetTarget(targetApp, maxVersionRes, true));
if (id == appID) {
var versionChecker = getVersionChecker();
return ((versionChecker.compare(version, minVersion) >= 0) &&
(versionChecker.compare(version, maxVersion) <= 0));
rv = (versionChecker.compare(appVersion, minVersion) >= 0) &&
(versionChecker.compare(appVersion, maxVersion) <= 0);
return rv; // App takes precedence over toolkit.
}
if (id == TOOLKIT_ID) {
rv = (versionChecker.compare(platformVersion, minVersion) >= 0) &&
(versionChecker.compare(platformVersion, maxVersion) <= 0);
// Keep looping, in case the app id is later.
}
}
return false;
return rv;
},
/**
@ -6413,6 +6482,8 @@ ExtensionsDataSource.prototype = {
* The ID of the application - XXXben unused?
* @param appVersion
* The Version of the application to check for incompatibility against.
* @param platformVersion
* The version of the toolkit to check compatibility against
* @param desiredType
* The nsIUpdateItem type of items to look for
* @param includeDisabled
@ -6420,7 +6491,8 @@ ExtensionsDataSource.prototype = {
* @returns An array of nsIUpdateItems that are incompatible with the application
* ID/Version supplied.
*/
getIncompatibleItemList: function(appID, appVersion, desiredType, includeDisabled) {
getIncompatibleItemList: function(appID, appVersion, platformVersion,
desiredType, includeDisabled) {
var items = [];
var ctr = getContainer(this._inner, this._itemRoot);
var elements = ctr.GetElements();
@ -6445,7 +6517,7 @@ ExtensionsDataSource.prototype = {
continue;
if (type != -1 && (type & desiredType) &&
!this.isCompatible(this, item, appVersion))
!this.isCompatible(this, item, appVersion, platformVersion))
items.push(this.getItemForID(id));
}
return items;
@ -6456,7 +6528,7 @@ ExtensionsDataSource.prototype = {
* a specific application or toolkit version.
* @param appVersion
* The Version of the application to check the blocklist against.
* @param toolkitVersion
* @param platformVersion
* The Version of the toolkit to check the blocklist against.
* @param desiredType
* The nsIUpdateItem type of items to look for
@ -6466,7 +6538,7 @@ ExtensionsDataSource.prototype = {
* @returns An array of nsIUpdateItems that are blocklisted with the application
* or toolkit version supplied.
*/
getBlocklistedItemList: function(appVersion, toolkitVersion, desiredType,
getBlocklistedItemList: function(appVersion, platformVersion, desiredType,
includeAppDisabled) {
if (!gBlocklist)
gBlocklist = Components.classes["@mozilla.org/extensions/blocklist;1"]
@ -6486,7 +6558,7 @@ ExtensionsDataSource.prototype = {
var version = this.getItemProperty(id, "version");
if (type != -1 && (type & desiredType) &&
gBlocklist.isAddonBlocklisted(id, version, appVersion, toolkitVersion))
gBlocklist.isAddonBlocklisted(id, version, appVersion, platformVersion))
items.push(this.getItemForID(id));
}
return items;
@ -6580,7 +6652,8 @@ ExtensionsDataSource.prototype = {
updateHash ? updateHash : "",
this.getItemProperty(id, "iconURL"),
this.getItemProperty(id, "updateURL"),
this.getItemProperty(id, "type"));
this.getItemProperty(id, "type"),
targetAppInfo ? targetAppInfo.appID : gApp.ID);
},
/**
@ -6624,17 +6697,23 @@ ExtensionsDataSource.prototype = {
* profile's extensions directory, it exists, and we have write access.
* @param id
* The ID of the item to update target application info for
* @param targetAppID
* The target application ID used for checking compatibility for this item.
* @param minVersion
* The minimum version of the target application that this item can
* run in
* @param maxVersion
* The maximum version of the target application that this item can
* run in
*
* @note Add-ons can specify a targetApplication id of toolkit@mozilla.org in
* their install manifest for compatibility with all apps using a
* specific release of the toolkit.
*/
updateTargetAppInfo: function(id, minVersion, maxVersion)
updateTargetAppInfo: function(id, targetAppID, minVersion, maxVersion)
{
// Update the Extensions datasource
this.setTargetApplicationInfo(id, minVersion, maxVersion, null);
this.setTargetApplicationInfo(id, targetAppID, minVersion, maxVersion, null);
var installLocation = InstallLocations.get(this.getInstallLocationKey(id));
if (installLocation.name != KEY_APP_PROFILE)
@ -6643,7 +6722,7 @@ ExtensionsDataSource.prototype = {
var installManifestFile = installLocation.getItemFile(id, FILE_INSTALL_MANIFEST);
// Only update if the item exists and we can write to the location
if (installManifestFile.exists() && installLocation.canAccess)
this.setTargetApplicationInfo(id, minVersion, maxVersion,
this.setTargetApplicationInfo(id, targetAppID, minVersion, maxVersion,
getInstallManifest(installManifestFile));
},
@ -6669,28 +6748,30 @@ ExtensionsDataSource.prototype = {
var targetApps = this._inner.GetTargets(r, EM_R("targetApplication"), true);
if (!targetApps.hasMoreElements())
targetApps = this._inner.GetTargets(gInstallManifestRoot, EM_R("targetApplication"), true);
var outData = null;
while (targetApps.hasMoreElements()) {
var targetApp = targetApps.getNext();
if (targetApp instanceof Components.interfaces.nsIRDFResource) {
try {
var foundAppID = stringData(this._inner.GetTarget(targetApp, EM_R("id"), true));
if (foundAppID != appID) // Different target application
// Different target application?
if (foundAppID != appID && foundAppID != TOOLKIT_ID)
continue;
var updatedMinVersion = this._inner.GetTarget(targetApp, EM_R("updatedMinVersion"), true);
var updatedMaxVersion = this._inner.GetTarget(targetApp, EM_R("updatedMaxVersion"), true);
if (updatedMinVersion && updatedMaxVersion)
return { id : id,
minVersion: stringData(updatedMinVersion),
maxVersion: stringData(updatedMaxVersion) };
else
return null;
outData = { id : id,
minVersion: stringData(updatedMinVersion),
maxVersion: stringData(updatedMaxVersion) };
if (foundAppID == appID)
return outData;
}
catch (e) {
continue;
}
}
}
return null;
return outData;
},
/**
@ -6698,14 +6779,20 @@ ExtensionsDataSource.prototype = {
* datasource during an installation or upgrade.
* @param id
* The ID of the item to set updated target application info for
* @param targetAppID
* The target application ID used for checking compatibility for this item.
* @param updatedMinVersion
* The updated minimum version of the target application that this
* item can run in
* @param updatedMaxVersion
* The updated maximum version of the target application that this
* item can run in
*
* @note Add-ons can specify a targetApplication id of toolkit@mozilla.org in
* their install manifest for compatibility with all apps using a
* specific release of the toolkit.
*/
setUpdatedTargetAppInfo: function(id, updatedMinVersion, updatedMaxVersion) {
setUpdatedTargetAppInfo: function(id, targetAppID, updatedMinVersion, updatedMaxVersion) {
// The default theme is always compatible so it is never updated.
if (getResourceForID(id).EqualsNode(this._defaultTheme))
return;
@ -6733,7 +6820,8 @@ ExtensionsDataSource.prototype = {
var targetApp = targetApps.getNext();
if (targetApp instanceof Components.interfaces.nsIRDFResource) {
var foundAppID = stringData(this._inner.GetTarget(targetApp, EM_R("id"), true));
if (foundAppID != appID) // Different target application
// Different target application?
if (foundAppID != targetAppID)
continue;
this._inner.Assert(targetApp, updatedMinVersionRes, EM_L(updatedMinVersion), true);
this._inner.Assert(targetApp, updatedMaxVersionRes, EM_L(updatedMaxVersion), true);
@ -6751,6 +6839,8 @@ ExtensionsDataSource.prototype = {
* @param datasource
* The datasource to look up target application info in
* @returns A JS Object with the following properties:
* "appID" The target application ID used for checking
* compatibility for this item.
* "minVersion" The minimum version of the target application
* that this item can run in
* "maxVersion" The maximum version of the target application
@ -6759,41 +6849,51 @@ ExtensionsDataSource.prototype = {
* id in the supplied datasource.
*/
getTargetApplicationInfo: function(id, datasource) {
var appID = gApp.ID;
// The default theme is always compatible.
if (getResourceForID(id).EqualsNode(this._defaultTheme)) {
var ver = gApp.version;
return { minVersion: ver, maxVersion: ver };
return { appID: appID, minVersion: ver, maxVersion: ver };
}
var appID = gApp.ID;
var r = getResourceForID(id);
var targetApps = datasource.GetTargets(r, EM_R("targetApplication"), true);
if (!targetApps)
return null;
if (!targetApps.hasMoreElements())
targetApps = datasource.GetTargets(gInstallManifestRoot, EM_R("targetApplication"), true);
var outData = null;
while (targetApps.hasMoreElements()) {
var targetApp = targetApps.getNext();
if (targetApp instanceof Components.interfaces.nsIRDFResource) {
try {
var foundAppID = stringData(datasource.GetTarget(targetApp, EM_R("id"), true));
if (foundAppID != appID) // Different target application
// Different target application?
if (foundAppID != appID && foundAppID != TOOLKIT_ID)
continue;
return { minVersion: stringData(datasource.GetTarget(targetApp, EM_R("minVersion"), true)),
maxVersion: stringData(datasource.GetTarget(targetApp, EM_R("maxVersion"), true)) };
outData = { appID: foundAppID,
minVersion: stringData(datasource.GetTarget(targetApp, EM_R("minVersion"), true)),
maxVersion: stringData(datasource.GetTarget(targetApp, EM_R("maxVersion"), true)) };
if (foundAppID == appID)
return outData;
}
catch (e) {
continue;
}
}
}
return null;
return outData;
},
/**
* Sets the target application info for an item in a datasource.
* @param id
* The GUID of the item to discover target application info for
* @param targetAppID
* The target application ID used for checking compatibility for this
* item.
* @param minVersion
* The minimum version of the target application that this item can
* run in
@ -6802,8 +6902,12 @@ ExtensionsDataSource.prototype = {
* run in
* @param datasource
* The datasource to loko up target application info in
*
* @note Add-ons can specify a targetApplication id of toolkit@mozilla.org in
* their install manifest for compatibility with all apps using a
* specific release of the toolkit.
*/
setTargetApplicationInfo: function(id, minVersion, maxVersion, datasource) {
setTargetApplicationInfo: function(id, targetAppID, minVersion, maxVersion, datasource) {
var targetDataSource = datasource;
if (!targetDataSource)
targetDataSource = this._inner;
@ -6817,7 +6921,8 @@ ExtensionsDataSource.prototype = {
var targetApp = targetApps.getNext();
if (targetApp instanceof Components.interfaces.nsIRDFResource) {
var foundAppID = stringData(targetDataSource.GetTarget(targetApp, EM_R("id"), true));
if (foundAppID != appID) // Different target application
// Different target application?
if (foundAppID != targetAppID)
continue;
this._setProperty(targetDataSource, targetApp, EM_R("minVersion"), EM_L(minVersion));
@ -7458,6 +7563,9 @@ ExtensionsDataSource.prototype = {
* See nsIExtensionManager.idl
*/
onAddonUpdateStarted: function(addon) {
if (!addon)
throw Components.results.NS_ERROR_INVALID_ARG;
LOG("Datasource: Addon Update Started: " + addon.id);
this.updateProperty(addon.id, "availableUpdateURL");
},
@ -7466,6 +7574,9 @@ ExtensionsDataSource.prototype = {
* See nsIExtensionManager.idl
*/
onAddonUpdateEnded: function(addon, status) {
if (!addon)
throw Components.results.NS_ERROR_INVALID_ARG;
LOG("Datasource: Addon Update Ended: " + addon.id + ", status: " + status);
var url = null, hash = null, version = null;
var updateAvailable = status == nsIAddonUpdateCheckListener.STATUS_UPDATE;
@ -7600,7 +7711,7 @@ ExtensionsDataSource.prototype = {
}
getVersionChecker();
var appVersion = gApp.version;
var appVersion = targetAppInfo.appID == TOOLKIT_ID ? gApp.platformVersion : gApp.version;
if (gVersionChecker.compare(targetAppInfo.maxVersion, appVersion) < 0 ||
gVersionChecker.compare(appVersion, targetAppInfo.minVersion) < 0) {
// OK, this item is incompatible.
@ -8064,7 +8175,8 @@ UpdateItem.prototype = {
* See nsIUpdateService.idl
*/
init: function(id, version, installLocationKey, minAppVersion, maxAppVersion,
name, downloadURL, xpiHash, iconURL, updateURL, type) {
name, downloadURL, xpiHash, iconURL, updateURL, type,
targetAppID) {
this._id = id;
this._version = version;
this._installLocationKey = installLocationKey;
@ -8076,6 +8188,7 @@ UpdateItem.prototype = {
this._iconURL = iconURL;
this._updateURL = updateURL;
this._type = type;
this._targetAppID = targetAppID;
},
/**
@ -8092,6 +8205,7 @@ UpdateItem.prototype = {
get iconURL() { return this._iconURL },
get updateRDF() { return this._updateURL; },
get type() { return this._type; },
get targetAppID() { return this._targetAppID; },
/**
* See nsIUpdateService.idl
@ -8107,7 +8221,8 @@ UpdateItem.prototype = {
xpiHash : this._xpiHash,
iconURL : this._iconURL,
updateRDF : this._updateURL,
type : this._type
type : this._type,
targetAppID : this._targetAppID
}.toSource();
},

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

@ -0,0 +1,30 @@
<?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>bug299716-2@tests.mozilla.org</em:id>
<em:version>0.1</em:version>
<!-- XPCShell -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Toolkit -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716</em:name>
<em:updateURL>http://localhost:4444/data/test_bug299716_2.rdf</em:updateURL>
</Description>
</RDF>

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

@ -0,0 +1,21 @@
<?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>bug299716-a@tests.mozilla.org</em:id>
<em:version>0.1</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>5</em:minVersion>
<em:maxVersion>5</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test A</em:name>
<em:updateURL>http://localhost:4444/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -0,0 +1,21 @@
<?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>bug299716-a@tests.mozilla.org</em:id>
<em:version>0.2</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>5</em:minVersion>
<em:maxVersion>5</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test A</em:name>
<em:updateURL>http://localhost:4444/data/test_bug299716.rdf</em:updateURL>
</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>bug299716-b@tests.mozilla.org</em:id>
<em:version>0.1</em:version>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test B</em:name>
<em:updateURL>http://localhost:4444/data/test_bug299716.rdf</em:updateURL>
</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>bug299716-b@tests.mozilla.org</em:id>
<em:version>0.2</em:version>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test B</em:name>
<em:updateURL>http://localhost:4444/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -0,0 +1,30 @@
<?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>bug299716-c@tests.mozilla.org</em:id>
<em:version>0.1</em:version>
<!-- XPCShell -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>5</em:minVersion>
<em:maxVersion>5</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Toolkit -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test C</em:name>
<em:updateURL>http://localhost:4444/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -0,0 +1,30 @@
<?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>bug299716-c@tests.mozilla.org</em:id>
<em:version>0.2</em:version>
<!-- XPCShell -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>5</em:minVersion>
<em:maxVersion>5</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Toolkit -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test C</em:name>
<em:updateURL>http://localhost:4444/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -0,0 +1,30 @@
<?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>bug299716-d@tests.mozilla.org</em:id>
<em:version>0.1</em:version>
<!-- XPCShell -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>5</em:minVersion>
<em:maxVersion>5</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Toolkit, invalid -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test D</em:name>
<em:updateURL>http://localhost:4444/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -0,0 +1,30 @@
<?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>bug299716-d@tests.mozilla.org</em:id>
<em:version>0.2</em:version>
<!-- XPCShell -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>5</em:minVersion>
<em:maxVersion>5</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Toolkit, invalid -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test D</em:name>
<em:updateURL>http://localhost:4444/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -0,0 +1,30 @@
<?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>bug299716-e@tests.mozilla.org</em:id>
<em:version>0.1</em:version>
<!-- Toolkit -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
</Description>
</em:targetApplication>
<!-- XPCShell, invalid -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test E</em:name>
<em:updateURL>http://localhost:4444/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -0,0 +1,30 @@
<?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>bug299716-e@tests.mozilla.org</em:id>
<em:version>0.2</em:version>
<!-- Toolkit -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
</Description>
</em:targetApplication>
<!-- XPCShell, invalid -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test E</em:name>
<em:updateURL>http://localhost:4444/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -0,0 +1,30 @@
<?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>bug299716-f@tests.mozilla.org</em:id>
<em:version>0.1</em:version>
<!-- Toolkit, invalid -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<!-- XPCShell, invalid -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test F</em:name>
<em:updateURL>http://localhost:4444/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -0,0 +1,30 @@
<?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>bug299716-f@tests.mozilla.org</em:id>
<em:version>0.2</em:version>
<!-- Toolkit, invalid -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<!-- XPCShell, invalid -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test F</em:name>
<em:updateURL>http://localhost:4444/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -0,0 +1,21 @@
<?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>bug299716-g@tests.mozilla.org</em:id>
<em:version>0.1</em:version>
<!-- Toolkit, invalid -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test G</em:name>
<em:updateURL>http://localhost:4444/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -0,0 +1,21 @@
<?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>bug299716-g@tests.mozilla.org</em:id>
<em:version>0.2</em:version>
<!-- Toolkit, invalid -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test G</em:name>
<em:updateURL>http://localhost:4444/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE RDF:RDF [
<!ENTITY bug299716 "urn:mozilla:extension:bug299716">
<!ENTITY addons_prefix "http://localhost:4444/addons/test_bug299716">
<!ENTITY v0.2 "<em:version>0.2</em:version>">
<!ENTITY xpcshell.app "
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>5</em:minVersion>
<em:maxVersion>5</em:maxVersion>
">
<!ENTITY toolkit.app "
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
">
<!ENTITY invalidRange "
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
">
<!ENTITY xpcshell.invalid "
<em:id>xpcshell@tests.mozilla.org</em:id>
&invalidRange;
">
<!ENTITY toolkit.invalid "
<em:id>toolkit@mozilla.org</em:id>
&invalidRange;
">
]>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<!-- XPCShell -->
<RDF:Description about="&bug299716;-a@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li RDF:resource="&bug299716;-a@tests.mozilla.org:0.2"/>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="&bug299716;-a@tests.mozilla.org:0.2">
&v0.2;
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_a_2.xpi">
&xpcshell.app;
</RDF:Description>
</em:targetApplication>
</RDF:Description>
<!-- Toolkit -->
<RDF:Description about="&bug299716;-b@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li RDF:resource="&bug299716;-b@tests.mozilla.org:0.2"/>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="&bug299716;-b@tests.mozilla.org:0.2">
&v0.2;
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_b_2.xpi">
&toolkit.app;
</RDF:Description>
</em:targetApplication>
</RDF:Description>
<!-- XPCShell + Toolkit -->
<RDF:Description about="&bug299716;-c@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li RDF:resource="&bug299716;-c@tests.mozilla.org:0.2"/>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="&bug299716;-c@tests.mozilla.org:0.2">
&v0.2;
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_c_2.xpi">
&xpcshell.app;
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_c_2.xpi">
&toolkit.app;
</RDF:Description>
</em:targetApplication>
</RDF:Description>
<!-- XPCShell (Toolkit invalid) -->
<RDF:Description about="&bug299716;-d@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li RDF:resource="&bug299716;-d@tests.mozilla.org:0.2"/>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="&bug299716;-d@tests.mozilla.org:0.2">
&v0.2;
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_d_2.xpi">
&xpcshell.app;
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_d_2.xpi">
&toolkit.invalid;
</RDF:Description>
</em:targetApplication>
</RDF:Description>
<!-- Toolkit (XPCShell invalid), should not install -->
<RDF:Description about="&bug299716;-e@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li RDF:resource="&bug299716;-e@tests.mozilla.org:0.2"/>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="&bug299716;-e@tests.mozilla.org:0.2">
&v0.2;
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_e_2.xpi">
&xpcshell.invalid;
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_e_2.xpi">
&toolkit.app;
</RDF:Description>
</em:targetApplication>
</RDF:Description>
<!-- None (XPCShell, Toolkit invalid), should not install -->
<RDF:Description about="&bug299716;-f@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li RDF:resource="&bug299716;-f@tests.mozilla.org:0.2"/>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="&bug299716;-f@tests.mozilla.org:0.2">
&v0.2;
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_f_2.xpi">
&xpcshell.invalid;
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_f_2.xpi">
&toolkit.invalid;
</RDF:Description>
</em:targetApplication>
</RDF:Description>
<!-- Toolkit (invalid), should not install -->
<RDF:Description about="&bug299716;-g@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li RDF:resource="&bug299716;-g@tests.mozilla.org:0.2"/>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="&bug299716;-g@tests.mozilla.org:0.2">
&v0.2;
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_g_2.xpi">
&toolkit.invalid;
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:RDF>

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

@ -0,0 +1,23 @@
<?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:bug299716-2@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>0.1</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>2.0.*</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
</RDF:RDF>

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

@ -0,0 +1,449 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Alexander J. Vincent <ajvincent@gmail.com>.
*
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL
*
* ***** END LICENSE BLOCK *****
*/
/* XXX ajvincent XPCOM_DEBUG_BREAK automatically causes a xpcshell test to crash
if a NS_ASSERTION fires. However, the assertions this testcase triggers are
unrelated to the actual test, and the component this test runs against is
JavaScript-based - so assertions here do not apply against the tested
component. I am (reluctantly) turning the assertions into stack warnings in
order to prevent test failures at this point which are not the fault of the
code being tested or the test script.
At present, the assertions fired are for calls which aren't thread-safe.
*/
var env = Components.classes["@mozilla.org/process/environment;1"]
.getService(Components.interfaces.nsIEnvironment);
env.set("XPCOM_DEBUG_BREAK", "stack");
// This allows the EM to attempt to display errors to the user without failing.
var promptService = {
// nsIPromptService
alert: function alert(aParent,
aDialogTitle,
aText) {
const title = "Bug 299716 test ";
var keyChar = aText.charAt(title.length).toLowerCase();
var id = "bug299716-" + keyChar + "@tests.mozilla.org";
for (var i = 0; i < ADDONS.length; i++) {
if (ADDONS[i].id != id) {
continue;
}
do_check_false(ADDONS[i].installed);
break;
}
},
// nsIPromptService
alertCheck: function alertCheck(aParent,
aDialogTitle,
aText,
aCheckMsg,
aCheckState) {
do_throw("Unexpected call to alertCheck!");
},
// nsIPromptService
confirm: function confirm(aParent,
aDialogTitle,
aText) {
do_throw("Unexpected call to confirm!");
},
// nsIPromptService
confirmCheck: function confirmCheck(aParent,
aDialogTitle,
aText,
aCheckMsg,
aCheckState) {
do_throw("Unexpected call to confirmCheck!");
},
// nsIPromptService
confirmEx: function confirmEx(aParent,
aDialogTitle,
aText,
aButtonFlags,
aButton0Title,
aButton1Title,
aButton2Title,
aCheckMsg,
aCheckState) {
do_throw("Unexpected call to confirmEx!");
},
// nsIPromptService
prompt: function prompt(aParent,
aDialogTitle,
aText,
aValue,
aCheckMsg,
aCheckState) {
do_throw("Unexpected call to prompt!");
},
// nsIPromptService
promptUsernameAndPassword:
function promptUsernameAndPassword(aParent,
aDialogTitle,
aText,
aUsername,
aPassword,
aCheckMsg,
aCheckState) {
do_throw("Unexpected call to promptUsernameAndPassword!");
},
// nsIPromptService
promptPassword: function promptPassword(aParent,
aDialogTitle,
aText,
aPassword,
aCheckMsg,
aCheckState) {
do_throw("Unexpected call to promptPassword!");
},
// nsIPromptService
select: function select(aParent,
aDialogTitle,
aText,
aCount,
aSelectList,
aOutSelection) {
do_throw("Unexpected call to select!");
},
// nsISupports
QueryInterface: function QueryInterface(iid) {
if (iid.equals(Components.interfaces.nsIPromptService)
|| iid.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
};
var PromptServiceFactory = {
createInstance: function createInstance(outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return promptService.QueryInterface(iid);
}
};
const nsIComponentRegistrar = Components.interfaces.nsIComponentRegistrar;
var registrar = Components.manager.QueryInterface(nsIComponentRegistrar);
const psID = Components.ID("{6cc9c9fe-bc0b-432b-a410-253ef8bcc699}");
registrar.registerFactory(psID,
"PromptService",
"@mozilla.org/embedcomp/prompt-service;1",
PromptServiceFactory);
const updateListener = {
_state: -1,
// nsIAddonUpdateListener
onStateChange: function onStateChange(aAddon, aState, aValue) {
if ((this._state == -1) &&
(aState == Components.interfaces.nsIXPIProgressDialog.DIALOG_CLOSE)) {
this._state = aState;
next_test();
}
},
onProgress: function onProgress(aAddon, aValue, aMaxValue) {
// do nothing.
}
};
// Update check listener.
const checkListener = {
// nsIAddonUpdateCheckListener
onUpdateStarted: function onUpdateStarted() {
// do nothing
},
// nsIAddonUpdateCheckListener
onUpdateEnded: function onUpdateEnded() {
next_test();
},
// nsIAddonUpdateCheckListener
onAddonUpdateStarted: function onAddonUpdateStarted(aAddon) {
// do nothing
},
// nsIAddonUpdateCheckListener
onAddonUpdateEnded: function onAddonUpdateEnded(aAddon, aStatus) {
for (var i = 0; i < ADDONS.length; i++) {
if (ADDONS[i].id == aAddon.id) {
ADDONS[i].newItem = aAddon;
return;
}
}
}
}
// Get the HTTP server.
do_import_script("netwerk/test/httpserver/httpd.js");
var testserver;
var updateItems = [];
// Configure test.
const DELAY = 2000;
var ADDONS = [
// XPCShell
{
id: "bug299716-a@tests.mozilla.org",
addon: "test_bug299716_a_1",
installed: true,
item: null,
newItem: null
},
// Toolkit
{
id: "bug299716-b@tests.mozilla.org",
addon: "test_bug299716_b_1",
installed: true,
item: null,
newItem: null
},
// XPCShell + Toolkit
{
id: "bug299716-c@tests.mozilla.org",
addon: "test_bug299716_c_1",
installed: true,
item: null,
newItem: null
},
// XPCShell (Toolkit invalid)
{
id: "bug299716-d@tests.mozilla.org",
addon: "test_bug299716_d_1",
installed: true,
item: null,
newItem: null
},
// Toolkit (XPCShell invalid)
{
id: "bug299716-e@tests.mozilla.org",
addon: "test_bug299716_e_1",
installed: false,
item: null,
newItem: null,
failedAppName: "XPCShell"
},
// None (XPCShell, Toolkit invalid)
{
id: "bug299716-f@tests.mozilla.org",
addon: "test_bug299716_f_1",
installed: false,
item: null,
newItem: null,
failedAppName: "XPCShell"
},
// None (Toolkit invalid)
{
id: "bug299716-g@tests.mozilla.org",
addon: "test_bug299716_g_1",
installed: false,
item: null,
newItem: null,
failedAppName: "Toolkit"
},
];
var currentAddonObj = null;
var next_test = function() {};
function do_check_item(aItem, aVersion, aAddonsEntry) {
if (aAddonsEntry.installed) {
do_check_eq(aItem.version, aVersion);
} else {
do_check_eq(aItem, null);
}
}
/**
* Start the test by installing extensions.
*/
function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "5", "1.9");
const dataDir = do_get_file("toolkit/mozapps/extensions/test/unit/data");
const addonsDir = do_get_addon(ADDONS[0].addon).parent;
// Make sure we can actually get our data files.
const xpiFile = addonsDir.clone();
xpiFile.append("test_bug299716_a_2.xpi");
do_check_true(xpiFile.exists());
// Create and configure the HTTP server.
testserver = new nsHttpServer();
testserver.registerDirectory("/addons/", addonsDir);
testserver.registerDirectory("/data/", dataDir);
testserver.start(4444);
// Make sure we can fetch the files over HTTP.
const Ci = Components.interfaces;
const xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance(Ci.nsIXMLHttpRequest)
xhr.open("GET", "http://localhost:4444/addons/test_bug299716_a_2.xpi", false);
xhr.send(null);
do_check_true(xhr.status == 200);
xhr.open("GET", "http://localhost:4444/data/test_bug299716.rdf", false);
xhr.send(null);
do_check_true(xhr.status == 200);
// Start the real test.
startupEM();
dump("\n\n*** INSTALLING NEW ITEMS\n\n");
gEM.addUpdateListener(updateListener);
for (var i = 0; i < ADDONS.length; i++) {
gEM.installItemFromFile(do_get_addon(ADDONS[i].addon),
NS_INSTALL_LOCATION_APPPROFILE);
}
do_test_pending();
// Give time for phone home to complete.
do_timeout(DELAY, "run_test_pt2()");
}
/**
* Check the versions of all items, and ask the extension manager to find updates.
*/
function run_test_pt2() {
dump("\n\n*** RESTARTING EXTENSION MANAGER\n\n");
restartEM();
// Try to update the items.
for (var i = 0; i < ADDONS.length; i++) {
var item = gEM.getItemForID(ADDONS[i].id);
do_check_item(item, "0.1", ADDONS[i]);
ADDONS[i].item = item;
updateItems[updateItems.length] = item;
}
dump("\n\n*** REQUESTING UPDATE\n\n");
// updateListener will call run_test_pt3().
next_test = run_test_pt3;
try {
gEM.update(updateItems,
updateItems.length,
Components.interfaces.nsIExtensionManager.UPDATE_CHECK_NEWVERSION,
checkListener);
do_throw("Shouldn't reach here!");
} catch (e if (e instanceof Components.interfaces.nsIException &&
e.result == Components.results.NS_ERROR_ILLEGAL_VALUE)) {
// do nothing, this is good
}
var addonsArray = [];
for (var i = 0; i < ADDONS.length; i++) {
if (ADDONS[i].item) {
addonsArray.push(ADDONS[i].item);
}
}
gEM.update(addonsArray,
addonsArray.length,
Components.interfaces.nsIExtensionManager.UPDATE_CHECK_NEWVERSION,
checkListener);
}
/**
* Install new items for each enabled extension.
*/
function run_test_pt3() {
// Install the new items.
var addonsArray = [];
for (var i = 0; i < ADDONS.length; i++) {
addonsArray.push(ADDONS[i].newItem);
}
dump("\n\n*** UPDATING " + addonsArray.length + " ITEMS\n\n");
// updateListener will call run_test_pt4().
next_test = run_test_pt4;
// Here, we have some bad items that try to update. Pepto-Bismol time.
try {
gEM.addDownloads(addonsArray, addonsArray.length, true);
do_throw("Shouldn't reach here!");
} catch (e if (e instanceof Components.interfaces.nsIException &&
e.result == Components.results.NS_ERROR_ILLEGAL_VALUE)) {
// do nothing, this is good
}
for (i = addonsArray.length - 1; i >= 0; i--) {
if (!addonsArray[i]) {
addonsArray.splice(i, 1);
}
}
do_check_true(addonsArray.length > 0);
gEM.addDownloads(addonsArray, addonsArray.length, true);
}
/**
* Check the final version of each extension.
*/
function run_test_pt4() {
dump("\n\n*** RESTARTING EXTENSION MANAGER\n\n");
restartEM();
dump("\n\n*** FINAL CHECKS\n\n");
for (var i = 0; i < ADDONS.length; i++) {
var item = gEM.getItemForID(ADDONS[i].id);
do_check_item(item, "0.2", ADDONS[i]);
}
do_test_finished();
testserver.stop();
// If we've gotten this far, then the test has passed.
env.set("XPCOM_DEBUG_BREAK", "abort");
}

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

@ -0,0 +1,106 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Dave Townsend <dtownsend@mozilla.com>.
*
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL
*
* ***** END LICENSE BLOCK *****
*/
// Update check listener.
const checkListener = {
// nsIAddonUpdateCheckListener
onUpdateStarted: function onUpdateStarted() {
},
// nsIAddonUpdateCheckListener
onUpdateEnded: function onUpdateEnded() {
var item = gEM.getItemForID(ADDON.id);
do_check_eq(item.version, 0.1);
do_check_eq(item.targetAppID, "xpcshell@tests.mozilla.org");
do_check_eq(item.minAppVersion, 1);
do_check_eq(item.maxAppVersion, 1);
do_test_finished();
testserver.stop();
},
// nsIAddonUpdateCheckListener
onAddonUpdateStarted: function onAddonUpdateStarted(aAddon) {
},
// nsIAddonUpdateCheckListener
onAddonUpdateEnded: function onAddonUpdateEnded(aAddon, aStatus) {
}
}
// Get the HTTP server.
do_import_script("netwerk/test/httpserver/httpd.js");
var testserver;
var ADDON = {
id: "bug299716-2@tests.mozilla.org",
addon: "test_bug299716_2"
};
function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
const dataDir = do_get_file("toolkit/mozapps/extensions/test/unit/data");
const addonsDir = do_get_addon(ADDON.addon).parent;
// Create and configure the HTTP server.
testserver = new nsHttpServer();
testserver.registerDirectory("/addons/", addonsDir);
testserver.registerDirectory("/data/", dataDir);
testserver.start(4444);
startupEM();
// Should just install.
gEM.installItemFromFile(do_get_addon(ADDON.addon),
NS_INSTALL_LOCATION_APPPROFILE);
restartEM();
var item = gEM.getItemForID(ADDON.id);
do_check_eq(item.version, 0.1);
do_check_eq(item.targetAppID, "xpcshell@tests.mozilla.org");
do_check_eq(item.minAppVersion, 1);
do_check_eq(item.maxAppVersion, 1);
do_test_pending();
gEM.update([item], 1,
Components.interfaces.nsIExtensionManager.UPDATE_SYNC_COMPATIBILITY,
checkListener);
}

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

@ -51,7 +51,7 @@ var observer = {
function initTest()
{
// Setup extension manager
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1");
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
startupEM();
// Register our parameter handlers
@ -80,7 +80,7 @@ function run_test()
var item = Cc["@mozilla.org/updates/item;1"].createInstance(Ci.nsIUpdateItem);
item.init("test@mozilla.org", "1.0", "app-profile", "0.0", "100.0", "Test extension",
null, null, "", null, item.TYPE_EXTENSION);
null, null, "", null, item.TYPE_EXTENSION, "xpcshell@tests.mozilla.org");
gExpectedURL = gTestURL.replace(/%ITEM_ID%/, item.id)
.replace(/%CUSTOM1%/, "custom_parameter_1")

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

@ -708,6 +708,7 @@ var gUpdatesAvailablePage = {
var em = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(Components.interfaces.nsIExtensionManager);
var items = em.getIncompatibleItemList("", gUpdates.update.version,
gUpdates.update.platformVersion,
nsIUpdateItem.TYPE_ADDON, false,
{ });
if (items.length > 0) {

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

@ -114,7 +114,7 @@ interface nsIUpdatePatch : nsISupports
* that the front end and other application services can use to learn more
* about what is going on.
*/
[scriptable, uuid(8e5822a6-c5d4-4537-be0a-9c95ba13ea2f)]
[scriptable, uuid(9d6a388b-2e0c-4d0e-9a60-5c9739a7ada5)]
interface nsIUpdate : nsISupports
{
/**
@ -134,6 +134,11 @@ interface nsIUpdate : nsISupports
*/
attribute AString version;
/**
* The Toolkit version of this update.
*/
attribute AString platformVersion;
/**
* The Addon version of this update. Used by the Extension System to track
* compatibility of installed addons with this update.

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

@ -24,6 +24,7 @@
* Darin Fisher <darin@meer.net>
* Ben Turner <bent.mozilla@gmail.com>
* Jeff Walden <jwalden+code@mit.edu>
* Alexander J. Vincent <ajvincent@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -103,6 +104,8 @@ const DOWNLOAD_CHUNK_SIZE = 300000; // bytes
const DOWNLOAD_BACKGROUND_INTERVAL = 600; // seconds
const DOWNLOAD_FOREGROUND_INTERVAL = 0;
const TOOLKIT_ID = "toolkit@mozilla.org";
const POST_UPDATE_CONTRACTID = "@mozilla.org/updates/post-update;1";
const nsIExtensionManager = Components.interfaces.nsIExtensionManager;
@ -898,6 +901,7 @@ Update.prototype = {
update.setAttribute("type", this.type);
update.setAttribute("name", this.name);
update.setAttribute("version", this.version);
update.setAttribute("platformVersion", this.platformVersion);
update.setAttribute("extensionVersion", this.extensionVersion);
update.setAttribute("detailsURL", this.detailsURL);
update.setAttribute("licenseURL", this.licenseURL);
@ -1887,6 +1891,7 @@ Checker.prototype = {
url = url.replace(/%OS_VERSION%/g, gOSVersion);
url = url.replace(/%LOCALE%/g, getLocale());
url = url.replace(/%CHANNEL%/g, getUpdateChannel());
url = url.replace(/%PLATFORM_VERSION%/g, gApp.platformVersion);
url = url.replace(/\+/g, "%2B");
if (force)
@ -2942,7 +2947,7 @@ function isCompatible(update) {
Components.classes["@mozilla.org/extensions/manager;1"].
getService(nsIExtensionManager);
var items = em.getIncompatibleItemList("", update.extensionVersion,
nsIUpdateItem.TYPE_ADDON, false, { });
update.platformVersion, nsIUpdateItem.TYPE_ADDON, false, { });
return items.length == 0;
#else
return true;
@ -2980,7 +2985,7 @@ function showPromptIfNoIncompatibilities(update) {
Components.classes["@mozilla.org/xpcom/version-comparator;1"].
getService(Components.interfaces.nsIVersionComparator);
return (vc.compare(version, addon.minAppVersion) >= 0) &&
(vc.compare(version, addon.maxAppVersion) <= 0);
(vc.compare(version, addon.maxAppVersion) <= 0);
}
/**
@ -3033,13 +3038,20 @@ function showPromptIfNoIncompatibilities(update) {
onAddonUpdateStarted: function(addon) {
},
onAddonUpdateEnded: function(addon, status) {
if (status == Components.interfaces.nsIAddonUpdateCheckListener.STATUS_UPDATE &&
addonIsCompatible(addon, update.extensionVersion)) {
for (var i = 0; i < this._addons.length; ++i) {
if (this._addons[i] == addon) {
this._addons.splice(i, 1);
break;
}
const Ci = Components.interfaces;
if (status != Ci.nsIAddonUpdateCheckListener.STATUS_UPDATE)
return;
var reqVersion = addon.targetAppID == TOOLKIT_ID ?
update.platformVersion :
update.extensionVersion;
if (!addonIsCompatible(addon, reqVersion))
return;
for (var i = 0; i < this._addons.length; ++i) {
if (this._addons[i] == addon) {
this._addons.splice(i, 1);
break;
}
}
},
@ -3058,8 +3070,9 @@ function showPromptIfNoIncompatibilities(update) {
var em =
Components.classes["@mozilla.org/extensions/manager;1"].
getService(nsIExtensionManager);
var listener = new Listener(em.getIncompatibleItemList("",
update.extensionVersion, nsIUpdateItem.TYPE_ADDON, false, { }));
var items = em.getIncompatibleItemList("", update.extensionVersion,
update.platformVersion, nsIUpdateItem.TYPE_ADDON, false, { });
var listener = new Listener(items);
// See documentation on |mode| above.
var mode = getPref("getIntPref", PREF_APP_UPDATE_INCOMPATIBLE_MODE,
nsIExtensionManager.UPDATE_CHECK_NEWVERSION);