Fix broken tests due to protocol handler and autocomplete re-registration
For the protocol handler, unregister on reinit(). For autocomplete, just skip registration if already registered.
This commit is contained in:
parent
349ae52b9c
commit
cd3fda98d1
3 changed files with 15 additions and 8 deletions
|
@ -1366,6 +1366,8 @@ ZoteroProtocolHandler.prototype = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @static
|
* @static
|
||||||
|
*
|
||||||
|
* Unregistered in Zotero.reinit() for tests
|
||||||
*/
|
*/
|
||||||
ZoteroProtocolHandler.init = function () {
|
ZoteroProtocolHandler.init = function () {
|
||||||
Services.io.registerProtocolHandler(
|
Services.io.registerProtocolHandler(
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
***** END LICENSE BLOCK *****
|
***** END LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ZOTERO_AC_CID = Components.ID('{06a2ed11-d0a4-4ff0-a56f-a44545eee6ea}');
|
const ZOTERO_AC_CLASS_ID = Components.ID('{06a2ed11-d0a4-4ff0-a56f-a44545eee6ea}');
|
||||||
|
const ZOTERO_AC_CONTRACT_ID = "@mozilla.org/autocomplete/search;1?name=zotero";
|
||||||
const EXPORTED_SYMBOLS = ['ZoteroAutoComplete'];
|
const EXPORTED_SYMBOLS = ['ZoteroAutoComplete'];
|
||||||
|
|
||||||
const Cc = Components.classes;
|
const Cc = Components.classes;
|
||||||
|
@ -351,19 +352,20 @@ ZoteroAutoComplete.prototype.stopSearch = function(){
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
ZoteroAutoComplete.init = function () {
|
ZoteroAutoComplete.init = function () {
|
||||||
let search = new ZoteroAutoComplete();
|
// If already registered (e.g., after a Zotero.reinit() in tests), skip
|
||||||
var name = "@mozilla.org/autocomplete/search;1?name=zotero";
|
var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||||
var componentManager = Components.manager.QueryInterface(
|
if (registrar.isCIDRegistered(ZOTERO_AC_CLASS_ID)) {
|
||||||
Ci.nsIComponentRegistrar
|
return;
|
||||||
);
|
}
|
||||||
componentManager.registerFactory(ZOTERO_AC_CID, "", name, search);
|
var search = new ZoteroAutoComplete();
|
||||||
|
registrar.registerFactory(ZOTERO_AC_CLASS_ID, "", ZOTERO_AC_CONTRACT_ID, search);
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// XPCOM goop
|
// XPCOM goop
|
||||||
//
|
//
|
||||||
|
|
||||||
ZoteroAutoComplete.prototype.classID = ZOTERO_AC_CID;
|
ZoteroAutoComplete.prototype.classID = ZOTERO_AC_CLASS_ID;
|
||||||
ZoteroAutoComplete.prototype.QueryInterface = ChromeUtils.generateQI([
|
ZoteroAutoComplete.prototype.QueryInterface = ChromeUtils.generateQI([
|
||||||
"nsIFactory",
|
"nsIFactory",
|
||||||
"nsIAutoCompleteSearch"
|
"nsIAutoCompleteSearch"
|
||||||
|
|
|
@ -184,6 +184,9 @@ ZoteroContext.prototype = {
|
||||||
reinit: function (cb, options = {}) {
|
reinit: function (cb, options = {}) {
|
||||||
Services.obs.notifyObservers(zContext.Zotero, "zotero-before-reload");
|
Services.obs.notifyObservers(zContext.Zotero, "zotero-before-reload");
|
||||||
return zContext.Zotero.shutdown().then(function() {
|
return zContext.Zotero.shutdown().then(function() {
|
||||||
|
// Unregister custom protocol handler
|
||||||
|
Services.io.unregisterProtocolHandler('zotero');
|
||||||
|
|
||||||
return cb ? cb() : false;
|
return cb ? cb() : false;
|
||||||
}).finally(function() {
|
}).finally(function() {
|
||||||
makeZoteroContext();
|
makeZoteroContext();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue