Add option not to delete hidden browser in http.js, and use it in translatorTester.js
This commit is contained in:
parent
c453db744a
commit
7a7bcae2c3
|
@ -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
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user