From 4440844edb6e62ddeb5b35778752139d04cb5511 Mon Sep 17 00:00:00 2001 From: Drew Willcoxon Date: Tue, 16 Feb 2016 16:34:25 -0800 Subject: [PATCH] Bug 1247641 - When loading a background thumbnail, load about:blank asynchronously when a load fails to avoid endless redirects. r=markh --- .../content/backgroundPageThumbsContent.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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); + } } } },