Be more careful about pageshow only fire with doc.readyState === "loading"
This commit is contained in:
parent
635cc8bd15
commit
d35c2d9a4f
1 changed files with 13 additions and 1 deletions
|
@ -489,6 +489,11 @@ Zotero.HTTP = new function() {
|
|||
* @return {browser} Hidden browser used for loading
|
||||
*/
|
||||
this.processDocuments = function(urls, processor, done, exception, dontDelete, cookieSandbox) {
|
||||
// (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;
|
||||
/**
|
||||
* Removes event listener for the load event and deletes the hidden browser
|
||||
*/
|
||||
|
@ -504,6 +509,7 @@ Zotero.HTTP = new function() {
|
|||
var doLoad = function() {
|
||||
if(urls.length) {
|
||||
var url = urls.shift();
|
||||
firedLoadEvent = 0;
|
||||
try {
|
||||
Zotero.debug("loading "+url);
|
||||
hiddenBrowser.loadURI(url);
|
||||
|
@ -529,7 +535,13 @@ Zotero.HTTP = new function() {
|
|||
var onLoad = function() {
|
||||
var doc = hiddenBrowser.contentDocument,
|
||||
url = doc.location.href.toString();
|
||||
if(url == "about:blank" || doc.readyState === "loading") return;
|
||||
if(url == "about:blank") return;
|
||||
if(doc.readyState === "loading" && firedLoadEvent < 120) {
|
||||
// Try again in a second
|
||||
firedLoadEvent++;
|
||||
Zotero.setTimeout(onLoad, 1000);
|
||||
return;
|
||||
}
|
||||
if(url !== prevUrl) { // Just in case it fires too many times
|
||||
prevUrl = url;
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue