Eliminate race condition during processDocuments call with multiple URLs
This commit is contained in:
parent
f24091626d
commit
13c3e5427e
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
|
// (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
|
// pageshow is called before we call pageshow with an incomplete document
|
||||||
const LOADING_STATE_TIMEOUT = 120;
|
const LOADING_STATE_TIMEOUT = 120;
|
||||||
var firedLoadEvent = 0,
|
var firedLoadEvent = 0;
|
||||||
loaded = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the next page
|
* Loads the next page
|
||||||
|
@ -504,7 +503,6 @@ Zotero.HTTP = new function() {
|
||||||
var url = urls[currentURL],
|
var url = urls[currentURL],
|
||||||
hiddenBrowser = hiddenBrowsers[currentURL];
|
hiddenBrowser = hiddenBrowsers[currentURL];
|
||||||
firedLoadEvent = 0;
|
firedLoadEvent = 0;
|
||||||
loaded = false;
|
|
||||||
currentURL++;
|
currentURL++;
|
||||||
try {
|
try {
|
||||||
Zotero.debug("Zotero.HTTP.processDocuments: Loading "+url);
|
Zotero.debug("Zotero.HTTP.processDocuments: Loading "+url);
|
||||||
|
@ -529,9 +527,9 @@ Zotero.HTTP = new function() {
|
||||||
* @inner
|
* @inner
|
||||||
*/
|
*/
|
||||||
var onLoad = function(e) {
|
var onLoad = function(e) {
|
||||||
if(loaded) return;
|
|
||||||
var hiddenBrowser = e.currentTarget,
|
var hiddenBrowser = e.currentTarget,
|
||||||
doc = hiddenBrowser.contentDocument;
|
doc = hiddenBrowser.contentDocument;
|
||||||
|
if(hiddenBrowser.zotero_loaded) return;
|
||||||
if(!doc) return;
|
if(!doc) return;
|
||||||
var url = doc.documentURI;
|
var url = doc.documentURI;
|
||||||
if(url === "about:blank") return;
|
if(url === "about:blank") return;
|
||||||
|
@ -543,7 +541,7 @@ Zotero.HTTP = new function() {
|
||||||
|
|
||||||
Zotero.debug("Zotero.HTTP.processDocuments: "+url+" loaded");
|
Zotero.debug("Zotero.HTTP.processDocuments: "+url+" loaded");
|
||||||
hiddenBrowser.removeEventListener("pageshow", onLoad, true);
|
hiddenBrowser.removeEventListener("pageshow", onLoad, true);
|
||||||
loaded = true;
|
hiddenBrowser.zotero_loaded = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
processor(doc);
|
processor(doc);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue