Bug 1458215 - Handle the optional service name in XPCOMUtils.defineLazyServiceGetters. r?kmag
MozReview-Commit-ID: 1Dp6lhQRbNU
--- a/js/xpconnect/loader/XPCOMUtils.jsm
+++ b/js/xpconnect/loader/XPCOMUtils.jsm
@@ -258,28 +258,28 @@ var XPCOMUtils = {
* Defines a lazy service getter on a specified object for each
* property in the given object.
*
* @param aObject
* The object to define the lazy getter on.
* @param aServices
* An object with a property for each service to be
* imported, where the property name is the name of the
- * symbol to define, and the value is a 2-element array
- * containing the contract ID and the interface name of the
- * service, as passed to defineLazyServiceGetter.
+ * symbol to define, and the value is a 1 or 2 element array
+ * containing the contract ID and, optionally, the interface
+ * name of the service, as passed to defineLazyServiceGetter.
*/
defineLazyServiceGetters: function XPCU_defineLazyServiceGetters(
aObject, aServices)
{
for (let [name, service] of Object.entries(aServices)) {
// Note: This is hot code, and cross-compartment array wrappers
// are not JIT-friendly to destructuring or spread operators, so
// we need to use indexed access instead.
- this.defineLazyServiceGetter(aObject, name, service[0], service[1]);
+ this.defineLazyServiceGetter(aObject, name, service[0], service[1] || null);
}
},
/**
* Defines a getter on a specified object for a module. The module will not
* be imported until first use. The getter allows to execute setup and
* teardown code (e.g. to register/unregister to services) and accepts
* a proxy object which acts on behalf of the module until it is imported.