From 49001572fd5bae61aad01a518782f0ad4875a442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Fri, 14 Apr 2017 12:43:39 +0300 Subject: [PATCH] Remove dependency on zoteroIntegration.idl --- chrome/content/zotero/xpcom/integration.js | 20 ++++++++++++++++---- test/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 index 4fc78548ce..a6035343a2 100644 --- 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 index 403d529bd9..bb17a62085 100644 --- 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']) {