From 6bad741446b32ec687d0a3f1d756901ba3d91238 Mon Sep 17 00:00:00 2001 From: Mason Chang Date: Mon, 4 Jan 2016 16:24:58 -0800 Subject: [PATCH] Bug 1231518. Load about:blank if thumbnail service fails. r=adw --- toolkit/components/thumbnails/PageThumbUtils.jsm | 1 + .../thumbnails/content/backgroundPageThumbsContent.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/toolkit/components/thumbnails/PageThumbUtils.jsm b/toolkit/components/thumbnails/PageThumbUtils.jsm index 5ff8b5229904..0f3da6f97a15 100644 --- a/toolkit/components/thumbnails/PageThumbUtils.jsm +++ b/toolkit/components/thumbnails/PageThumbUtils.jsm @@ -187,6 +187,7 @@ this.PageThumbUtils = { // remove the scrollbar sizes. let scale = Math.min(Math.max(intermediateWidth / contentWidth, intermediateHeight / contentHeight), 1); + let snapshotCtx = snapshotCanvas.getContext("2d"); snapshotCtx.save(); snapshotCtx.scale(scale, scale); diff --git a/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js b/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js index dcbc7a81fa45..342847b74975 100644 --- a/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js +++ b/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js @@ -99,7 +99,7 @@ const backgroundPageThumbsContent = { onStateChange: function (webProgress, req, flags, status) { if (webProgress.isTopLevel && (flags & Ci.nsIWebProgressListener.STATE_STOP) && - this._currentCapture && Components.isSuccessCode(status)) { + this._currentCapture) { if (req.name == "about:blank") { if (this._state == STATE_CAPTURING) { // about:blank has loaded, ending the current capture. @@ -114,10 +114,14 @@ const backgroundPageThumbsContent = { this._startNextCapture(); } } - else if (this._state == STATE_LOADING) { + else if (this._state == STATE_LOADING && + Components.isSuccessCode(status)) { // The requested page has loaded. Capture it. this._state = STATE_CAPTURING; this._captureCurrentPage(); + } else { + this._state = STATE_CANCELED; + this._loadAboutBlank(); } } },