Add option not to delete hidden browser in http.js, and use it in translatorTester.js

This commit is contained in:
Simon Kornblith 2011-06-23 09:29:53 +00:00
parent c453db744a
commit 7a7bcae2c3
2 changed files with 16 additions and 5 deletions

View File

@ -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
);
};

View File

@ -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;
}
/**