Bug 1231518. Load about:blank if thumbnail service fails. r=adw a=sylvestre
authorMason Chang <mchang@mozilla.com>
Mon, 04 Jan 2016 16:24:58 -0800
changeset 310869 12749267243fd0e94093f8249df0644faeea4546
parent 310868 9bb7a45e5b69d68ddd2752acc9cf3f500365b1d2
child 310870 746c9a0348f607456e2d7db191351cc2073ded39
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw, sylvestre
bugs1231518
milestone45.0a2
Bug 1231518. Load about:blank if thumbnail service fails. r=adw a=sylvestre
toolkit/components/thumbnails/PageThumbUtils.jsm
toolkit/components/thumbnails/content/backgroundPageThumbsContent.js
--- a/toolkit/components/thumbnails/PageThumbUtils.jsm
+++ b/toolkit/components/thumbnails/PageThumbUtils.jsm
@@ -182,16 +182,17 @@ this.PageThumbUtils = {
       snapshotCanvas = this.createCanvas(aWindow, intermediateWidth, intermediateHeight);
     }
 
     // This is step 1.
     // Also by default, canvas does not draw the scrollbars, so no need to
     // 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);
     snapshotCtx.drawWindow(aWindow, 0, 0, contentWidth, contentHeight,
                            PageThumbUtils.THUMBNAIL_BG_COLOR,
                            snapshotCtx.DRAWWINDOW_DO_NOT_FLUSH);
     snapshotCtx.restore();
     if (skipDownscale) {
--- a/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js
+++ b/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js
@@ -94,35 +94,39 @@ const backgroundPageThumbsContent = {
       delete this._currentCapture;
       this._startNextCapture();
     }
   },
 
   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.
           this._finishCurrentCapture();
           delete this._currentCapture;
           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();
         }
       }
-      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();
       }
     }
   },
 
   _captureCurrentPage: function () {
     let capture = this._currentCapture;
     capture.finalURL = this._webNav.currentURI.spec;
     capture.pageLoadTime = new Date() - capture.pageLoadStartDate;