commit d35c2d9a4fae34f56756dfc663c505c019837ea3
parent 635cc8bd15565b96b707a3dfcb9b0615aa009ff2
Author: Simon Kornblith <simon@simonster.com>
Date: Wed, 29 Feb 2012 02:56:31 -0500
Be more careful about pageshow only fire with doc.readyState === "loading"
Diffstat:
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/xpcom/http.js b/chrome/content/zotero/xpcom/http.js
@@ -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 {