www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 49001572fd5bae61aad01a518782f0ad4875a442
parent 0de22b132efd92d4660e26f24f1772f2ec57106d
Author: Adomas VenĨkauskas <adomas.ven@gmail.com>
Date:   Fri, 14 Apr 2017 12:43:39 +0300

Remove dependency on zoteroIntegration.idl

Diffstat:
Mchrome/content/zotero/xpcom/integration.js | 20++++++++++++++++----
Mtest/tests/integrationTests.js | 2--
2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js @@ -228,8 +228,13 @@ Zotero.Integration = new function() { try { var componentClass = "@zotero.org/Zotero/integration/application?agent="+agent+";1"; Zotero.debug("Integration: Instantiating "+componentClass+" for command "+command+(docId ? " with doc "+docId : "")); - return Components.classes[componentClass] - .getService(Components.interfaces.zoteroIntegrationApplication); + try { + return Components.classes[componentClass] + .getService(Components.interfaces.zoteroIntegrationApplication); + } catch (e) { + return Components.classes[componentClass] + .getService(Components.interfaces.nsISupports).wrappedJSObject; + } } catch(e) { throw new Zotero.Exception.Alert("integration.error.notInstalled", [], "integration.error.title"); @@ -309,8 +314,10 @@ Zotero.Integration = new function() { document.activate(); // Call complete function if one exists - if(document.wrappedJSObject && document.wrappedJSObject.complete) { + if (document.wrappedJSObject && document.wrappedJSObject.complete) { document.wrappedJSObject.complete(); + } else if (document.complete) { + document.complete(); } } catch(e) { Zotero.logError(e); @@ -1434,7 +1441,12 @@ Zotero.Integration.Fields.prototype.get = function get() { var fieldsEnumerator = subject.QueryInterface(Components.interfaces.nsISimpleEnumerator); var fields = me._fields = []; while(fieldsEnumerator.hasMoreElements()) { - fields.push(fieldsEnumerator.getNext().QueryInterface(Components.interfaces.zoteroIntegrationField)); + let field = fieldsEnumerator.getNext(); + try { + fields.push(field.QueryInterface(Components.interfaces.zoteroIntegrationField)); + } catch (e) { + fields.push(field); + } } if(Zotero.Debug.enabled) { diff --git a/test/tests/integrationTests.js b/test/tests/integrationTests.js @@ -120,7 +120,6 @@ describe("Zotero.Integration", function () { * Informs the document processor that the operation is complete */ complete: () => 0, - QueryInterface: function() {return this}, }; DocumentPluginDummy.FieldEnumerator = function(doc) {this.doc = doc; this.idx = 0}; @@ -190,7 +189,6 @@ describe("Zotero.Integration", function () { * @returns {Number} */ getNoteIndex: () => 0, - QueryInterface: function() {return this}, }; for (let cls of ['Application', 'Document', 'FieldEnumerator', 'Field']) {