From 8d61e30a93b40d9aceb65b7f05b20f7dca43dacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Fri, 26 Oct 2018 16:29:53 +0300 Subject: [PATCH] Update translatorTester for use in translation server --- .../tools/testTranslators/translatorTester.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/tools/testTranslators/translatorTester.js b/chrome/content/zotero/tools/testTranslators/translatorTester.js index 9564542c65..a56244b919 100644 --- a/chrome/content/zotero/tools/testTranslators/translatorTester.js +++ b/chrome/content/zotero/tools/testTranslators/translatorTester.js @@ -24,7 +24,7 @@ */ // Timeout for test to complete -var TEST_RUN_TIMEOUT = 600000; +var TEST_RUN_TIMEOUT = 60000; var EXPORTED_SYMBOLS = ["Zotero_TranslatorTesters"]; // For debugging specific translators by label @@ -410,13 +410,17 @@ Zotero_TranslatorTester.prototype._runTestsRecursively = function(testDoneCallba * @param {Function} testDoneCallback - A callback to be executed when test is complete */ Zotero_TranslatorTester.prototype.fetchPageAndRunTest = function (test, testDoneCallback) { + if (typeof process === 'object' && process + '' === '[object process]'){ + this._cookieSandbox = require('request').jar(); + } Zotero.HTTP.processDocuments( test.url, (doc) => { this.runTest(test, doc, function (obj, test, status, message) { testDoneCallback(obj, test, status, message); }); - } + }, + this._cookieSandbox, ) .catch(function (e) { testDoneCallback(this, test, "failed", "Translation failed to initialize: " + e); @@ -442,6 +446,9 @@ Zotero_TranslatorTester.prototype.runTest = function(test, doc, testDoneCallback } else if(this.type === "search") { translate.setSearch(test.input); } + if (translate.setCookieSandbox && this._cookieSandbox) { + translate.setCookieSandbox(this._cookieSandbox); + } translate.setHandler("translators", function(obj, translators) { me._runTestTranslate(translate, translators, test, testDoneCallback); @@ -765,5 +772,8 @@ Zotero_TranslatorTester._generateDiff = new function() { }; if (typeof process === 'object' && process + '' === '[object process]'){ - module.exports = Zotero_TranslatorTesters; + module.exports = { + Tester: Zotero_TranslatorTesters, + TranslatorTester: Zotero_TranslatorTester + }; }