Bug 1333682 - Don't register form autofill autocomplete if it's already registered. r=MattN
MozReview-Commit-ID: 3x7jGaXLfnF
--- a/browser/extensions/formautofill/content/FormAutofillContent.js
+++ b/browser/extensions/formautofill/content/FormAutofillContent.js
@@ -175,32 +175,38 @@ AutocompleteFactory.prototype = {
register(targetConstructor) {
let proto = targetConstructor.prototype;
this._classID = proto.classID;
let factory = XPCOMUtils._getFactory(targetConstructor);
this._factory = factory;
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
- registrar.registerFactory(proto.classID, proto.classDescription,
- proto.contractID, factory);
+ if (proto.classID && !registrar.isCIDRegistered(proto.classID)) {
+ registrar.registerFactory(proto.classID, proto.classDescription,
+ proto.contractID, factory);
+ }
- if (proto.classID2) {
+ if (proto.classID2 && !registrar.isCIDRegistered(proto.classID2)) {
this._classID2 = proto.classID2;
registrar.registerFactory(proto.classID2, proto.classDescription,
proto.contractID2, factory);
}
},
unregister() {
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
- registrar.unregisterFactory(this._classID, this._factory);
- if (this._classID2) {
+ if (this._classID && registrar.isCIDRegistered(this._classID)) {
+ registrar.unregisterFactory(this._classID, this._factory);
+ }
+
+ if (this._classID2 && registrar.isCIDRegistered(this._classID2)) {
registrar.unregisterFactory(this._classID2, this._factory);
}
+
this._factory = null;
},
};
/**
* @constructor
*