Bug 555942: Style and attribute prefix fixes, no review

* * *
Fix argument renames for test_registry.js
This commit is contained in:
Dave Townsend 2010-04-28 09:42:07 -07:00
Родитель c3623f619f
Коммит a132e97c1f
14 изменённых файлов: 2244 добавлений и 2223 удалений

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

@ -57,45 +57,45 @@ const PROVIDERS = [
/**
* Logs a debugging message.
*
* @param str
* The string to log
* @param aStr
* The string to log
*/
function LOG(str) {
dump("*** addons.manager: " + str + "\n");
function LOG(aStr) {
dump("*** addons.manager: " + aStr + "\n");
}
/**
* Logs a warning message.
*
* @param str
* The string to log
* @param aStr
* The string to log
*/
function WARN(str) {
LOG(str);
function WARN(aStr) {
LOG(aStr);
}
/**
* Logs an error message.
*
* @param str
* The string to log
* @param aStr
* The string to log
*/
function ERROR(str) {
LOG(str);
function ERROR(aStr) {
LOG(aStr);
}
/**
* Calls a callback method consuming any thrown exception. Any parameters after
* the callback parameter will be passed to the callback.
*
* @param callback
* The callback method to call
* @param aCallback
* The callback method to call
*/
function safeCall(callback) {
function safeCall(aCallback) {
var args = Array.slice(arguments, 1);
try {
callback.apply(null, args);
aCallback.apply(null, args);
}
catch (e) {
WARN("Exception calling callback: " + e);
@ -106,28 +106,27 @@ function safeCall(callback) {
* Calls a method on a provider if it exists and consumes any thrown exception.
* Any parameters after the dflt parameter are passed to the provider's method.
*
* @param provider
* The provider to call
* @param method
* The method name to call
* @param dflt
* A default return value if the provider does not implement the named
* method or throws an error.
* @return the return value from the provider or dflt if the provider does not
* implement method or throws an error
* @param aProvider
* The provider to call
* @param aMethod
* The method name to call
* @param aDefault
* A default return value if the provider does not implement the named
* method or throws an error.
* @return the return value from the provider or dflt if the provider does not
* implement method or throws an error
*/
function callProvider(provider, method, dflt) {
if (!(method in provider))
return dflt;
function callProvider(aProvider, aMethod, aDefault) {
if (!(aMethod in aProvider))
return aDefault;
var args = Array.slice(arguments, 3);
try {
return provider[method].apply(provider, args);
}
catch (e) {
ERROR("Exception calling provider." + method + ": " + e);
return dflt;
return aProvider[aMethod].apply(aProvider, args);
} catch (e) {
ERROR("Exception calling provider." + aMethod + ": " + e);
return aDefault;
}
}
@ -135,21 +134,21 @@ function callProvider(provider, method, dflt) {
* A helper class to repeatedly call a listener with each object in an array
* optionally checking whether the object has a method in it.
*
* @param objects
* The array of objects to iterate through
* @param method
* An optional method name, if not null any objects without this method
* will not be passed to the listener
* @param listener
* A listener implementing nextObject and noMoreObjects methods. The
* former will be called with the AsyncObjectCaller as the first
* parameter and the object as the second. noMoreObjects will be passed
* just the AsyncObjectCaller
* @param aObjects
* The array of objects to iterate through
* @param aMethod
* An optional method name, if not null any objects without this method
* will not be passed to the listener
* @param aListener
* A listener implementing nextObject and noMoreObjects methods. The
* former will be called with the AsyncObjectCaller as the first
* parameter and the object as the second. noMoreObjects will be passed
* just the AsyncObjectCaller
*/
function AsyncObjectCaller(objects, method, listener) {
this.objects = objects.slice(0);
this.method = method;
this.listener = listener;
function AsyncObjectCaller(aObjects, aMethod, aListener) {
this.objects = aObjects.slice(0);
this.method = aMethod;
this.listener = aListener;
this.callNext();
}
@ -241,15 +240,15 @@ var AddonManagerInternal = {
/**
* Registers a new AddonProvider.
*
* @param provider
* The provider to register
* @param aProvider
* The provider to register
*/
registerProvider: function AMI_registerProvider(provider) {
this.providers.push(provider);
registerProvider: function AMI_registerProvider(aProvider) {
this.providers.push(aProvider);
// If we're registering after startup call this provider's startup.
if (this.started)
callProvider(provider, "startup");
callProvider(aProvider, "startup");
},
/**
@ -278,12 +277,12 @@ var AddonManagerInternal = {
Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", scope);
scope.LightweightThemeManager.updateCurrentTheme();
this.getAddonsByTypes(null, function getAddonsCallback(addons) {
addons.forEach(function BUC_forEachCallback(addon) {
if (addon.permissions & AddonManager.PERM_CAN_UPGRADE) {
addon.findUpdates({
onUpdateAvailable: function BUC_onUpdateAvailable(addon, install) {
install.install();
this.getAddonsByTypes(null, function getAddonsCallback(aAddons) {
aAddons.forEach(function BUC_forEachCallback(aAddon) {
if (aAddon.permissions & AddonManager.PERM_CAN_UPGRADE) {
aAddon.findUpdates({
onUpdateAvailable: function BUC_onUpdateAvailable(aAddon, aInstall) {
aInstall.install();
}
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
}
@ -295,28 +294,28 @@ var AddonManagerInternal = {
* Calls all registered InstallListeners with an event. Any parameters after
* the extraListeners parameter are passed to the listener.
*
* @param method
* The method on the listeners to call
* @param extraListeners
* An array of extra InstallListeners to also call
* @return false if any of the listeners returned false, true otherwise
* @param aMethod
* The method on the listeners to call
* @param aExtraListeners
* An array of extra InstallListeners to also call
* @return false if any of the listeners returned false, true otherwise
*/
callInstallListeners: function AMI_callInstallListeners(method, extraListeners) {
callInstallListeners: function AMI_callInstallListeners(aMethod, aExtraListeners) {
let result = true;
let listeners = this.installListeners;
if (extraListeners)
listeners = extraListeners.concat(listeners);
if (aExtraListeners)
listeners = aExtraListeners.concat(listeners);
let args = Array.slice(arguments, 2);
listeners.forEach(function(listener) {
try {
if (method in listener) {
if (listener[method].apply(listener, args) === false)
if (aMethod in listener) {
if (listener[aMethod].apply(listener, args) === false)
result = false;
}
}
catch (e) {
WARN("InstallListener threw exception when calling " + method + ": " + e);
WARN("InstallListener threw exception when calling " + aMethod + ": " + e);
}
});
return result;
@ -326,18 +325,18 @@ var AddonManagerInternal = {
* Calls all registered AddonListeners with an event. Any parameters after
* the method parameter are passed to the listener.
*
* @param method
* The method on the listeners to call
* @param aMethod
* The method on the listeners to call
*/
callAddonListeners: function AMI_callAddonListeners(method) {
callAddonListeners: function AMI_callAddonListeners(aMethod) {
var args = Array.slice(arguments, 1);
this.addonListeners.forEach(function(listener) {
try {
if (method in listener)
listener[method].apply(listener, args);
if (aMethod in listener)
listener[aMethod].apply(listener, args);
}
catch (e) {
WARN("AddonListener threw exception when calling " + method + ": " + e);
WARN("AddonListener threw exception when calling " + aMethod + ": " + e);
}
});
},
@ -347,88 +346,88 @@ var AddonManagerInternal = {
* add-on only supports a single add-on being enabled at a time. This allows
* the providers to disable theirs if necessary.
*
* @param id
* The id of the enabled add-on
* @param type
* The type of the enabled add-on
* @param pendingRestart
* A boolean indicating if the change will only take place the next
* time the application is restarted
* @param aId
* The id of the enabled add-on
* @param aType
* The type of the enabled add-on
* @param aPendingRestart
* A boolean indicating if the change will only take place the next
* time the application is restarted
*/
notifyAddonChanged: function AMI_notifyAddonChanged(id, type, pendingRestart) {
notifyAddonChanged: function AMI_notifyAddonChanged(aId, aType, aPendingRestart) {
this.providers.forEach(function(provider) {
callProvider(provider, "addonChanged", null, id, type, pendingRestart);
callProvider(provider, "addonChanged", null, aId, aType, aPendingRestart);
});
},
/**
* Asynchronously gets an AddonInstall for a URL.
*
* @param url
* The url the add-on is located at
* @param callback
* A callback to pass the AddonInstall to
* @param mimetype
* The mimetype of the add-on
* @param hash
* An optional hash of the add-on
* @param name
* An optional placeholder name while the add-on is being downloaded
* @param iconURL
* An optional placeholder icon URL while the add-on is being downloaded
* @param version
* An optional placeholder version while the add-on is being downloaded
* @param loadGroup
* An optional nsILoadGroup to associate any network requests with
* @throws if the url, callback or mimetype arguments are not specified
* @param aUrl
* The url the add-on is located at
* @param aCallback
* A callback to pass the AddonInstall to
* @param aMimetype
* The mimetype of the add-on
* @param aHash
* An optional hash of the add-on
* @param aName
* An optional placeholder name while the add-on is being downloaded
* @param aIconURL
* An optional placeholder icon URL while the add-on is being downloaded
* @param aVersion
* An optional placeholder version while the add-on is being downloaded
* @param aLoadGroup
* An optional nsILoadGroup to associate any network requests with
* @throws if the aUrl, aCallback or aMimetype arguments are not specified
*/
getInstallForURL: function AMI_getInstallForURL(url, callback, mimetype, hash,
name, iconURL, version,
loadGroup) {
if (!url || !mimetype || !callback)
getInstallForURL: function AMI_getInstallForURL(aUrl, aCallback, aMimetype,
aHash, aName, aIconURL,
aVersion, aLoadGroup) {
if (!aUrl || !aMimetype || !aCallback)
throw new TypeError("Invalid arguments");
for (let i = 0; i < this.providers.length; i++) {
if (callProvider(this.providers[i], "supportsMimetype", false, mimetype)) {
if (callProvider(this.providers[i], "supportsMimetype", false, aMimetype)) {
callProvider(this.providers[i], "getInstallForURL", null,
url, hash, name, iconURL, version, loadGroup,
function(install) {
safeCall(callback, install);
aUrl, aHash, aName, aIconURL, aVersion, aLoadGroup,
function(aInstall) {
safeCall(aCallback, aInstall);
});
return;
}
}
safeCall(callback, null);
safeCall(aCallback, null);
},
/**
* Asynchronously gets an AddonInstall for an nsIFile.
*
* @param file
* the nsIFile where the add-on is located
* @param callback
* A callback to pass the AddonInstall to
* @param mimetype
* An optional mimetype hint for the add-on
* @throws if the file or callback arguments are not specified
* @param aFile
* the nsIFile where the add-on is located
* @param aCallback
* A callback to pass the AddonInstall to
* @param aMimetype
* An optional mimetype hint for the add-on
* @throws if the aFile or aCallback arguments are not specified
*/
getInstallForFile: function AMI_getInstallForFile(file, callback, mimetype) {
if (!file || !callback)
getInstallForFile: function AMI_getInstallForFile(aFile, aCallback, aMimetype) {
if (!aFile || !aCallback)
throw Cr.NS_ERROR_INVALID_ARG;
new AsyncObjectCaller(this.providers, "getInstallForFile", {
nextObject: function(caller, provider) {
callProvider(provider, "getInstallForFile", null, file,
function(install) {
if (install)
safeCall(callback, install);
nextObject: function(aCaller, aProvider) {
callProvider(aProvider, "getInstallForFile", null, aFile,
function(aInstall) {
if (aInstall)
safeCall(aCallback, aInstall);
else
caller.callNext();
aCaller.callNext();
});
},
noMoreObjects: function(caller) {
safeCall(callback, null);
noMoreObjects: function(aCaller) {
safeCall(aCallback, null);
}
});
},
@ -437,29 +436,29 @@ var AddonManagerInternal = {
* Asynchronously gets all current AddonInstalls optionally limiting to a list
* of types.
*
* @param types
* An optional array of types to retrieve. Each type is a string name
* @param callback
* A callback which will be passed an array of AddonInstalls
* @throws if the callback argument is not specified
* @param aTypes
* An optional array of types to retrieve. Each type is a string name
* @param aCallback
* A callback which will be passed an array of AddonInstalls
* @throws if the aCallback argument is not specified
*/
getInstalls: function AMI_getInstalls(types, callback) {
if (!callback)
getInstalls: function AMI_getInstalls(aTypes, aCallback) {
if (!aCallback)
throw Cr.NS_ERROR_INVALID_ARG;
let installs = [];
new AsyncObjectCaller(this.providers, "getInstalls", {
nextObject: function(caller, provider) {
callProvider(provider, "getInstalls", null, types,
function(providerInstalls) {
installs = installs.concat(providerInstalls);
caller.callNext();
nextObject: function(aCaller, aProvider) {
callProvider(aProvider, "getInstalls", null, aTypes,
function(aProviderInstalls) {
installs = installs.concat(aProviderInstalls);
aCaller.callNext();
});
},
noMoreObjects: function(caller) {
safeCall(callback, installs);
noMoreObjects: function(aCaller) {
safeCall(aCallback, installs);
}
});
},
@ -467,13 +466,13 @@ var AddonManagerInternal = {
/**
* Checks whether installation is enabled for a particular mimetype.
*
* @param mimetype
* The mimetype to check
* @return true if installation is enabled for the mimetype
* @param aMimetype
* The mimetype to check
* @return true if installation is enabled for the mimetype
*/
isInstallEnabled: function AMI_isInstallEnabled(mimetype) {
isInstallEnabled: function AMI_isInstallEnabled(aMimetype) {
for (let i = 0; i < this.providers.length; i++) {
if (callProvider(this.providers[i], "supportsMimetype", false, mimetype) &&
if (callProvider(this.providers[i], "supportsMimetype", false, aMimetype) &&
callProvider(this.providers[i], "isInstallEnabled"))
return true;
}
@ -484,16 +483,16 @@ var AddonManagerInternal = {
* Checks whether a particular source is allowed to install add-ons of a
* given mimetype.
*
* @param mimetype
* The mimetype of the add-on
* @param uri
* The uri of the source, may be null
* @return true if the source is allowed to install this mimetype
* @param aMimetype
* The mimetype of the add-on
* @param aURI
* The uri of the source, may be null
* @return true if the source is allowed to install this mimetype
*/
isInstallAllowed: function AMI_isInstallAllowed(mimetype, uri) {
isInstallAllowed: function AMI_isInstallAllowed(aMimetype, aURI) {
for (let i = 0; i < this.providers.length; i++) {
if (callProvider(this.providers[i], "supportsMimetype", false, mimetype) &&
callProvider(this.providers[i], "isInstallAllowed", null, uri))
if (callProvider(this.providers[i], "supportsMimetype", false, aMimetype) &&
callProvider(this.providers[i], "isInstallAllowed", null, aURI))
return true;
}
},
@ -502,23 +501,23 @@ var AddonManagerInternal = {
* Starts installation of an array of AddonInstalls notifying the registered
* web install listener of blocked or started installs.
*
* @param mimetype
* The mimetype of add-ons being installed
* @param source
* The nsIDOMWindowInternal that started the installs
* @param uri
* the nsIURI that started the installs
* @param installs
* The array of AddonInstalls to be installed
* @param aMimetype
* The mimetype of add-ons being installed
* @param aSource
* The nsIDOMWindowInternal that started the installs
* @param aURI
* the nsIURI that started the installs
* @param aInstalls
* The array of AddonInstalls to be installed
*/
installAddonsFromWebpage: function AMI_installAddonsFromWebpage(mimetype,
source,
uri,
installs) {
installAddonsFromWebpage: function AMI_installAddonsFromWebpage(aMimetype,
aSource,
aURI,
aInstalls) {
if (!("@mozilla.org/addons/web-install-listener;1" in Cc)) {
WARN("No web installer available, cancelling all installs");
installs.forEach(function(install) {
install.cancel();
aInstalls.forEach(function(aInstall) {
aInstall.cancel();
});
return;
}
@ -527,18 +526,18 @@ var AddonManagerInternal = {
let weblistener = Cc["@mozilla.org/addons/web-install-listener;1"].
getService(Ci.amIWebInstallListener);
if (!this.isInstallAllowed(mimetype, uri)) {
if (weblistener.onWebInstallBlocked(source, uri, installs,
installs.length)) {
installs.forEach(function(install) {
install.install();
if (!this.isInstallAllowed(aMimetype, aURI)) {
if (weblistener.onWebInstallBlocked(aSource, aURI, aInstalls,
aInstalls.length)) {
aInstalls.forEach(function(aInstall) {
aInstall.install();
});
}
}
else if (weblistener.onWebInstallRequested(source, uri, installs,
installs.length)) {
installs.forEach(function(install) {
install.install();
else if (weblistener.onWebInstallRequested(aSource, aURI, aInstalls,
aInstalls.length)) {
aInstalls.forEach(function(aInstall) {
aInstall.install();
});
}
}
@ -547,8 +546,8 @@ var AddonManagerInternal = {
// calling onWebInstallBlocked or onWebInstallRequested all of the
// installs should get cancelled.
WARN("Failure calling web installer: " + e);
installs.forEach(function(install) {
install.cancel();
aInstalls.forEach(function(aInstall) {
aInstall.cancel();
});
}
},
@ -556,51 +555,51 @@ var AddonManagerInternal = {
/**
* Adds a new InstallListener if the listener is not already registered.
*
* @param listener
* The InstallListener to add
* @param aListener
* The InstallListener to add
*/
addInstallListener: function AMI_addInstallListener(listener) {
if (!this.installListeners.some(function(i) { return i == listener; }))
this.installListeners.push(listener);
addInstallListener: function AMI_addInstallListener(aListener) {
if (!this.installListeners.some(function(i) { return i == aListener; }))
this.installListeners.push(aListener);
},
/**
* Removes an InstallListener if the listener is registered.
*
* @param listener
* The InstallListener to remove
* @param aListener
* The InstallListener to remove
*/
removeInstallListener: function AMI_removeInstallListener(listener) {
removeInstallListener: function AMI_removeInstallListener(aListener) {
this.installListeners = this.installListeners.filter(function(i) {
return i != listener;
return i != aListener;
});
},
/**
* Asynchronously gets an add-on with a specific ID.
*
* @param id
* The ID of the add-on to retrieve
* @param callback
* The callback to pass the retrieved add-on to
* @throws if the id or callback arguments are not specified
* @param aId
* The ID of the add-on to retrieve
* @param aCallback
* The callback to pass the retrieved add-on to
* @throws if the aId or aCallback arguments are not specified
*/
getAddon: function AMI_getAddon(id, callback) {
if (!id || !callback)
getAddon: function AMI_getAddon(aId, aCallback) {
if (!aId || !aCallback)
throw Cr.NS_ERROR_INVALID_ARG;
new AsyncObjectCaller(this.providers, "getAddon", {
nextObject: function(caller, provider) {
callProvider(provider, "getAddon", null, id, function(addon) {
if (addon)
safeCall(callback, addon);
nextObject: function(aCaller, aProvider) {
callProvider(aProvider, "getAddon", null, aId, function(aAddon) {
if (aAddon)
safeCall(aCallback, aAddon);
else
caller.callNext();
aCaller.callNext();
});
},
noMoreObjects: function(caller) {
safeCall(callback, null);
noMoreObjects: function(aCaller) {
safeCall(aCallback, null);
}
});
},
@ -608,28 +607,28 @@ var AddonManagerInternal = {
/**
* Asynchronously gets an array of add-ons.
*
* @param ids
* The array of IDs to retrieve
* @param callback
* The callback to pass an array of Addons to
* @throws if the id or callback arguments are not specified
* @param aIds
* The array of IDs to retrieve
* @param aCallback
* The callback to pass an array of Addons to
* @throws if the aId or aCallback arguments are not specified
*/
getAddons: function AMI_getAddons(ids, callback) {
if (!ids || !callback)
getAddons: function AMI_getAddons(aIds, aCallback) {
if (!aIds || !aCallback)
throw Cr.NS_ERROR_INVALID_ARG;
let addons = [];
new AsyncObjectCaller(ids, null, {
nextObject: function(caller, id) {
AddonManagerInternal.getAddon(id, function(addon) {
addons.push(addon);
caller.callNext();
new AsyncObjectCaller(aIds, null, {
nextObject: function(aCaller, aId) {
AddonManagerInternal.getAddon(aId, function(aAddon) {
addons.push(aAddon);
aCaller.callNext();
});
},
noMoreObjects: function(caller) {
safeCall(callback, addons);
noMoreObjects: function(aCaller) {
safeCall(aCallback, addons);
}
});
},
@ -637,29 +636,29 @@ var AddonManagerInternal = {
/**
* Asynchronously gets add-ons of specific types.
*
* @param types
* An optional array of types to retrieve. Each type is a string name
* @param callback
* The callback to pass an array of Addons to.
* @throws if the callback argument is not specified
* @param aTypes
* An optional array of types to retrieve. Each type is a string name
* @param aCallback
* The callback to pass an array of Addons to.
* @throws if the aCallback argument is not specified
*/
getAddonsByTypes: function AMI_getAddonsByTypes(types, callback) {
if (!callback)
getAddonsByTypes: function AMI_getAddonsByTypes(aTypes, aCallback) {
if (!aCallback)
throw Cr.NS_ERROR_INVALID_ARG;
let addons = [];
new AsyncObjectCaller(this.providers, "getAddonsByTypes", {
nextObject: function(caller, provider) {
callProvider(provider, "getAddonsByTypes", null, types,
function(providerAddons) {
addons = addons.concat(providerAddons);
caller.callNext();
nextObject: function(aCaller, aProvider) {
callProvider(aProvider, "getAddonsByTypes", null, aTypes,
function(aProviderAddons) {
addons = addons.concat(aProviderAddons);
aCaller.callNext();
});
},
noMoreObjects: function(caller) {
safeCall(callback, addons);
noMoreObjects: function(aCaller) {
safeCall(aCallback, addons);
}
});
},
@ -668,30 +667,30 @@ var AddonManagerInternal = {
* Asynchronously gets add-ons that have operations waiting for an application
* restart to complete.
*
* @param types
* An optional array of types to retrieve. Each type is a string name
* @param callback
* The callback to pass the array of Addons to
* @throws if the callback argument is not specified
* @param aTypes
* An optional array of types to retrieve. Each type is a string name
* @param aCallback
* The callback to pass the array of Addons to
* @throws if the aCallback argument is not specified
*/
getAddonsWithPendingOperations:
function AMI_getAddonsWithPendingOperations(types, callback) {
if (!callback)
function AMI_getAddonsWithPendingOperations(aTypes, aCallback) {
if (!aCallback)
throw Cr.NS_ERROR_INVALID_ARG;
let addons = [];
new AsyncObjectCaller(this.providers, "getAddonsWithPendingOperations", {
nextObject: function(caller, provider) {
callProvider(provider, "getAddonsWithPendingOperations", null, types,
function(providerAddons) {
addons = addons.concat(providerAddons);
caller.callNext();
nextObject: function(aCaller, aProvider) {
callProvider(aProvider, "getAddonsWithPendingOperations", null, aTypes,
function(aProviderAddons) {
addons = addons.concat(aProviderAddons);
aCaller.callNext();
});
},
noMoreObjects: function(caller) {
safeCall(callback, addons);
safeCall(aCallback, addons);
}
});
},
@ -699,23 +698,23 @@ var AddonManagerInternal = {
/**
* Adds a new AddonListener if the listener is not already registered.
*
* @param listener
* The listener to add
* @param aListener
* The listener to add
*/
addAddonListener: function AMI_addAddonListener(listener) {
if (!this.addonListeners.some(function(i) { return i == listener; }))
this.addonListeners.push(listener);
addAddonListener: function AMI_addAddonListener(aListener) {
if (!this.addonListeners.some(function(i) { return i == aListener; }))
this.addonListeners.push(aListener);
},
/**
* Removes an AddonListener if the listener is registered.
*
* @param listener
* The listener to remove
* @param aListener
* The listener to remove
*/
removeAddonListener: function AMI_removeAddonListener(listener) {
removeAddonListener: function AMI_removeAddonListener(aListener) {
this.addonListeners = this.addonListeners.filter(function(i) {
return i != listener;
return i != aListener;
});
}
};
@ -731,8 +730,8 @@ var AddonManagerPrivate = {
AddonManagerInternal.startup();
},
registerProvider: function AMP_registerProvider(provider) {
AddonManagerInternal.registerProvider(provider);
registerProvider: function AMP_registerProvider(aProvider) {
AddonManagerInternal.registerProvider(aProvider);
},
shutdown: function AMP_shutdown() {
@ -743,16 +742,16 @@ var AddonManagerPrivate = {
AddonManagerInternal.backgroundUpdateCheck();
},
notifyAddonChanged: function AMP_notifyAddonChanged(id, type, pendingRestart) {
AddonManagerInternal.notifyAddonChanged(id, type, pendingRestart);
notifyAddonChanged: function AMP_notifyAddonChanged(aId, aType, aPendingRestart) {
AddonManagerInternal.notifyAddonChanged(aId, aType, aPendingRestart);
},
callInstallListeners: function AMP_callInstallListeners(method) {
callInstallListeners: function AMP_callInstallListeners(aMethod) {
return AddonManagerInternal.callInstallListeners.apply(AddonManagerInternal,
arguments);
arguments);
},
callAddonListeners: function AMP_callAddonListeners(method) {
callAddonListeners: function AMP_callAddonListeners(aMethod) {
AddonManagerInternal.callAddonListeners.apply(AddonManagerInternal, arguments);
}
};
@ -839,64 +838,64 @@ var AddonManager = {
// The combination of all scopes.
SCOPE_ALL: 15,
getInstallForURL: function AM_getInstallForURL(url, callback, mimetype, hash,
name, iconURL, version,
loadGroup) {
AddonManagerInternal.getInstallForURL(url, callback, mimetype, hash, name,
iconURL, version, loadGroup);
getInstallForURL: function AM_getInstallForURL(aUrl, aCallback, aMimetype,
aHash, aName, aIconURL,
aVersion, aLoadGroup) {
AddonManagerInternal.getInstallForURL(aUrl, aCallback, aMimetype, aHash,
aName, aIconURL, aVersion, aLoadGroup);
},
getInstallForFile: function AM_getInstallForFile(file, callback, mimetype) {
AddonManagerInternal.getInstallForFile(file, callback, mimetype);
getInstallForFile: function AM_getInstallForFile(aFile, aCallback, aMimetype) {
AddonManagerInternal.getInstallForFile(aFile, aCallback, aMimetype);
},
getAddon: function AM_getAddon(id, callback) {
AddonManagerInternal.getAddon(id, callback);
getAddon: function AM_getAddon(aId, aCallback) {
AddonManagerInternal.getAddon(aId, aCallback);
},
getAddons: function AM_getAddons(ids, callback) {
AddonManagerInternal.getAddons(ids, callback);
getAddons: function AM_getAddons(aIds, aCallback) {
AddonManagerInternal.getAddons(aIds, aCallback);
},
getAddonsWithPendingOperations:
function AM_getAddonsWithPendingOperations(types, callback) {
AddonManagerInternal.getAddonsWithPendingOperations(types, callback);
function AM_getAddonsWithPendingOperations(aTypes, aCallback) {
AddonManagerInternal.getAddonsWithPendingOperations(aTypes, aCallback);
},
getAddonsByTypes: function AM_getAddonsByTypes(types, callback) {
AddonManagerInternal.getAddonsByTypes(types, callback);
getAddonsByTypes: function AM_getAddonsByTypes(aTypes, aCallback) {
AddonManagerInternal.getAddonsByTypes(aTypes, aCallback);
},
getInstalls: function AM_getInstalls(types, callback) {
AddonManagerInternal.getInstalls(types, callback);
getInstalls: function AM_getInstalls(aTypes, aCallback) {
AddonManagerInternal.getInstalls(aTypes, aCallback);
},
isInstallEnabled: function AM_isInstallEnabled(type) {
return AddonManagerInternal.isInstallEnabled(type);
isInstallEnabled: function AM_isInstallEnabled(aType) {
return AddonManagerInternal.isInstallEnabled(aType);
},
isInstallAllowed: function AM_isInstallAllowed(type, uri) {
return AddonManagerInternal.isInstallAllowed(type, uri);
isInstallAllowed: function AM_isInstallAllowed(aType, aUri) {
return AddonManagerInternal.isInstallAllowed(aType, aUri);
},
installAddonsFromWebpage: function AM_installAddonsFromWebpage(type, source,
uri, installs) {
AddonManagerInternal.installAddonsFromWebpage(type, source, uri, installs);
installAddonsFromWebpage: function AM_installAddonsFromWebpage(aType, aSource,
aUri, aInstalls) {
AddonManagerInternal.installAddonsFromWebpage(aType, aSource, aUri, aInstalls);
},
addInstallListener: function AM_addInstallListener(listener) {
AddonManagerInternal.addInstallListener(listener);
addInstallListener: function AM_addInstallListener(aListener) {
AddonManagerInternal.addInstallListener(aListener);
},
removeInstallListener: function AM_removeInstallListener(listener) {
AddonManagerInternal.removeInstallListener(listener);
removeInstallListener: function AM_removeInstallListener(aListener) {
AddonManagerInternal.removeInstallListener(aListener);
},
addAddonListener: function AM_addAddonListener(listener) {
AddonManagerInternal.addAddonListener(listener);
addAddonListener: function AM_addAddonListener(aListener) {
AddonManagerInternal.addAddonListener(aListener);
},
removeAddonListener: function AM_removeAddonListener(listener) {
AddonManagerInternal.removeAddonListener(listener);
removeAddonListener: function AM_removeAddonListener(aListener) {
AddonManagerInternal.removeAddonListener(aListener);
}
};

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

@ -66,30 +66,30 @@ var gRDF = Cc["@mozilla.org/rdf/rdf-service;1"].
/**
* Logs a debug message.
*
* @param str
* The string to log
* @param aStr
* The string to log
*/
function LOG(str) {
dump("*** addons.updates: " + str + "\n");
function LOG(aStr) {
dump("*** addons.updates: " + aStr + "\n");
}
/**
* Logs a warning message
*
* @param str
* The string to log
* @param aStr
* The string to log
*/
function WARN(str) {
LOG(str);
function WARN(aStr) {
LOG(aStr);
}
/**
* Logs an error message
*
* @param str
* The string to log
* @param aStr
* The string to log
*/
function ERROR(str) {
function ERROR(aStr) {
LOG(str);
}
@ -114,37 +114,38 @@ RDFSerializer.prototype = {
/**
* Escapes characters from a string that should not appear in XML.
*
* @param string
* The string to be escaped
* @return a string with all characters invalid in XML character data
* converted to entity references.
* @param aString
* The string to be escaped
* @return a string with all characters invalid in XML character data
* converted to entity references.
*/
escapeEntities: function RDFS_escapeEntities(string) {
string = string.replace(/&/g, "&amp;");
string = string.replace(/</g, "&lt;");
string = string.replace(/>/g, "&gt;");
return string.replace(/"/g, "&quot;");
escapeEntities: function RDFS_escapeEntities(aString) {
aString = aString.replace(/&/g, "&amp;");
aString = aString.replace(/</g, "&lt;");
aString = aString.replace(/>/g, "&gt;");
return aString.replace(/"/g, "&quot;");
},
/**
* Serializes all the elements of an RDF container.
*
* @param ds
* The RDF datasource
* @param container
* The RDF container to output the child elements of
* @param indent
* The current level of indent for pretty-printing
* @return a string containing the serialized elements.
* @param aDs
* The RDF datasource
* @param aContainer
* The RDF container to output the child elements of
* @param aIndent
* The current level of indent for pretty-printing
* @return a string containing the serialized elements.
*/
serializeContainerItems: function RDFS_serializeContainerItems(ds, container, indent) {
serializeContainerItems: function RDFS_serializeContainerItems(aDs, aContainer,
aIndent) {
var result = "";
var items = container.GetElements();
var items = aContainer.GetElements();
while (items.hasMoreElements()) {
var item = items.getNext().QueryInterface(Ci.nsIRDFResource);
result += indent + "<RDF:li>\n"
result += this.serializeResource(ds, item, indent + this.INDENT);
result += indent + "</RDF:li>\n"
result += aIndent + "<RDF:li>\n"
result += this.serializeResource(aDs, item, aIndent + this.INDENT);
result += aIndent + "</RDF:li>\n"
}
return result;
},
@ -154,19 +155,21 @@ RDFSerializer.prototype = {
* the em:signature property. As this serialization is to be compared against
* the manifest signature it cannot contain the em:signature property itself.
*
* @param ds
* The RDF datasource
* @param resource
* The RDF resource that contains the properties to serialize
* @param indent
* The current level of indent for pretty-printing
* @return a string containing the serialized properties.
* @throws if the resource contains a property that cannot be serialized
* @param aDs
* The RDF datasource
* @param aResource
* The RDF resource that contains the properties to serialize
* @param aIndent
* The current level of indent for pretty-printing
* @return a string containing the serialized properties.
* @throws if the resource contains a property that cannot be serialized
*/
serializeResourceProperties: function RDFS_serializeResourceProperties(ds, resource, indent) {
serializeResourceProperties: function RDFS_serializeResourceProperties(aDs,
aResource,
aIndent) {
var result = "";
var items = [];
var arcs = ds.ArcLabelsOut(resource);
var arcs = aDs.ArcLabelsOut(aResource);
while (arcs.hasMoreElements()) {
var arc = arcs.getNext().QueryInterface(Ci.nsIRDFResource);
if (arc.ValueUTF8.substring(0, PREFIX_NS_EM.length) != PREFIX_NS_EM)
@ -175,20 +178,22 @@ RDFSerializer.prototype = {
if (prop == "signature")
continue;
var targets = ds.GetTargets(resource, arc, true);
var targets = aDs.GetTargets(aResource, arc, true);
while (targets.hasMoreElements()) {
var target = targets.getNext();
if (target instanceof Ci.nsIRDFResource) {
var item = indent + "<em:" + prop + ">\n";
item += this.serializeResource(ds, target, indent + this.INDENT);
item += indent + "</em:" + prop + ">\n";
var item = aIndent + "<em:" + prop + ">\n";
item += this.serializeResource(aDs, target, aIndent + this.INDENT);
item += aIndent + "</em:" + prop + ">\n";
items.push(item);
}
else if (target instanceof Ci.nsIRDFLiteral) {
items.push(indent + "<em:" + prop + ">" + this.escapeEntities(target.Value) + "</em:" + prop + ">\n");
items.push(aIndent + "<em:" + prop + ">" +
this.escapeEntities(target.Value) + "</em:" + prop + ">\n");
}
else if (target instanceof Ci.nsIRDFInt) {
items.push(indent + "<em:" + prop + " NC:parseType=\"Integer\">" + target.Value + "</em:" + prop + ">\n");
items.push(aIndent + "<em:" + prop + " NC:parseType=\"Integer\">" +
target.Value + "</em:" + prop + ">\n");
}
else {
throw new Error("Cannot serialize unknown literal type");
@ -205,51 +210,51 @@ RDFSerializer.prototype = {
* This will only output EM_NS properties and will ignore any em:signature
* property.
*
* @param ds
* The RDF datasource
* @param resource
* The RDF resource to serialize
* @param indent
* The current level of indent for pretty-printing. If undefined no
* indent will be added
* @return a string containing the serialized resource.
* @throws if the RDF data contains multiple references to the same resource.
* @param aDs
* The RDF datasource
* @param aResource
* The RDF resource to serialize
* @param aIndent
* The current level of indent for pretty-printing. If undefined no
* indent will be added
* @return a string containing the serialized resource.
* @throws if the RDF data contains multiple references to the same resource.
*/
serializeResource: function RDFS_serializeResource(ds, resource, indent) {
if (this.resources.indexOf(resource) != -1 ) {
serializeResource: function RDFS_serializeResource(aDs, aResource, aIndent) {
if (this.resources.indexOf(aResource) != -1 ) {
// We cannot output multiple references to the same resource.
throw new Error("Cannot serialize multiple references to " + resource.Value);
throw new Error("Cannot serialize multiple references to " + aResource.Value);
}
if (indent === undefined)
indent = "";
if (aIndent === undefined)
aIndent = "";
this.resources.push(resource);
this.resources.push(aResource);
var container = null;
var type = "Description";
if (this.cUtils.IsSeq(ds, resource)) {
if (this.cUtils.IsSeq(aDs, aResource)) {
type = "Seq";
container = this.cUtils.MakeSeq(ds, resource);
container = this.cUtils.MakeSeq(aDs, aResource);
}
else if (this.cUtils.IsAlt(ds, resource)) {
else if (this.cUtils.IsAlt(aDs, aResource)) {
type = "Alt";
container = this.cUtils.MakeAlt(ds, resource);
container = this.cUtils.MakeAlt(aDs, aResource);
}
else if (this.cUtils.IsBag(ds, resource)) {
else if (this.cUtils.IsBag(aDs, aResource)) {
type = "Bag";
container = this.cUtils.MakeBag(ds, resource);
container = this.cUtils.MakeBag(aDs, aResource);
}
var result = indent + "<RDF:" + type;
if (!gRDF.IsAnonymousResource(resource))
result += " about=\"" + this.escapeEntities(resource.ValueUTF8) + "\"";
var result = aIndent + "<RDF:" + type;
if (!gRDF.IsAnonymousResource(aResource))
result += " about=\"" + this.escapeEntities(aResource.ValueUTF8) + "\"";
result += ">\n";
if (container)
result += this.serializeContainerItems(ds, container, indent + this.INDENT);
result += this.serializeContainerItems(aDs, container, aIndent + this.INDENT);
result += this.serializeResourceProperties(ds, resource, indent + this.INDENT);
result += this.serializeResourceProperties(aDs, aResource, aIndent + this.INDENT);
result += indent + "</RDF:" + type + ">\n";
result += aIndent + "</RDF:" + type + ">\n";
return result;
}
}
@ -257,39 +262,40 @@ RDFSerializer.prototype = {
/**
* Parses an RDF style update manifest into an array of update objects.
*
* @param id
* The ID of the add-on being checked for updates
* @param type
* The type of the add-on being checked for updates
* @param updateKey
* An optional update key for the add-on
* @param The XMLHttpRequest that has retrieved the update manifest
* @return an array of update objects
* @throws if the update manifest is invalid in any way
* @param aId
* The ID of the add-on being checked for updates
* @param aType
* The type of the add-on being checked for updates
* @param aUpdateKey
* An optional update key for the add-on
* @param aRequest
* The XMLHttpRequest that has retrieved the update manifest
* @return an array of update objects
* @throws if the update manifest is invalid in any way
*/
function parseRDFManifest(id, type, updateKey, request) {
function EM_R(prop) {
return gRDF.GetResource(PREFIX_NS_EM + prop);
function parseRDFManifest(aId, aType, aUpdateKey, aRequest) {
function EM_R(aProp) {
return gRDF.GetResource(PREFIX_NS_EM + aProp);
}
function getValue(literal) {
if (literal instanceof Ci.nsIRDFLiteral)
return literal.Value;
if (literal instanceof Ci.nsIRDFResource)
return literal.Value;
if (literal instanceof Ci.nsIRDFInt)
return literal.Value;
function getValue(aLiteral) {
if (aLiteral instanceof Ci.nsIRDFLiteral)
return aLiteral.Value;
if (aLiteral instanceof Ci.nsIRDFResource)
return aLiteral.Value;
if (aLiteral instanceof Ci.nsIRDFInt)
return aLiteral.Value;
return null;
}
function getProperty(ds, source, property) {
return getValue(ds.GetTarget(source, EM_R(property), true));
function getProperty(aDs, aSource, aProperty) {
return getValue(aDs.GetTarget(aSource, EM_R(aProperty), true));
}
function getRequiredProperty(ds, source, property) {
let value = getProperty(ds, source, property);
function getRequiredProperty(aDs, aSource, aProperty) {
let value = getProperty(aDs, aSource, aProperty);
if (!value)
throw new Error("Update manifest is missing a required " + property + " property.");
throw new Error("Update manifest is missing a required " + aProperty + " property.");
return value;
}
@ -297,27 +303,27 @@ function parseRDFManifest(id, type, updateKey, request) {
createInstance(Ci.nsIRDFXMLParser);
let ds = Cc["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"].
createInstance(Ci.nsIRDFDataSource);
rdfParser.parseString(ds, request.channel.URI, request.responseText);
rdfParser.parseString(ds, aRequest.channel.URI, aRequest.responseText);
switch (type) {
switch (aType) {
case "extension":
var item = PREFIX_EXTENSION + id;
var item = PREFIX_EXTENSION + aId;
break;
case "theme":
item = PREFIX_THEME + id;
item = PREFIX_THEME + aId;
break;
default:
item = PREFIX_ITEM + id;
item = PREFIX_ITEM + aId;
break;
}
let extensionRes = gRDF.GetResource(item);
// If we have an update key then the update manifest must be signed
if (updateKey) {
if (aUpdateKey) {
let signature = getProperty(ds, extensionRes, "signature");
if (!signature)
throw new Error("Update manifest for " + id + " does not contain a required signature");
throw new Error("Update manifest for " + aId + " does not contain a required signature");
let serializer = new RDFSerializer();
let updateString = null;
@ -325,7 +331,7 @@ function parseRDFManifest(id, type, updateKey, request) {
updateString = serializer.serializeResource(ds, extensionRes);
}
catch (e) {
throw new Error("Failed to generate signed string for " + id + ". Serializer threw " + e);
throw new Error("Failed to generate signed string for " + aId + ". Serializer threw " + e);
}
let result = false;
@ -333,14 +339,14 @@ function parseRDFManifest(id, type, updateKey, request) {
try {
let verifier = Cc["@mozilla.org/security/datasignatureverifier;1"].
getService(Ci.nsIDataSignatureVerifier);
result = verifier.verifyData(updateString, signature, updateKey);
result = verifier.verifyData(updateString, signature, aUpdateKey);
}
catch (e) {
throw new Error("The signature or updateKey for " + id + " is malformed");
throw new Error("The signature or updateKey for " + aId + " is malformed");
}
if (!result)
throw new Error("The signature for " + id + " was not created by the add-on's updateKey");
throw new Error("The signature for " + aId + " was not created by the add-on's updateKey");
}
let updates = ds.GetTarget(extensionRes, EM_R("updates"), true);
@ -374,7 +380,7 @@ function parseRDFManifest(id, type, updateKey, request) {
continue;
}
LOG("Found an update entry for " + id + " version " + version);
LOG("Found an update entry for " + aId + " version " + version);
let targetApps = ds.GetTargets(item, EM_R("targetApplication"), true);
while (targetApps.hasMoreElements()) {
@ -417,31 +423,31 @@ function parseRDFManifest(id, type, updateKey, request) {
* Starts downloading an update manifest and then passes it to an appropriate
* parser to convert to an array of update objects
*
* @param id
* The ID of the add-on being checked for updates
* @param type
* The type of add-on being checked for updates
* @param updateKey
* An optional update key for the add-on
* @param url
* The URL of the update manifest
* @param observer
* An observer to pass results to
* @param aId
* The ID of the add-on being checked for updates
* @param aType
* The type of add-on being checked for updates
* @param aUpdateKey
* An optional update key for the add-on
* @param aUrl
* The URL of the update manifest
* @param aObserver
* An observer to pass results to
*/
function UpdateParser(id, type, updateKey, url, observer) {
this.id = id;
this.type = type;
this.updateKey = updateKey;
this.observer = observer;
function UpdateParser(aId, aType, aUpdateKey, aUrl, aObserver) {
this.id = aId;
this.type = aType;
this.updateKey = aUpdateKey;
this.observer = aObserver;
this.timer = Cc["@mozilla.org/timer;1"].
createInstance(Ci.nsITimer);
this.timer.initWithCallback(this, TIMEOUT, Ci.nsITimer.TYPE_ONE_SHOT);
LOG("Requesting " + url);
LOG("Requesting " + aUrl);
this.request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
createInstance(Ci.nsIXMLHttpRequest);
this.request.open("GET", url, true);
this.request.open("GET", aUrl, true);
this.request.channel.notificationCallbacks = new BadCertHandler();
this.request.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
this.request.overrideMimeType("text/xml");
@ -526,15 +532,15 @@ UpdateParser.prototype = {
/**
* Helper method to notify the observer that an error occured.
*/
notifyError: function UP_notifyError(status) {
notifyError: function UP_notifyError(aStatus) {
if ("onUpdateCheckError" in this.observer)
this.observer.onUpdateCheckError(status);
this.observer.onUpdateCheckError(aStatus);
},
/**
* Called when the request has timed out and should be canceled.
*/
notify: function UP_notify(timer) {
notify: function UP_notify(aTimer) {
this.timer = null;
this.request.abort();
this.request = null;
@ -548,25 +554,25 @@ UpdateParser.prototype = {
/**
* Tests if an update matches a version of the application or platform
*
* @param update
* The available update
* @param appVersion
* The application version to use
* @param platformVersion
* The platform version to use
* @return true if the update is compatible with the application/platform
* @param aUpdate
* The available update
* @param aAppVersion
* The application version to use
* @param aPlatformVersion
* The platform version to use
* @return true if the update is compatible with the application/platform
*/
function matchesVersions(update, appVersion, platformVersion) {
function matchesVersions(aUpdate, aAppVersion, aPlatformVersion) {
let result = false;
for (let i = 0; i < update.targetApplications.length; i++) {
let app = update.targetApplications[i];
for (let i = 0; i < aUpdate.targetApplications.length; i++) {
let app = aUpdate.targetApplications[i];
if (app.id == Services.appinfo.ID) {
return (Services.vc.compare(appVersion, app.minVersion) >= 0) &&
(Services.vc.compare(appVersion, app.maxVersion) <= 0);
return (Services.vc.compare(aAppVersion, app.minVersion) >= 0) &&
(Services.vc.compare(aAppVersion, app.maxVersion) <= 0);
}
if (app.id == TOOLKIT_ID) {
result = (Services.vc.compare(platformVersion, app.minVersion) >= 0) &&
(Services.vc.compare(platformVersion, app.maxVersion) <= 0);
result = (Services.vc.compare(aPlatformVersion, app.minVersion) >= 0) &&
(Services.vc.compare(aPlatformVersion, app.maxVersion) <= 0);
}
}
return result;
@ -583,39 +589,39 @@ var AddonUpdateChecker = {
* Retrieves the best matching compatibility update for the application from
* a list of available update objects.
*
* @param updates
* An array of update objects
* @param version
* The version of the add-on to get new compatibility information for
* @param ignoreCompatibility
* An optional parameter to get the first compatibility update that
* is compatible with any version of the application or toolkit
* @param appVersion
* The version of the application or null to use the current version
* @param platformVersion
* The version of the platform or null to use the current version
* @return an update object if one matches or null if not
* @param aUpdates
* An array of update objects
* @param aVersion
* The version of the add-on to get new compatibility information for
* @param aIgnoreCompatibility
* An optional parameter to get the first compatibility update that
* is compatible with any version of the application or toolkit
* @param aAppVersion
* The version of the application or null to use the current version
* @param aPlatformVersion
* The version of the platform or null to use the current version
* @return an update object if one matches or null if not
*/
getCompatibilityUpdate: function AUC_getCompatibilityUpdate(updates, version,
ignoreCompatibility,
appVersion,
platformVersion) {
if (!appVersion)
appVersion = Services.appinfo.version;
if (!platformVersion)
platformVersion = Services.appinfo.platformVersion;
getCompatibilityUpdate: function AUC_getCompatibilityUpdate(aUpdates, aVersion,
aIgnoreCompatibility,
aAppVersion,
aPlatformVersion) {
if (!aAppVersion)
aAppVersion = Services.appinfo.version;
if (!aPlatformVersion)
aPlatformVersion = Services.appinfo.platformVersion;
for (let i = 0; i < updates.length; i++) {
if (Services.vc.compare(updates[i].version, version) == 0) {
if (ignoreCompatibility) {
for (let j = 0; j < updates[i].targetApplications.length; j++) {
let id = updates[i].targetApplications[j].id;
for (let i = 0; i < aUpdates.length; i++) {
if (Services.vc.compare(aUpdates[i].version, aVersion) == 0) {
if (aIgnoreCompatibility) {
for (let j = 0; j < aUpdates[i].targetApplications.length; j++) {
let id = aUpdates[i].targetApplications[j].id;
if (id == Services.appinfo.ID || id == TOOLKIT_ID)
return updates[i];
return aUpdates[i];
}
}
else if (matchesVersions(updates[i], appVersion, platformVersion)) {
return updates[i];
else if (matchesVersions(aUpdates[i], aAppVersion, aPlatformVersion)) {
return aUpdates[i];
}
}
}
@ -625,29 +631,29 @@ var AddonUpdateChecker = {
/**
* Returns the newest available update from a list of update objects.
*
* @param updates
* An array of update objects
* @param appVersion
* The version of the application or null to use the current version
* @param platformVersion
* The version of the platform or null to use the current version
* @return an update object if one matches or null if not
* @param aUpdates
* An array of update objects
* @param aAppVersion
* The version of the application or null to use the current version
* @param aPlatformVersion
* The version of the platform or null to use the current version
* @return an update object if one matches or null if not
*/
getNewestCompatibleUpdate: function AUC_getNewestCompatibleUpdate(updates,
appVersion,
platformVersion) {
if (!appVersion)
appVersion = Services.appinfo.version;
if (!platformVersion)
platformVersion = Services.appinfo.platformVersion;
getNewestCompatibleUpdate: function AUC_getNewestCompatibleUpdate(aUpdates,
aAppVersion,
aPlatformVersion) {
if (!aAppVersion)
aAppVersion = Services.appinfo.version;
if (!aPlatformVersion)
aPlatformVersion = Services.appinfo.platformVersion;
let newest = null;
for (let i = 0; i < updates.length; i++) {
if (!updates[i].updateURL)
for (let i = 0; i < aUpdates.length; i++) {
if (!aUpdates[i].updateURL)
continue;
if ((newest == null || (Services.vc.compare(newest.version, updates[i].version) < 0)) &&
matchesVersions(updates[i], appVersion, platformVersion))
newest = updates[i];
if ((newest == null || (Services.vc.compare(newest.version, aUpdates[i].version) < 0)) &&
matchesVersions(aUpdates[i], aAppVersion, aPlatformVersion))
newest = aUpdates[i];
}
return newest;
},
@ -655,19 +661,19 @@ var AddonUpdateChecker = {
/**
* Starts an update check.
*
* @param id
* The ID of the add-on being checked for updates
* @param type
* The type of add-on being checked for updates
* @param updateKey
* An optional update key for the add-on
* @param url
* The URL of the add-on's update manifest
* @param observer
* An observer to notify of results
* @param aId
* The ID of the add-on being checked for updates
* @param aType
* The type of add-on being checked for updates
* @param aUpdateKey
* An optional update key for the add-on
* @param aUrl
* The URL of the add-on's update manifest
* @param aObserver
* An observer to notify of results
*/
checkForUpdates: function AUC_checkForUpdates(id, type, updateKey, url,
observer) {
new UpdateParser(id, type, updateKey, url, observer);
checkForUpdates: function AUC_checkForUpdates(aId, aType, aUpdateKey, aUrl,
aObserver) {
new UpdateParser(aId, aType, aUpdateKey, aUrl, aObserver);
}
};

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

@ -231,8 +231,8 @@ var LightweightThemeManager = {
/**
* Switches to a new lightweight theme.
*
* @param aData
* The lightweight theme to switch to
* @param aData
* The lightweight theme to switch to
*/
themeChanged: function(aData) {
if (_previewTimer) {
@ -272,13 +272,13 @@ var LightweightThemeManager = {
* Called when a new add-on has been enabled when only one add-on of that type
* can be enabled.
*
* @param aId
* The ID of the newly enabled add-on
* @param aType
* The type of the newly enabled add-on
* @param aPendingRestart
* true if the newly enabled add-on will only become enabled after a
* restart
* @param aId
* The ID of the newly enabled add-on
* @param aType
* The type of the newly enabled add-on
* @param aPendingRestart
* true if the newly enabled add-on will only become enabled after a
* restart
*/
addonChanged: function(aId, aType, aPendingRestart) {
if (aType != ADDON_TYPE)
@ -341,10 +341,10 @@ var LightweightThemeManager = {
/**
* Called to get an Addon with a particular ID.
*
* @param aId
* The ID of the add-on to retrieve
* @param aCallback
* A callback to pass the Addon to
* @param aId
* The ID of the add-on to retrieve
* @param aCallback
* A callback to pass the Addon to
*/
getAddon: function(aId, aCallback) {
let id = _getInternalID(aId);
@ -365,10 +365,10 @@ var LightweightThemeManager = {
/**
* Called to get Addons of a particular type.
*
* @param aTypes
* An array of types to fetch. Can be null to get all types.
* @param aCallback
* A callback to pass an array of Addons to
* @param aTypes
* An array of types to fetch. Can be null to get all types.
* @param aCallback
* A callback to pass an array of Addons to
*/
getAddonsByTypes: function(aTypes, aCallback) {
if (aTypes && aTypes.indexOf(ADDON_TYPE) == -1) {

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

@ -46,29 +46,32 @@ Components.utils.import("resource://gre/modules/AddonManager.jsm");
/**
* Logs a debug message.
* @param str
* The string to log
*
* @param aStr
* The string to log
*/
function LOG(str) {
dump("*** addons.plugins: " + str + "\n");
function LOG(aStr) {
dump("*** addons.plugins: " + aStr + "\n");
}
/**
* Logs a warning message.
* @param str
* The string to log
*
* @param aStr
* The string to log
*/
function WARN(str) {
LOG(str);
function WARN(aStr) {
LOG(aStr);
}
/**
* Logs an error message.
* @param str
* The string to log
*
* @param aStr
* The string to log
*/
function ERROR(str) {
LOG(str);
function ERROR(aStr) {
LOG(aStr);
}
var PluginProvider = {
@ -77,45 +80,47 @@ var PluginProvider = {
/**
* Called to get an Addon with a particular ID.
* @param id
* The ID of the add-on to retrieve
* @param callback
* A callback to pass the Addon to
*
* @param aId
* The ID of the add-on to retrieve
* @param aCallback
* A callback to pass the Addon to
*/
getAddon: function PL_getAddon(id, callback) {
getAddon: function PL_getAddon(aId, aCallback) {
if (!this.plugins)
this.buildPluginList();
if (id in this.plugins) {
let name = this.plugins[id].name;
let description = this.plugins[id].description;
if (aId in this.plugins) {
let name = this.plugins[aId].name;
let description = this.plugins[aId].description;
let tags = Cc["@mozilla.org/plugin/host;1"].
getService(Ci.nsIPluginHost).
getPluginTags({});
let selected = [];
tags.forEach(function(tag) {
if (tag.name == name && tag.description == description)
selected.push(tag);
tags.forEach(function(aTag) {
if (aTag.name == name && aTag.description == description)
selected.push(aTag);
}, this);
callback(new PluginWrapper(id, name, description, selected));
aCallback(new PluginWrapper(aId, name, description, selected));
}
else {
callback(null);
aCallback(null);
}
},
/**
* Called to get Addons of a particular type.
* @param types
* An array of types to fetch. Can be null to get all types.
* @param callback
* A callback to pass an array of Addons to
*
* @param aTypes
* An array of types to fetch. Can be null to get all types.
* @param callback
* A callback to pass an array of Addons to
*/
getAddonsByTypes: function PL_getAddonsByTypes(types, callback) {
if (types && types.indexOf("plugin") < 0) {
callback([]);
getAddonsByTypes: function PL_getAddonsByTypes(aTypes, aCallback) {
if (aTypes && aTypes.indexOf("plugin") < 0) {
aCallback([]);
return;
}
@ -125,34 +130,36 @@ var PluginProvider = {
let results = [];
for (let id in this.plugins) {
this.getAddon(id, function(addon) {
results.push(addon);
this.getAddon(id, function(aAddon) {
results.push(aAddon);
});
}
callback(results);
aCallback(results);
},
/**
* Called to get Addons that have pending operations.
* @param types
* An array of types to fetch. Can be null to get all types
* @param callback
* A callback to pass an array of Addons to
*
* @param aTypes
* An array of types to fetch. Can be null to get all types
* @param aCallback
* A callback to pass an array of Addons to
*/
getAddonsWithPendingOperations: function PL_getAddonsWithPendingOperations(types, callback) {
callback([]);
getAddonsWithPendingOperations: function PL_getAddonsWithPendingOperations(aTypes, aCallback) {
aCallback([]);
},
/**
* Called to get the current AddonInstalls, optionally restricting by type.
* @param types
* An array of types or null to get all types
* @param callback
* A callback to pass the array of AddonInstalls to
*
* @param aTypes
* An array of types or null to get all types
* @param aCallback
* A callback to pass the array of AddonInstalls to
*/
getInstalls: function PL_getInstalls(types, callback) {
callback([]);
getInstalls: function PL_getInstalls(aTypes, aCallback) {
aCallback([]);
},
buildPluginList: function PL_buildPluginList() {
@ -162,18 +169,18 @@ var PluginProvider = {
this.plugins = {};
let seen = {};
tags.forEach(function(tag) {
if (!(tag.name in seen))
seen[tag.name] = {};
if (!(tag.description in seen[tag.name])) {
tags.forEach(function(aTag) {
if (!(aTag.name in seen))
seen[aTag.name] = {};
if (!(aTag.description in seen[aTag.name])) {
let id = Cc["@mozilla.org/uuid-generator;1"].
getService(Ci.nsIUUIDGenerator).
generateUUID();
this.plugins[id] = {
name: tag.name,
description: tag.description
name: aTag.name,
description: aTag.description
};
seen[tag.name][tag.description] = true;
seen[aTag.name][aTag.description] = true;
}
}, this);
}
@ -183,33 +190,33 @@ var PluginProvider = {
* The PluginWrapper wraps a set of nsIPluginTags to provide the data visible to
* public callers through the API.
*/
function PluginWrapper(id, name, description, tags) {
let safedesc = description.replace(/<\/?[a-z][^>]*>/gi, " ");
function PluginWrapper(aId, aName, aDescription, aTags) {
let safedesc = aDescription.replace(/<\/?[a-z][^>]*>/gi, " ");
let homepageURL = null;
if (/<A\s+HREF=[^>]*>/i.test(description))
homepageURL = /<A\s+HREF=["']?([^>"'\s]*)/i.exec(description)[1];
if (/<A\s+HREF=[^>]*>/i.test(aDescription))
homepageURL = /<A\s+HREF=["']?([^>"'\s]*)/i.exec(aDescription)[1];
this.__defineGetter__("id", function() id);
this.__defineGetter__("id", function() aId);
this.__defineGetter__("type", function() "plugin");
this.__defineGetter__("name", function() name);
this.__defineGetter__("name", function() aName);
this.__defineGetter__("description", function() safedesc);
this.__defineGetter__("version", function() tags[0].version);
this.__defineGetter__("version", function() aTags[0].version);
this.__defineGetter__("homepageURL", function() homepageURL);
this.__defineGetter__("isActive", function() !tags[0].blocklisted && !tags[0].disabled);
this.__defineGetter__("isActive", function() !aTags[0].blocklisted && !aTags[0].disabled);
this.__defineGetter__("isCompatible", function() true);
this.__defineGetter__("appDisabled", function() tags[0].blocklisted);
this.__defineGetter__("userDisabled", function() tags[0].disabled);
this.__defineSetter__("userDisabled", function(val) {
if (tags[0].disabled == val)
this.__defineGetter__("appDisabled", function() aTags[0].blocklisted);
this.__defineGetter__("userDisabled", function() aTags[0].disabled);
this.__defineSetter__("userDisabled", function(aVal) {
if (aTags[0].disabled == aVal)
return;
tags.forEach(function(tag) {
tag.disabled = val;
aTags.forEach(function(aTag) {
aTag.disabled = aVal;
});
AddonManagerPrivate.callAddonListeners(val ? "onDisabling" : "onEnabling", this, false);
AddonManagerPrivate.callAddonListeners(val ? "onDisabled" : "onEnabled", this);
return val;
AddonManagerPrivate.callAddonListeners(aVal ? "onDisabling" : "onEnabling", this, false);
AddonManagerPrivate.callAddonListeners(aVal ? "onDisabled" : "onEnabled", this);
return aVal;
});
this.__defineGetter__("pendingOperations", function() {
@ -235,15 +242,15 @@ function PluginWrapper(id, name, description, tags) {
throw new Error("Plugin is not marked to be uninstalled");
};
this.findUpdates = function(listener, reason, appVersion, platformVersion) {
this.findUpdates = function(aListener, aReason, aAppVersion, aPlatformVersion) {
throw new Error("Cannot search for updates for plugins");
};
this.hasResource = function(path) {
this.hasResource = function(aPath) {
return false;
},
this.getResourceURL = function(path) {
this.getResourceURL = function(aPath) {
return null;
}
}

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

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

@ -66,11 +66,11 @@ function amManager() {
}
amManager.prototype = {
observe: function AMC_observe(subject, topic, data) {
observe: function AMC_observe(aSubject, aTopic, aData) {
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
switch (topic) {
switch (aTopic) {
case "profile-after-change":
os.addObserver(this, "xpcom-shutdown", false);
AddonManagerPrivate.startup();
@ -85,82 +85,82 @@ amManager.prototype = {
/**
* @see amIWebInstaller.idl
*/
isInstallEnabled: function AMC_isInstallEnabled(mimetype, referer) {
return AddonManager.isInstallEnabled(mimetype);
isInstallEnabled: function AMC_isInstallEnabled(aMimetype, aReferer) {
return AddonManager.isInstallEnabled(aMimetype);
},
/**
* @see amIWebInstaller.idl
*/
installAddonsFromWebpage: function AMC_installAddonsFromWebpage(mimetype,
window,
referer, uris,
hashes, names,
icons, callback) {
if (uris.length == 0)
installAddonsFromWebpage: function AMC_installAddonsFromWebpage(aMimetype,
aWindow,
aReferer, aUris,
aHashes, aNames,
aIcons, aCallback) {
if (aUris.length == 0)
return false;
let retval = true;
if (!AddonManager.isInstallAllowed(mimetype, referer)) {
callback = null;
if (!AddonManager.isInstallAllowed(aMimetype, aReferer)) {
aCallback = null;
retval = false;
}
let loadGroup = null;
try {
loadGroup = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocumentLoader).loadGroup;
loadGroup = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocumentLoader).loadGroup;
}
catch (e) {
}
let installs = [];
function buildNextInstall() {
if (uris.length == 0) {
AddonManager.installAddonsFromWebpage(mimetype, window, referer, installs);
if (aUris.length == 0) {
AddonManager.installAddonsFromWebpage(aMimetype, aWindow, aReferer, installs);
return;
}
let uri = uris.shift();
AddonManager.getInstallForURL(uri, function(install) {
if (install) {
installs.push(install);
if (callback) {
install.addListener({
onDownloadCancelled: function(install) {
callback.onInstallEnded(uri, USER_CANCELLED);
let uri = aUris.shift();
AddonManager.getInstallForURL(uri, function(aInstall) {
if (aInstall) {
installs.push(aInstall);
if (aCallback) {
aInstall.addListener({
onDownloadCancelled: function(aInstall) {
aCallback.onInstallEnded(uri, USER_CANCELLED);
},
onDownloadFailed: function(install, error) {
if (error == AddonManager.ERROR_CORRUPT_FILE)
callback.onInstallEnded(uri, CANT_READ_ARCHIVE);
onDownloadFailed: function(aInstall, aError) {
if (aError == AddonManager.ERROR_CORRUPT_FILE)
aCallback.onInstallEnded(uri, CANT_READ_ARCHIVE);
else
callback.onInstallEnded(uri, DOWNLOAD_ERROR);
aCallback.onInstallEnded(uri, DOWNLOAD_ERROR);
},
onInstallFailed: function(install, error) {
callback.onInstallEnded(uri, EXECUTION_ERROR);
onInstallFailed: function(aInstall, aError) {
aCallback.onInstallEnded(uri, EXECUTION_ERROR);
},
onInstallEnded: function(install, status) {
callback.onInstallEnded(uri, SUCCESS);
onInstallEnded: function(aInstall, aStatus) {
aCallback.onInstallEnded(uri, SUCCESS);
}
});
}
}
else if (callback) {
callback.callback(uri, UNSUPPORTED_TYPE);
else if (aCallback) {
aCallback.onInstallEnded(uri, UNSUPPORTED_TYPE);
}
buildNextInstall();
}, mimetype, hashes.shift(), names.shift(), icons.shift(), null, loadGroup);
}, aMimetype, aHashes.shift(), aNames.shift(), aIcons.shift(), null, loadGroup);
}
buildNextInstall();
return retval;
},
notify: function AMC_notify(timer) {
notify: function AMC_notify(aTimer) {
AddonManagerPrivate.backgroundUpdateCheck();
},
@ -173,13 +173,13 @@ amManager.prototype = {
"getService,addon-background-update-timer," +
PREF_EM_UPDATE_INTERVAL + ",86400" }],
_xpcom_factory: {
createInstance: function(outer, iid) {
if (outer != null)
createInstance: function(aOuter, aIid) {
if (aOuter != null)
throw Cr.NS_ERROR_NO_AGGREGATION;
if (!gSingleton)
gSingleton = new amManager();
return gSingleton.QueryInterface(iid);
return gSingleton.QueryInterface(aIid);
}
},
QueryInterface: XPCOMUtils.generateQI([Ci.amIWebInstaller,
@ -187,5 +187,5 @@ amManager.prototype = {
Ci.nsIObserver])
};
function NSGetModule(compMgr, fileSpec)
function NSGetModule(aCompMgr, aFileSpec)
XPCOMUtils.generateModule([amManager]);

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

@ -52,38 +52,40 @@ amContentHandler.prototype = {
/**
* Handles a new request for an application/x-xpinstall file.
*
* @param mimetype
* The mimetype of the file
* @param context
* The context passed to nsIChannel.asyncOpen
* @param aMimetype
* The mimetype of the file
* @param aContext
* The context passed to nsIChannel.asyncOpen
* @param aRequest
* The nsIRequest dealing with the content
*/
handleContent: function XCH_handleContent(mimetype, context, request) {
if (mimetype != XPI_CONTENT_TYPE)
handleContent: function XCH_handleContent(aMimetype, aContext, aRequest) {
if (aMimetype != XPI_CONTENT_TYPE)
throw Cr.NS_ERROR_WONT_HANDLE_CONTENT;
if (!(request instanceof Ci.nsIChannel))
if (!(aRequest instanceof Ci.nsIChannel))
throw Cr.NS_ERROR_WONT_HANDLE_CONTENT;
let uri = request.URI;
let uri = aRequest.URI;
let referer = null;
if (request instanceof Ci.nsIPropertyBag2) {
referer = request.getPropertyAsInterface("docshell.internalReferrer",
Ci.nsIURI);
if (aRequest instanceof Ci.nsIPropertyBag2) {
referer = aRequest.getPropertyAsInterface("docshell.internalReferrer",
Ci.nsIURI);
}
let window = null;
let callbacks = request.notificationCallbacks ?
request.notificationCallbacks :
request.loadGroup.notificationCallbacks;
let callbacks = aRequest.notificationCallbacks ?
aRequest.notificationCallbacks :
aRequest.loadGroup.notificationCallbacks;
if (callbacks)
window = callbacks.getInterface(Ci.nsIDOMWindow);
request.cancel(Cr.NS_BINDING_ABORTED);
aRequest.cancel(Cr.NS_BINDING_ABORTED);
let manager = Cc["@mozilla.org/addons/integration;1"].
getService(Ci.amIWebInstaller);
manager.installAddonsFromWebpage(mimetype, window, referer, [uri.spec],
manager.installAddonsFromWebpage(aMimetype, window, referer, [uri.spec],
[null], [null], [null], null, 1);
},

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

@ -48,12 +48,13 @@ interface amIInstallCallback : nsISupports
{
/**
* Called when an install completes or fails.
* @param url
* The url of the add-on being installed
* @param status
* 0 if the install was successful or negative if not
*
* @param aUrl
* The url of the add-on being installed
* @param aStatus
* 0 if the install was successful or negative if not
*/
void onInstallEnded(in AString url, in PRInt32 status);
void onInstallEnded(in AString aUrl, in PRInt32 aStatus);
};
/**
@ -84,43 +85,43 @@ interface amIInstallTrigger : nsISupports
/**
* Starts a new installation of a set of add-ons.
*
* @param args
* The add-ons to install. This should be a JS object, each property
* is the name of an add-on to be installed. The value of the
* property should either be a string URL, or an object with the
* following properties:
* * URL for the add-on's URL
* * IconURL for an icon for the add-on
* * Hash for a hash of the add-on
* @param callback
* A callback to call as each installation succeeds or fails
* @return true if the installations were successfully started
* @param aArgs
* The add-ons to install. This should be a JS object, each property
* is the name of an add-on to be installed. The value of the
* property should either be a string URL, or an object with the
* following properties:
* * URL for the add-on's URL
* * IconURL for an icon for the add-on
* * Hash for a hash of the add-on
* @param aCallback
* A callback to call as each installation succeeds or fails
* @return true if the installations were successfully started
*/
boolean install(in nsIVariant args, [optional] in amIInstallCallback callback);
boolean install(in nsIVariant aArgs, [optional] in amIInstallCallback aCallback);
/**
* Starts installing a new add-on. This method is deprecated, please use
* "install" in the future.
*
* @param type
* Unused, retained for backwards compatibility
* @param url
* The URL of the add-on
* @param skin
* Unused, retained for backwards compatibility
* @return true if the installation was successfully started
* @param aType
* Unused, retained for backwards compatibility
* @param aUrl
* The URL of the add-on
* @param aSkin
* Unused, retained for backwards compatibility
* @return true if the installation was successfully started
*/
boolean installChrome(in PRUint32 type, in AString url, in AString skin);
boolean installChrome(in PRUint32 aType, in AString aUrl, in AString aSkin);
/**
* Starts installing a new add-on. This method is deprecated, please use
* "install" in the future.
*
* @param url
* The URL of the add-on
* @param flags
* Unused, retained for backwards compatibility
* @return true if the installation was successfully started
* @param aUrl
* The URL of the add-on
* @param aFlags
* Unused, retained for backwards compatibility
* @return true if the installation was successfully started
*/
boolean startSoftwareUpdate(in AString url, [optional] in PRInt32 flags);
boolean startSoftwareUpdate(in AString aUrl, [optional] in PRInt32 aFlags);
};

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

@ -72,34 +72,34 @@ interface amIWebInstallListener : nsISupports
* Called when the website is not allowed to directly prompt the user to
* install add-ons.
*
* @param window
* The window that triggered the installs
* @param uri
* The URI of the site that triggered the installs
* @param installs
* The AddonInstalls that were blocked
* @param count
* The number of AddonInstalls
* @return true if the caller should start the installs
* @param aWindow
* The window that triggered the installs
* @param aUri
* The URI of the site that triggered the installs
* @param aInstalls
* The AddonInstalls that were blocked
* @param aCount
* The number of AddonInstalls
* @return true if the caller should start the installs
*/
boolean onWebInstallBlocked(in nsIDOMWindowInternal window, in nsIURI uri,
[array, size_is(count)] in nsIVariant installs,
[optional] in PRUint32 count);
boolean onWebInstallBlocked(in nsIDOMWindowInternal aWindow, in nsIURI aUri,
[array, size_is(aCount)] in nsIVariant aInstalls,
[optional] in PRUint32 aCount);
/**
* Called when a website wants to ask the user to install add-ons.
*
* @param window
* The window that triggered the installs
* @param uri
* The URI of the site that triggered the installs
* @param installs
* The AddonInstalls that were requested
* @param count
* The number of AddonInstalls
* @return true if the caller should start the installs
* @param aWindow
* The window that triggered the installs
* @param aUri
* The URI of the site that triggered the installs
* @param aInstalls
* The AddonInstalls that were requested
* @param aCount
* The number of AddonInstalls
* @return true if the caller should start the installs
*/
boolean onWebInstallRequested(in nsIDOMWindowInternal window, in nsIURI uri,
[array, size_is(count)] in nsIVariant installs,
[optional] in PRUint32 count);
boolean onWebInstallRequested(in nsIDOMWindowInternal aWindow, in nsIURI aUri,
[array, size_is(aCount)] in nsIVariant aInstalls,
[optional] in PRUint32 aCount);
};

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

@ -51,45 +51,45 @@ interface amIWebInstaller : nsISupports
/**
* Checks if installation is enabled for a webpage.
*
* @param mimetype
* The mimetype for the add-on to be installed
* @param referer
* The URL of the webpage trying to install an add-on
* @return true if installation is enabled
* @param aMimetype
* The mimetype for the add-on to be installed
* @param referer
* The URL of the webpage trying to install an add-on
* @return true if installation is enabled
*/
boolean isInstallEnabled(in AString mimetype, in nsIURI referer);
boolean isInstallEnabled(in AString aMimetype, in nsIURI aReferer);
/**
* Installs an array of add-ons at the request of a webpage
*
* @param mimetype
* The mimetype for the add-ons
* @param window
* The window installing the add-ons
* @param referer
* The URI for the webpage installing the add-ons
* @param uris
* The URIs of add-ons to be installed
* @param hashes
* The hashes for the add-ons to be installed
* @param names
* The names for the add-ons to be installed
* @param icons
* The icons for the add-ons to be installed
* @param callback
* An optional callback to notify about installation success and
* failure
* @param installCount
* An optional argument including the number of add-ons to install
* @return true if the installation was successfully started
* @param aMimetype
* The mimetype for the add-ons
* @param aWindow
* The window installing the add-ons
* @param aReferer
* The URI for the webpage installing the add-ons
* @param aUris
* The URIs of add-ons to be installed
* @param aHashes
* The hashes for the add-ons to be installed
* @param aNames
* The names for the add-ons to be installed
* @param aIcons
* The icons for the add-ons to be installed
* @param aCallback
* An optional callback to notify about installation success and
* failure
* @param aInstallCount
* An optional argument including the number of add-ons to install
* @return true if the installation was successfully started
*/
boolean installAddonsFromWebpage(in AString mimetype,
in nsIDOMWindowInternal window,
in nsIURI referer,
[array, size_is(installCount)] in wstring uris,
[array, size_is(installCount)] in wstring hashes,
[array, size_is(installCount)] in wstring names,
[array, size_is(installCount)] in wstring icons,
[optional] in amIInstallCallback callback,
[optional] in PRUint32 installCount);
boolean installAddonsFromWebpage(in AString aMimetype,
in nsIDOMWindowInternal aWindow,
in nsIURI aReferer,
[array, size_is(aInstallCount)] in wstring aUris,
[array, size_is(aInstallCount)] in wstring aHashes,
[array, size_is(aInstallCount)] in wstring aNames,
[array, size_is(aInstallCount)] in wstring aIcons,
[optional] in amIInstallCallback aCallback,
[optional] in PRUint32 aInstallCount);
};

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

@ -56,7 +56,7 @@
// Helper function for URI verification
//
static nsresult
CheckLoadURIFromScript(JSContext *cx, const nsACString& uriStr)
CheckLoadURIFromScript(JSContext *aCx, const nsACString& aUriStr)
{
nsresult rv;
nsCOMPtr<nsIScriptSecurityManager> secman(do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv));
@ -73,7 +73,7 @@ CheckLoadURIFromScript(JSContext *cx, const nsACString& uriStr)
// Note that we use a null base URI here, since that's what we use when we
// actually convert the string into a URI to load.
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), uriStr);
rv = NS_NewURI(getter_AddRefs(uri), aUriStr);
NS_ENSURE_SUCCESS(rv, rv);
// are we allowed to load this one?
@ -114,10 +114,10 @@ amInstallTrigger::GetJSContext()
}
already_AddRefed<nsIDOMWindowInternal>
amInstallTrigger::GetOriginatingWindow(JSContext* cx)
amInstallTrigger::GetOriginatingWindow(JSContext* aCx)
{
nsIScriptGlobalObject *globalObject = nsnull;
nsIScriptContext *scriptContext = GetScriptContextFromJSContext(cx);
nsIScriptContext *scriptContext = GetScriptContextFromJSContext(aCx);
if (!scriptContext)
return nsnull;
@ -162,8 +162,8 @@ amInstallTrigger::Enabled(PRBool *_retval NS_OUTPARAM)
/* boolean install (in nsIVariant args, [optional] in amIInstallCallback callback); */
NS_IMETHODIMP
amInstallTrigger::Install(nsIVariant *args,
amIInstallCallback *callback,
amInstallTrigger::Install(nsIVariant *aArgs,
amIInstallCallback *aCallback,
PRBool *_retval NS_OUTPARAM)
{
JSContext *cx = GetJSContext();
@ -171,7 +171,7 @@ amInstallTrigger::Install(nsIVariant *args,
nsCOMPtr<nsIURI> referer = GetOriginatingURI(window);
jsval params;
nsresult rv = args->GetAsJSVal(&params);
nsresult rv = aArgs->GetAsJSVal(&params);
NS_ENSURE_SUCCESS(rv, rv);
if (!JSVAL_IS_OBJECT(params) || !JSVAL_TO_OBJECT(params))
@ -287,7 +287,7 @@ amInstallTrigger::Install(nsIVariant *args,
rv = mManager->InstallAddonsFromWebpage(NS_LITERAL_STRING("application/x-xpinstall"),
window, referer, uris.Elements(),
hashes.Elements(), names.Elements(),
icons.Elements(), callback, count,
icons.Elements(), aCallback, count,
_retval);
for (PRUint32 i = 0; i < uris.Length(); i++) {
@ -301,18 +301,18 @@ amInstallTrigger::Install(nsIVariant *args,
/* boolean installChrome (in PRUint32 type, in AString url, in AString skin); */
NS_IMETHODIMP
amInstallTrigger::InstallChrome(PRUint32 type,
const nsAString & url,
const nsAString & skin,
amInstallTrigger::InstallChrome(PRUint32 aType,
const nsAString & aUrl,
const nsAString & aSkin,
PRBool *_retval NS_OUTPARAM)
{
return StartSoftwareUpdate(url, 0, _retval);
return StartSoftwareUpdate(aUrl, 0, _retval);
}
/* boolean startSoftwareUpdate (in AString url, [optional] in PRInt32 flags); */
NS_IMETHODIMP
amInstallTrigger::StartSoftwareUpdate(const nsAString & url,
PRInt32 flags,
amInstallTrigger::StartSoftwareUpdate(const nsAString & aUrl,
PRInt32 aFlags,
PRBool *_retval NS_OUTPARAM)
{
nsresult rv;
@ -326,7 +326,7 @@ amInstallTrigger::StartSoftwareUpdate(const nsAString & url,
nsTArray<const PRUnichar*> icons;
nsTArray<const PRUnichar*> hashes;
nsCString tmpURI = NS_ConvertUTF16toUTF8(url);
nsCString tmpURI = NS_ConvertUTF16toUTF8(aUrl);
// Get relative URL to load
if (referer) {
rv = referer->Resolve(tmpURI, tmpURI);
@ -357,9 +357,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(amInstallTrigger)
static NS_METHOD
RegisterInstallTrigger(nsIComponentManager *aCompMgr,
nsIFile *aPath,
const char *registryLocation,
const char *componentType,
const nsModuleComponentInfo *info)
const char *aRegistryLocation,
const char *aComponentType,
const nsModuleComponentInfo *aInfo)
{
nsresult rv = NS_OK;

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

@ -58,7 +58,7 @@ private:
~amInstallTrigger();
JSContext* GetJSContext();
already_AddRefed<nsIDOMWindowInternal> GetOriginatingWindow(JSContext* cx);
already_AddRefed<nsIDOMWindowInternal> GetOriginatingWindow(JSContext* aCx);
already_AddRefed<nsIURI> GetOriginatingURI(nsIDOMWindowInternal* aWindow);
nsCOMPtr<amIWebInstaller> mManager;

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

@ -55,43 +55,43 @@ Components.utils.import("resource://gre/modules/Services.jsm");
/**
* Logs a warning message
*
* @param str
* The string to log
* @param aStr
* The string to log
*/
function WARN(str) {
dump("*** addons.weblistener: " + str + "\n");
function WARN(aStr) {
dump("*** addons.weblistener: " + aStr + "\n");
}
/**
* Creates a new installer to monitor downloads and prompt to install when
* ready
*
* @param window
* The window that started the installations
* @param url
* The URL that started the installations
* @installs installs
* An array of AddonInstalls
* @param aWindow
* The window that started the installations
* @param aUrl
* The URL that started the installations
* @param aInstalls
* An array of AddonInstalls
*/
function Installer(window, url, installs) {
this.window = window;
this.url = url;
this.downloads = installs;
function Installer(aWindow, aUrl, aInstalls) {
this.window = aWindow;
this.url = aUrl;
this.downloads = aInstalls;
this.installs = [];
this.bundle = Cc["@mozilla.org/intl/stringbundle;1"].
getService(Ci.nsIStringBundleService).
createBundle("chrome://mozapps/locale/extensions/extensions.properties");
this.count = installs.length;
installs.forEach(function(install) {
install.addListener(this);
this.count = aInstalls.length;
aInstalls.forEach(function(aInstall) {
aInstall.addListener(this);
// Might already be a local file
if (install.state == AddonManager.STATE_DOWNLOADED)
this.onDownloadEnded(install);
if (aInstall.state == AddonManager.STATE_DOWNLOADED)
this.onDownloadEnded(aInstall);
else
install.install();
aInstall.install();
}, this);
}
@ -121,54 +121,54 @@ Installer.prototype = {
null, "chrome,modal,centerscreen", args);
},
onDownloadCancelled: function(install) {
install.removeListener(this);
onDownloadCancelled: function(aInstall) {
aInstall.removeListener(this);
this.checkAllDownloaded();
},
onDownloadFailed: function(install, error) {
install.removeListener(this);
onDownloadFailed: function(aInstall, aError) {
aInstall.removeListener(this);
// TODO show some better error
Services.prompt.alert(this.window, "Download Failed", "The download of " + install.sourceURL + " failed: " + error);
Services.prompt.alert(this.window, "Download Failed", "The download of " + aInstall.sourceURL + " failed: " + aError);
this.checkAllDownloaded();
},
onDownloadEnded: function(install) {
install.removeListener(this);
onDownloadEnded: function(aInstall) {
aInstall.removeListener(this);
if (install.addon.appDisabled) {
if (aInstall.addon.appDisabled) {
// App disabled items are not compatible
install.cancel();
aInstall.cancel();
let title = null;
let text = null;
let problems = "";
if (!install.addon.isCompatible)
if (!aInstall.addon.isCompatible)
problems += "incompatible, ";
if (!install.addon.providesUpdatesSecurely)
if (!aInstall.addon.providesUpdatesSecurely)
problems += "insecure updates, ";
if (install.addon.blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED) {
if (aInstall.addon.blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED) {
problems += "blocklisted, ";
title = bundle.GetStringFromName("blocklistedInstallTitle2");
text = this.bundle.formatStringFromName("blocklistedInstallMsg2",
[install.addon.name], 1);
}
problems = problems.substring(0, problems.length - 2);
WARN("Not installing " + install.addon.id + " because of the following: " + problems);
WARN("Not installing " + aInstall.addon.id + " because of the following: " + problems);
title = this.bundle.GetStringFromName("incompatibleTitle2", 1);
text = this.bundle.formatStringFromName("incompatibleMessage",
[install.addon.name,
install.addon.version,
[aInstall.addon.name,
aInstall.addon.version,
Services.appinfo.name,
Services.appinfo.version], 4);
Services.prompt.alert(this.window, title, text);
}
else {
this.installs.push(install);
this.installs.push(aInstall);
}
this.checkAllDownloaded();
@ -183,11 +183,11 @@ extWebInstallListener.prototype = {
/**
* @see amIWebInstallListener.idl
*/
onWebInstallBlocked: function(window, uri, installs) {
onWebInstallBlocked: function(aWindow, aUri, aInstalls) {
let info = {
originatingWindow: window,
originatingURI: uri,
installs: installs,
originatingWindow: aWindow,
originatingURI: aUri,
installs: aInstalls,
install: function() {
dump("Start installs\n");
@ -204,8 +204,8 @@ extWebInstallListener.prototype = {
/**
* @see amIWebInstallListener.idl
*/
onWebInstallRequested: function(window, uri, installs) {
new Installer(window, uri, installs);
onWebInstallRequested: function(aWindow, aUri, aInstalls) {
new Installer(aWindow, aUri, aInstalls);
// We start the installs ourself
return false;
@ -217,5 +217,5 @@ extWebInstallListener.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.amIWebInstallListener])
};
function NSGetModule(compMgr, fileSpec)
function NSGetModule(aCompMgr, aFileSpec)
XPCOMUtils.generateModule([extWebInstallListener]);

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

@ -66,12 +66,12 @@ function createAppInfo(id, name, version, platformVersion) {
* Tests that an add-on does appear in the crash report annotations, if
* crash reporting is enabled. The test will fail if the add-on is not in the
* annotation.
* @param id
* The ID of the add-on
* @param version
* The version of the add-on
* @param aId
* The ID of the add-on
* @param aVersion
* The version of the add-on
*/
function do_check_in_crash_annotation(id, version) {
function do_check_in_crash_annotation(aId, aVersion) {
if (!("nsICrashReporter" in AM_Ci))
return;
@ -81,19 +81,19 @@ function do_check_in_crash_annotation(id, version) {
}
let addons = gAppInfo.annotations["Add-ons"].split(",");
do_check_false(addons.indexOf(id + ":" + version) < 0);
do_check_false(addons.indexOf(aId + ":" + aVersion) < 0);
}
/**
* Tests that an add-on does not appear in the crash report annotations, if
* crash reporting is enabled. The test will fail if the add-on is in the
* annotation.
* @param id
* The ID of the add-on
* @param version
* The version of the add-on
* @param aId
* The ID of the add-on
* @param aVersion
* The version of the add-on
*/
function do_check_not_in_crash_annotation(id, version) {
function do_check_not_in_crash_annotation(aId, aVersion) {
if (!("nsICrashReporter" in AM_Ci))
return;
@ -103,42 +103,42 @@ function do_check_not_in_crash_annotation(id, version) {
}
let addons = gAppInfo.annotations["Add-ons"].split(",");
do_check_true(addons.indexOf(id + ":" + version) < 0);
do_check_true(addons.indexOf(aId + ":" + aVersion) < 0);
}
/**
* Returns a testcase xpi
*
* @param name
* The name of the testcase (without extension)
* @return an nsILocalFile pointing to the testcase xpi
* @param aName
* The name of the testcase (without extension)
* @return an nsILocalFile pointing to the testcase xpi
*/
function do_get_addon(name) {
return do_get_file("addons/" + name + ".xpi");
function do_get_addon(aName) {
return do_get_file("addons/" + aName + ".xpi");
}
/**
* Starts up the add-on manager as if it was started by the application. This
* will simulate any restarts requested by the manager.
*
* @param expectedRestarts
* An optional parameter to specify the expected number of restarts.
* If passed and the number of restarts requested differs then the
* test will fail
* @param appChanged
* An optional boolean parameter to simulate the case where the
* application has changed version since the last run. If not passed it
* defaults to true
* @param aExpectedRestarts
* An optional parameter to specify the expected number of restarts.
* If passed and the number of restarts requested differs then the
* test will fail
* @param aAppChanged
* An optional boolean parameter to simulate the case where the
* application has changed version since the last run. If not passed it
* defaults to true
*/
function startupManager(expectedRestarts, appChanged) {
function startupManager(aExpectedRestarts, aAppChanged) {
if (gInternalManager)
do_throw("Test attempt to startup manager that was already started.");
if (appChanged === undefined)
appChanged = true;
if (aAppChanged === undefined)
aAppChanged = true;
// Load the add-ons list as it was during application startup
loadAddonsList(appChanged);
loadAddonsList(aAppChanged);
gInternalManager = AM_Cc["@mozilla.org/addons/integration;1"].
getService(AM_Ci.nsIObserver).
@ -148,20 +148,20 @@ function startupManager(expectedRestarts, appChanged) {
let appStartup = AM_Cc["@mozilla.org/toolkit/app-startup;1"].
getService(AM_Ci.nsIAppStartup2);
var restart = appChanged || appStartup.needsRestart;
var restart = aAppChanged || appStartup.needsRestart;
appStartup.needsRestart = false;
if (restart) {
if (expectedRestarts !== undefined)
restartManager(expectedRestarts - 1);
if (aExpectedRestarts !== undefined)
restartManager(aExpectedRestarts - 1);
else
restartManager();
}
else if (expectedRestarts !== undefined) {
if (expectedRestarts > 0)
do_throw("Expected to need to restart " + expectedRestarts + " more times");
else if (expectedRestarts < 0)
do_throw("Restarted " + (-expectedRestarts) + " more times than expected");
else if (aExpectedRestarts !== undefined) {
if (aExpectedRestarts > 0)
do_throw("Expected to need to restart " + aExpectedRestarts + " more times");
else if (aExpectedRestarts < 0)
do_throw("Restarted " + (-aExpectedRestarts) + " more times than expected");
}
}
@ -169,23 +169,23 @@ function startupManager(expectedRestarts, appChanged) {
* Restarts the add-on manager as if the host application was restarted. This
* will simulate any restarts requested by the manager.
*
* @param expectedRestarts
* An optional parameter to specify the expected number of restarts.
* If passed and the number of restarts requested differs then the
* test will fail
* @param newVersion
* An optional new version to use for the application. Passing this
* will change nsIXULAppInfo.version and make the startup appear as if
* the application version has changed.
* @param aExpectedRestarts
* An optional parameter to specify the expected number of restarts.
* If passed and the number of restarts requested differs then the
* test will fail
* @param aNewVersion
* An optional new version to use for the application. Passing this
* will change nsIXULAppInfo.version and make the startup appear as if
* the application version has changed.
*/
function restartManager(expectedRestarts, newVersion) {
function restartManager(aExpectedRestarts, aNewVersion) {
shutdownManager();
if (newVersion) {
gAppInfo.version = newVersion;
startupManager(expectedRestarts, true);
if (aNewVersion) {
gAppInfo.version = aNewVersion;
startupManager(aExpectedRestarts, true);
}
else {
startupManager(expectedRestarts, false);
startupManager(aExpectedRestarts, false);
}
}
@ -203,12 +203,12 @@ function shutdownManager() {
gAppInfo.annotations = {};
}
function loadAddonsList(appChanged) {
function readDirectories(section) {
function loadAddonsList(aAppChanged) {
function readDirectories(aSection) {
var dirs = [];
var keys = parser.getKeys(section);
var keys = parser.getKeys(aSection);
while (keys.hasMore()) {
let descriptor = parser.getString(section, keys.getNext());
let descriptor = parser.getString(aSection, keys.getNext());
try {
let file = AM_Cc["@mozilla.org/file/local;1"].
createInstance(AM_Ci.nsILocalFile);
@ -232,7 +232,7 @@ function loadAddonsList(appChanged) {
file.append("extensions.ini");
if (!file.exists())
return;
if (appChanged) {
if (aAppChanged) {
file.remove(true);
return;
}
@ -244,22 +244,22 @@ function loadAddonsList(appChanged) {
gAddonsList.themes = readDirectories("ThemeDirs");
}
function isItemInAddonsList(type, dir, id) {
var path = dir.clone();
path.append(id);
for (var i = 0; i < gAddonsList[type].length; i++) {
if (gAddonsList[type][i].equals(path))
function isItemInAddonsList(aType, aDir, aId) {
var path = aDir.clone();
path.append(aId);
for (var i = 0; i < gAddonsList[aType].length; i++) {
if (gAddonsList[aType][i].equals(path))
return true;
}
return false;
}
function isThemeInAddonsList(dir, id) {
return isItemInAddonsList("themes", dir, id);
function isThemeInAddonsList(aDir, aId) {
return isItemInAddonsList("themes", aDir, aId);
}
function isExtensionInAddonsList(dir, id) {
return isItemInAddonsList("extensions", dir, id);
function isExtensionInAddonsList(aDir, aId) {
return isItemInAddonsList("extensions", aDir, aId);
}
/**
@ -269,25 +269,25 @@ function isExtensionInAddonsList(dir, id) {
* The string to escape
* @return The escaped string
*/
function escapeXML(str) {
return str.toString()
.replace(/&/g, "&amp;")
.replace(/"/g, "&quot;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;");
function escapeXML(aStr) {
return aStr.toString()
.replace(/&/g, "&amp;")
.replace(/"/g, "&quot;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;");
}
function writeLocaleStrings(data) {
function writeLocaleStrings(aData) {
let rdf = "";
["name", "description", "creator", "homepageURL"].forEach(function(prop) {
if (prop in data)
rdf += "<em:" + prop + ">" + escapeXML(data[prop]) + "</em:" + prop + ">\n";
["name", "description", "creator", "homepageURL"].forEach(function(aProp) {
if (aProp in aData)
rdf += "<em:" + aProp + ">" + escapeXML(aData[aProp]) + "</em:" + aProp + ">\n";
});
["developer", "translator", "contributor"].forEach(function(prop) {
if (prop in data) {
data[prop].forEach(function(value) {
rdf += "<em:" + prop + ">" + escapeXML(value) + "</em:" + prop + ">\n";
["developer", "translator", "contributor"].forEach(function(aProp) {
if (aProp in aData) {
aData[aProp].forEach(function(aValue) {
rdf += "<em:" + aProp + ">" + escapeXML(aValue) + "</em:" + aProp + ">\n";
});
}
});
@ -301,31 +301,31 @@ function writeLocaleStrings(data) {
* minVersion and maxVersion in the targetApplications property to give target
* application compatibility.
*
* @param data
* @param aData
* The object holding data about the add-on
* @param dir
* @param aDir
* The directory to add the install.rdf to
*/
function writeInstallRDFToDir(data, dir) {
function writeInstallRDFToDir(aData, aDir) {
var rdf = '<?xml version="1.0"?>\n';
rdf += '<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n' +
' xmlns:em="http://www.mozilla.org/2004/em-rdf#">\n';
rdf += '<Description about="urn:mozilla:install-manifest">\n';
["id", "version", "type", "internalName", "updateURL", "updateKey",
"optionsURL", "aboutURL", "iconURL"].forEach(function(prop) {
if (prop in data)
rdf += "<em:" + prop + ">" + escapeXML(data[prop]) + "</em:" + prop + ">\n";
"optionsURL", "aboutURL", "iconURL"].forEach(function(aProp) {
if (aProp in aData)
rdf += "<em:" + aProp + ">" + escapeXML(aData[aProp]) + "</em:" + aProp + ">\n";
});
rdf += writeLocaleStrings(data);
rdf += writeLocaleStrings(aData);
if ("targetApplications" in data) {
data.targetApplications.forEach(function(app) {
if ("targetApplications" in aData) {
aData.targetApplications.forEach(function(aApp) {
rdf += "<em:targetApplication><Description>\n";
["id", "minVersion", "maxVersion"].forEach(function(prop) {
if (prop in app)
rdf += "<em:" + prop + ">" + escapeXML(app[prop]) + "</em:" + prop + ">\n";
["id", "minVersion", "maxVersion"].forEach(function(aProp) {
if (aProp in aApp)
rdf += "<em:" + aProp + ">" + escapeXML(aApp[aProp]) + "</em:" + aProp + ">\n";
});
rdf += "</Description></em:targetApplication>\n";
});
@ -333,9 +333,9 @@ function writeInstallRDFToDir(data, dir) {
rdf += "</Description>\n</RDF>\n";
if (!dir.exists())
dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
var file = dir.clone();
if (!aDir.exists())
aDir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
var file = aDir.clone();
file.append("install.rdf");
if (file.exists())
file.remove(true);
@ -348,12 +348,12 @@ function writeInstallRDFToDir(data, dir) {
fos.close();
}
function registerDirectory(key, dir) {
function registerDirectory(aKey, aDir) {
var dirProvider = {
getFile: function(prop, persistent) {
persistent.value = true;
if (prop == key)
return dir.clone();
getFile: function(aProp, aPersistent) {
aPersistent.value = true;
if (aProp == aKey)
return aDir.clone();
return null;
},
@ -367,84 +367,84 @@ var gExpectedEvents = {};
var gExpectedInstalls = [];
var gNext = null;
function getExpectedEvent(id) {
if (!(id in gExpectedEvents))
do_throw("Wasn't expecting events for " + id);
if (gExpectedEvents[id].length == 0)
do_throw("Too many events for " + id);
let event = gExpectedEvents[id].shift();
function getExpectedEvent(aId) {
if (!(aId in gExpectedEvents))
do_throw("Wasn't expecting events for " + aId);
if (gExpectedEvents[aId].length == 0)
do_throw("Too many events for " + aId);
let event = gExpectedEvents[aId].shift();
if (event instanceof Array)
return event;
return [event, true];
}
const AddonListener = {
onEnabling: function(addon, requiresRestart) {
let [event, expectedRestart] = getExpectedEvent(addon.id);
onEnabling: function(aAddon, aRequiresRestart) {
let [event, expectedRestart] = getExpectedEvent(aAddon.id);
do_check_eq("onEnabling", event);
do_check_eq(requiresRestart, expectedRestart);
do_check_eq(aRequiresRestart, expectedRestart);
if (expectedRestart)
do_check_true(hasFlag(addon.pendingOperations, AddonManager.PENDING_ENABLE));
do_check_false(hasFlag(addon.permissions, AddonManager.PERM_CAN_ENABLE));
do_check_true(hasFlag(aAddon.pendingOperations, AddonManager.PENDING_ENABLE));
do_check_false(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_ENABLE));
return check_test_completed(arguments);
},
onEnabled: function(addon) {
let [event, expectedRestart] = getExpectedEvent(addon.id);
onEnabled: function(aAddon) {
let [event, expectedRestart] = getExpectedEvent(aAddon.id);
do_check_eq("onEnabled", event);
do_check_false(hasFlag(addon.permissions, AddonManager.PERM_CAN_ENABLE));
do_check_false(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_ENABLE));
return check_test_completed(arguments);
},
onDisabling: function(addon, requiresRestart) {
let [event, expectedRestart] = getExpectedEvent(addon.id);
onDisabling: function(aAddon, aRequiresRestart) {
let [event, expectedRestart] = getExpectedEvent(aAddon.id);
do_check_eq("onDisabling", event);
do_check_eq(requiresRestart, expectedRestart);
do_check_eq(aRequiresRestart, expectedRestart);
if (expectedRestart)
do_check_true(hasFlag(addon.pendingOperations, AddonManager.PENDING_DISABLE));
do_check_false(hasFlag(addon.permissions, AddonManager.PERM_CAN_DISABLE));
do_check_true(hasFlag(aAddon.pendingOperations, AddonManager.PENDING_DISABLE));
do_check_false(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_DISABLE));
return check_test_completed(arguments);
},
onDisabled: function(addon) {
let [event, expectedRestart] = getExpectedEvent(addon.id);
onDisabled: function(aAddon) {
let [event, expectedRestart] = getExpectedEvent(aAddon.id);
do_check_eq("onDisabled", event);
do_check_false(hasFlag(addon.permissions, AddonManager.PERM_CAN_DISABLE));
do_check_false(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_DISABLE));
return check_test_completed(arguments);
},
onInstalling: function(addon, requiresRestart) {
let [event, expectedRestart] = getExpectedEvent(addon.id);
onInstalling: function(aAddon, aRequiresRestart) {
let [event, expectedRestart] = getExpectedEvent(aAddon.id);
do_check_eq("onInstalling", event);
do_check_eq(requiresRestart, expectedRestart);
do_check_eq(aRequiresRestart, expectedRestart);
if (expectedRestart)
do_check_true(hasFlag(addon.pendingOperations, AddonManager.PENDING_INSTALL));
do_check_true(hasFlag(aAddon.pendingOperations, AddonManager.PENDING_INSTALL));
return check_test_completed(arguments);
},
onInstalled: function(addon) {
let [event, expectedRestart] = getExpectedEvent(addon.id);
onInstalled: function(aAddon) {
let [event, expectedRestart] = getExpectedEvent(aAddon.id);
do_check_eq("onInstalled", event);
return check_test_completed(arguments);
},
onUninstalling: function(addon, requiresRestart) {
let [event, expectedRestart] = getExpectedEvent(addon.id);
onUninstalling: function(aAddon, aRequiresRestart) {
let [event, expectedRestart] = getExpectedEvent(aAddon.id);
do_check_eq("onUninstalling", event);
do_check_eq(requiresRestart, expectedRestart);
do_check_eq(aRequiresRestart, expectedRestart);
if (expectedRestart)
do_check_true(hasFlag(addon.pendingOperations, AddonManager.PENDING_UNINSTALL));
do_check_true(hasFlag(aAddon.pendingOperations, AddonManager.PENDING_UNINSTALL));
return check_test_completed(arguments);
},
onUninstalled: function(addon) {
let [event, expectedRestart] = getExpectedEvent(addon.id);
onUninstalled: function(aAddon) {
let [event, expectedRestart] = getExpectedEvent(aAddon.id);
do_check_eq("onUninstalled", event);
return check_test_completed(arguments);
},
onOperationCancelled: function(addon) {
let [event, expectedRestart] = getExpectedEvent(addon.id);
onOperationCancelled: function(aAddon) {
let [event, expectedRestart] = getExpectedEvent(aAddon.id);
do_check_eq("onOperationCancelled", event);
return check_test_completed(arguments);
}
@ -507,29 +507,29 @@ const InstallListener = {
return check_test_completed(arguments);
},
onExternalInstall: function(addon, existingAddon, requiresRestart) {
onExternalInstall: function(aAddon, existingAddon, aRequiresRestart) {
do_check_eq("onExternalInstall", gExpectedInstalls.shift());
do_check_false(requiresRestart);
do_check_false(aRequiresRestart);
return check_test_completed(arguments);
}
};
function hasFlag(bits, flag) {
return (bits & flag) != 0;
function hasFlag(aBits, aFlag) {
return (aBits & aFlag) != 0;
}
// Just a wrapper around setting the expected events
function prepare_test(expectedEvents, expectedInstalls, next) {
function prepare_test(aExpectedEvents, aExpectedInstalls, aNext) {
AddonManager.addAddonListener(AddonListener);
AddonManager.addInstallListener(InstallListener);
gExpectedInstalls = expectedInstalls;
gExpectedEvents = expectedEvents;
gNext = next;
gExpectedInstalls = aExpectedInstalls;
gExpectedEvents = aExpectedEvents;
gNext = aNext;
}
// Checks if all expected events have been seen and if so calls the callback
function check_test_completed(args) {
function check_test_completed(aArgs) {
if (!gNext)
return;
@ -541,7 +541,7 @@ function check_test_completed(args) {
return;
}
return gNext.apply(null, args);
return gNext.apply(null, aArgs);
}
// Verifies that all the expected events for all add-ons were seen
@ -559,24 +559,24 @@ function ensure_test_completed() {
* A helper method to install an array of AddonInstall to completion and then
* call a provided callback.
*
* @param installs
* @param aInstalls
* The array of AddonInstalls to install
* @param callback
* @param aCallback
* The callback to call when all installs have finished
*/
function completeAllInstalls(installs, callback) {
function completeAllInstalls(aInstalls, aCallback) {
let count = aInstalls.length;
if (count == 0) {
callback();
aCallback();
return;
}
let count = installs.length;
function installCompleted(install) {
install.removeListener(listener);
function installCompleted(aInstall) {
aInstall.removeListener(listener);
if (--count == 0)
callback();
aCallback();
}
let listener = {
@ -587,9 +587,9 @@ function completeAllInstalls(installs, callback) {
onInstallEnded: installCompleted
};
installs.forEach(function(install) {
install.addListener(listener);
install.install();
aInstalls.forEach(function(aInstall) {
aInstall.addListener(listener);
aInstall.install();
});
}
@ -597,28 +597,28 @@ function completeAllInstalls(installs, callback) {
* A helper method to install an array of files and call a callback after the
* installs are completed.
*
* @param files
* @param aFiles
* The array of files to install
* @param callback
* @param aCallback
* The callback to call when all installs have finished
* @param ignoreIncompatible
* @param aIgnoreIncompatible
* Optional parameter to ignore add-ons that are incompatible in
* aome way with the application
*/
function installAllFiles(files, callback, ignoreIncompatible) {
let count = files.length;
function installAllFiles(aFiles, aCallback, aIgnoreIncompatible) {
let count = aFiles.length;
let installs = [];
files.forEach(function(file) {
AddonManager.getInstallForFile(file, function(install) {
if (!install)
do_throw("No AddonInstall created for " + file.path);
aFiles.forEach(function(aFile) {
AddonManager.getInstallForFile(aFile, function(aInstall) {
if (!aInstall)
do_throw("No AddonInstall created for " + aFile.path);
if (!ignoreIncompatible || !install.addon.appDisabled)
installs.push(install);
if (!aIgnoreIncompatible || !aInstall.addon.appDisabled)
installs.push(aInstall);
if (--count == 0)
completeAllInstalls(installs, callback);
completeAllInstalls(installs, aCallback);
});
});
}
@ -628,8 +628,8 @@ if ("nsIWindowsRegKey" in AM_Ci) {
LOCAL_MACHINE: {},
CURRENT_USER: {},
setValue: function(root, path, name, value) {
switch (root) {
setValue: function(aRoot, aPath, aName, aValue) {
switch (aRoot) {
case AM_Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE:
var rootKey = MockRegistry.LOCAL_MACHINE;
break
@ -638,27 +638,27 @@ if ("nsIWindowsRegKey" in AM_Ci) {
break
}
if (!(path in rootKey)) {
rootKey[path] = [];
if (!(aPath in rootKey)) {
rootKey[aPath] = [];
}
else {
for (let i = 0; i < rootKey[path].length; i++) {
if (rootKey[path][i].name == name) {
if (value === null)
rootKey[path].splice(i, 1);
for (let i = 0; i < rootKey[aPath].length; i++) {
if (rootKey[aPath][i].name == aName) {
if (aValue === null)
rootKey[aPath].splice(i, 1);
else
rootKey[path][i].value = value;
rootKey[aPath][i].value = aValue;
return;
}
}
}
if (value === null)
if (aValue === null)
return;
rootKey[path].push({
name: name,
value: value
rootKey[aPath].push({
name: aName,
value: aValue
});
}
};