diff --git a/chrome/content/zotero/tools/testTranslators/translatorTester.js b/chrome/content/zotero/tools/testTranslators/translatorTester.js index 642eacdb5c..876fc970f1 100644 --- a/chrome/content/zotero/tools/testTranslators/translatorTester.js +++ b/chrome/content/zotero/tools/testTranslators/translatorTester.js @@ -421,7 +421,9 @@ Zotero_TranslatorTester.prototype.fetchPageAndRunTest = function (test, testDone testDoneCallback(obj, test, status, message); }); }, - this._cookieSandbox, + { + cookieSandbox: this._cookieSandbox + } ) .catch(function (e) { testDoneCallback(this, test, "failed", "Translation failed to initialize: " + e); diff --git a/chrome/content/zotero/xpcom/http.js b/chrome/content/zotero/xpcom/http.js index f30c3c5bdc..56baa55ced 100644 --- a/chrome/content/zotero/xpcom/http.js +++ b/chrome/content/zotero/xpcom/http.js @@ -903,10 +903,12 @@ Zotero.HTTP = new function() { * @param {String|String[]} urls URL(s) of documents to load * @param {Function} processor - Callback to be executed for each document loaded; if function returns * a promise, it's waited for before continuing - * @param {Zotero.CookieSandbox} [cookieSandbox] Cookie sandbox object + * @param {Object} [options] + * @param {Zotero.CookieSandbox} [options.cookieSandbox] - Cookie sandbox object + * @param {Object} [options.headers] - Headers to include in the request * @return {Promise} - A promise for an array of results from the processor runs */ - this.processDocuments = async function (urls, processor, cookieSandbox) { + this.processDocuments = async function (urls, processor, options = {}) { // Handle old signature: urls, processor, onDone, onError, dontDelete, cookieSandbox if (arguments.length > 3) { Zotero.debug("Zotero.HTTP.processDocuments() now takes only 3 arguments -- update your code"); @@ -914,6 +916,14 @@ Zotero.HTTP = new function() { var onError = arguments[3]; var cookieSandbox = arguments[5]; } + else if (options instanceof Zotero.CookieSandbox) { + Zotero.debug("Zotero.HTTP.processDocuments() now takes an 'options' object for its third parameter -- update your code"); + var cookieSandbox = options; + } + else { + var cookieSandbox = options.cookieSandbox; + var headers = options.headers; + } if (typeof urls == "string") urls = [urls]; var funcs = urls.map(url => () => { @@ -921,7 +931,9 @@ Zotero.HTTP = new function() { "GET", url, { - responseType: 'document' + responseType: 'document', + cookieSandbox, + headers } ) .then((xhr) => { diff --git a/chrome/content/zotero/xpcom/utilities_translate.js b/chrome/content/zotero/xpcom/utilities_translate.js index 577bfa87c9..89ea3e57dd 100644 --- a/chrome/content/zotero/xpcom/utilities_translate.js +++ b/chrome/content/zotero/xpcom/utilities_translate.js @@ -261,7 +261,9 @@ Zotero.Utilities.Translate.prototype.processDocuments = async function (urls, pr if (!processor) return; return processDoc(doc); }, - translate.cookieSandbox + { + cookieSandbox: translate.cookieSandbox + } ) ); }