diff --git a/chrome/content/zotero/xpcom/server_connector.js b/chrome/content/zotero/xpcom/server_connector.js index 97ebd1f15..f8bdad3d2 100644 --- a/chrome/content/zotero/xpcom/server_connector.js +++ b/chrome/content/zotero/xpcom/server_connector.js @@ -201,6 +201,7 @@ Zotero.Server.Connector.Detect.prototype = { * uri - The URI of the page to be saved * html - document.innerHTML or equivalent * cookie - document.cookie or equivalent + * translatorID [optional] - a translator ID as returned by /connector/detect * * Returns: * If a single item, sends response code 201 with item in body. @@ -297,8 +298,11 @@ Zotero.Server.Connector.SavePage.prototype = { } }); - // set translator and translate - translate.setTranslator(this._parsedPostData.translatorID); + if (this._parsedPostData.translatorID) { + translate.setTranslator(this._parsedPostData.translatorID); + } else { + translate.setTranslator(translators[0]); + } translate.translate(libraryID); } } diff --git a/test/tests/data/coins.html b/test/tests/data/coins.html new file mode 100644 index 000000000..b60116665 --- /dev/null +++ b/test/tests/data/coins.html @@ -0,0 +1,12 @@ + + +
+ +This is a test page
+ + + diff --git a/test/tests/server_connectorTest.js b/test/tests/server_connectorTest.js index 45e8dc509..dd4c28756 100644 --- a/test/tests/server_connectorTest.js +++ b/test/tests/server_connectorTest.js @@ -390,6 +390,58 @@ describe("Connector Server", function () { }); }); + describe("/connector/savePage", function() { + // TEMP: Wait for indexing to complete, which happens after a 1-second delay, after a 201 has + // been returned to the connector. Would be better to make sure indexing has completed. + afterEach(function* () { + yield Zotero.Promise.delay(1050); + }); + + it("should return 500 if no translator available for page", function* () { + var xmlhttp = yield Zotero.HTTP.request( + 'POST', + connectorServerPath + "/connector/savePage", + { + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + uri: "http://example.com", + html: "