diff --git a/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js b/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js index 61386de5fdc..800768106ec 100644 --- a/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js +++ b/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js @@ -108,8 +108,6 @@ const backgroundPageThumbsContent = { this._startNextCapture(); } else if (this._state == STATE_CANCELED) { - // A capture request was received while the current capture's page - // was still loading. delete this._currentCapture; this._startNextCapture(); } @@ -119,9 +117,20 @@ const backgroundPageThumbsContent = { // The requested page has loaded. Capture it. this._state = STATE_CAPTURING; this._captureCurrentPage(); - } else { + } + else if (this._state != STATE_CANCELED) { + // Something went wrong. Cancel the capture. Loading about:blank + // while onStateChange is still on the stack does not actually stop + // the request if it redirects, so do it asyncly. this._state = STATE_CANCELED; - this._loadAboutBlank(); + if (!this._cancelTimer) { + this._cancelTimer = + Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); + this._cancelTimer.init(() => { + this._loadAboutBlank(); + delete this._cancelTimer; + }, 0, Ci.nsITimer.TYPE_ONE_SHOT); + } } } },