Merge pull request #226 from aurimasv/processDocuments
Eliminate race condition during processDocuments call with multiple URLs
This commit is contained in:
commit
03ed7913a6
1 changed files with 3 additions and 5 deletions
|
@ -492,8 +492,7 @@ Zotero.HTTP = new function() {
|
|||
// (Approximately) how many seconds to wait if the document is left in the loading state and
|
||||
// pageshow is called before we call pageshow with an incomplete document
|
||||
const LOADING_STATE_TIMEOUT = 120;
|
||||
var firedLoadEvent = 0,
|
||||
loaded = false;
|
||||
var firedLoadEvent = 0;
|
||||
|
||||
/**
|
||||
* Loads the next page
|
||||
|
@ -504,7 +503,6 @@ Zotero.HTTP = new function() {
|
|||
var url = urls[currentURL],
|
||||
hiddenBrowser = hiddenBrowsers[currentURL];
|
||||
firedLoadEvent = 0;
|
||||
loaded = false;
|
||||
currentURL++;
|
||||
try {
|
||||
Zotero.debug("Zotero.HTTP.processDocuments: Loading "+url);
|
||||
|
@ -529,9 +527,9 @@ Zotero.HTTP = new function() {
|
|||
* @inner
|
||||
*/
|
||||
var onLoad = function(e) {
|
||||
if(loaded) return;
|
||||
var hiddenBrowser = e.currentTarget,
|
||||
doc = hiddenBrowser.contentDocument;
|
||||
if(hiddenBrowser.zotero_loaded) return;
|
||||
if(!doc) return;
|
||||
var url = doc.documentURI;
|
||||
if(url === "about:blank") return;
|
||||
|
@ -543,7 +541,7 @@ Zotero.HTTP = new function() {
|
|||
|
||||
Zotero.debug("Zotero.HTTP.processDocuments: "+url+" loaded");
|
||||
hiddenBrowser.removeEventListener("pageshow", onLoad, true);
|
||||
loaded = true;
|
||||
hiddenBrowser.zotero_loaded = true;
|
||||
|
||||
try {
|
||||
processor(doc);
|
||||
|
|
Loading…
Reference in a new issue