commit 7a7bcae2c38074b2811b681c52e7267ce8a767ee
parent c453db744a7801161f9f80636cc077edd540f75d
Author: Simon Kornblith <simon@simonster.com>
Date: Thu, 23 Jun 2011 09:29:53 +0000
Add option not to delete hidden browser in http.js, and use it in translatorTester.js
Diffstat:
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git 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
@@ -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;
}
/**