diff --git a/chrome/content/zotero/tools/testTranslators/translatorTester.js b/chrome/content/zotero/tools/testTranslators/translatorTester.js index 64f712e73..db5188bf3 100644 --- a/chrome/content/zotero/tools/testTranslators/translatorTester.js +++ b/chrome/content/zotero/tools/testTranslators/translatorTester.js @@ -159,20 +159,26 @@ Zotero_TranslatorTester.prototype._runTestsRecursively = function(testDoneCallba /** * Fetches the page for a given test and runs it + * This function is only applicable in Firefox; it is overridden in translator_global.js in Chrome + * and Safari * @param {Object} test Test to execute * @param {Document} doc DOM document to test against * @param {Function} testDoneCallback A callback to be executed when test is complete */ Zotero_TranslatorTester.prototype.fetchPageAndRunTest = function(test, testDoneCallback) { var me = this; - Zotero.HTTP.processDocuments(test.url, + var hiddenBrowser = Zotero.HTTP.processDocuments(test.url, function(doc) { - me.runTest(test, doc, testDoneCallback); + me.runTest(test, doc, function(obj, test, status, message) { + Zotero.Browser.deleteHiddenBrowser(hiddenBrowser); + testDoneCallback(obj, test, status, message); + }); }, null, function(e) { testDoneCallback(this, test, "failed", "Translation failed to initialize: "+e); - } + }, + true ); }; diff --git a/chrome/content/zotero/xpcom/http.js b/chrome/content/zotero/xpcom/http.js index 18b49990b..a420d133b 100644 --- a/chrome/content/zotero/xpcom/http.js +++ b/chrome/content/zotero/xpcom/http.js @@ -504,14 +504,17 @@ Zotero.HTTP = new function() { * @param {Function} processor Callback to be executed for each document loaded * @param {Function} done Callback to be executed after all documents have been loaded * @param {Function} exception Callback to be executed if an exception occurs + * @param {Boolean} dontDelete Don't delete the hidden browser upon completion; calling function + * must call deleteHiddenBrowser itself. + * @return {browser} Hidden browser used for loading */ - this.processDocuments = function(urls, processor, done, exception) { + this.processDocuments = function(urls, processor, done, exception, dontDelete) { /** * Removes event listener for the load event and deletes the hidden browser */ var removeListeners = function() { hiddenBrowser.removeEventListener(loadEvent, onLoad, true); - Zotero.Browser.deleteHiddenBrowser(hiddenBrowser); + if(!dontDelete) Zotero.Browser.deleteHiddenBrowser(hiddenBrowser); } /** @@ -572,6 +575,8 @@ Zotero.HTTP = new function() { hiddenBrowser.addEventListener(loadEvent, onLoad, true); doLoad(); + + return hiddenBrowser; } /**