Don't try to register command line handler if already registered

Avoids an error when reiniting during tests
This commit is contained in:
Dan Stillman 2024-03-29 07:19:58 -04:00
parent 2ec6c7c72e
commit 849ffe0133

View file

@ -130,14 +130,17 @@ var ZoteroCommandLineHandler = {
};
const Cm = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
Cm.registerFactory(
ZoteroCommandLineHandler.classID,
"command-line-handler",
ZoteroCommandLineHandler.contractID,
ZoteroCommandLineHandler
);
const catman = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
catman.addCategoryEntry("command-line-handler",
"m-zotero",
ZoteroCommandLineHandler.contractID, false, true);
// Don't register if already registered (e.g., after a reinit() in tests)
if (!Cm.isCIDRegistered(ZoteroCommandLineHandler.classID)) {
Cm.registerFactory(
ZoteroCommandLineHandler.classID,
"command-line-handler",
ZoteroCommandLineHandler.contractID,
ZoteroCommandLineHandler
);
const catman = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
catman.addCategoryEntry("command-line-handler",
"m-zotero",
ZoteroCommandLineHandler.contractID, false, true);
}