Bug 644993 - Undo close tab doesn't refresh the content in a SSL Error page [r=mark.finkle]
authorLucas Rocha <lucasr@mozilla.com>
Fri, 12 Aug 2011 07:44:00 -0400
changeset 74350 bd9891ab14eb38ca79fb28789f4139c9d8f1fd9c
parent 74349 c1eadd115562e155ec1ef3a0c24fb33fea4b2ca6
child 74351 431405059a6966e1d7089d3ee6ac1d2e43f15efe
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersmark
bugs644993
milestone8.0a1
Bug 644993 - Undo close tab doesn't refresh the content in a SSL Error page [r=mark.finkle]
mobile/chrome/content/browser.js
mobile/chrome/content/content.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -376,16 +376,17 @@ var Browser = {
     messageManager.addMessageListener("Browser:CanCaptureMouse:Return", this);
     messageManager.addMessageListener("Browser:FormSubmit", this);
     messageManager.addMessageListener("Browser:KeyPress", this);
     messageManager.addMessageListener("Browser:ZoomToPoint:Return", this);
     messageManager.addMessageListener("Browser:CanUnload:Return", this);
     messageManager.addMessageListener("scroll", this);
     messageManager.addMessageListener("Browser:CertException", this);
     messageManager.addMessageListener("Browser:BlockedSite", this);
+    messageManager.addMessageListener("Browser:ErrorPage", this);
 
     // Broadcast a UIReady message so add-ons know we are finished with startup
     let event = document.createEvent("Events");
     event.initEvent("UIReady", true, false);
     window.dispatchEvent(event);
 
     // If we have an opener this was not the first window opened and will not
     // receive an initial resize event. instead we fire the resize handler manually
@@ -478,16 +479,17 @@ var Browser = {
 
     messageManager.removeMessageListener("Browser:ViewportMetadata", this);
     messageManager.removeMessageListener("Browser:FormSubmit", this);
     messageManager.removeMessageListener("Browser:KeyPress", this);
     messageManager.removeMessageListener("Browser:ZoomToPoint:Return", this);
     messageManager.removeMessageListener("scroll", this);
     messageManager.removeMessageListener("Browser:CertException", this);
     messageManager.removeMessageListener("Browser:BlockedSite", this);
+    messageManager.removeMessageListener("Browser:ErrorPage", this);
 
     var os = Services.obs;
     os.removeObserver(XPInstallObserver, "addon-install-blocked");
     os.removeObserver(XPInstallObserver, "addon-install-started");
     os.removeObserver(SessionHistoryObserver, "browser:purge-session-history");
     os.removeObserver(ContentCrashObserver, "ipc:content-shutdown");
     os.removeObserver(MemoryObserver, "memory-pressure");
 
@@ -931,16 +933,24 @@ var Browser = {
           Cu.reportError("Couldn't get phishing info URL: " + e);
         }
         break;
       }
     }
   },
 
   /**
+   * Handle error page message from the content.
+   */
+  _handleErrorPage: function _handleErrorPage(aMessage) {
+    let tab = this.getTabForBrowser(aMessage.target);
+    tab.updateThumbnail({ force: true });
+  },
+
+  /**
    * Compute the sidebar percentage visibility.
    *
    * @param [optional] dx
    * @param [optional] dy an offset distance at which to perform the visibility
    * computation
    */
   computeSidebarVisibility: function computeSidebarVisibility(dx, dy) {
     function visibility(aSidebarRect, aVisibleRect) {
@@ -1220,16 +1230,19 @@ var Browser = {
         }
         break;
       case "Browser:CertException":
         this._handleCertException(aMessage);
         break;
       case "Browser:BlockedSite":
         this._handleBlockedSite(aMessage);
         break;
+      case "Browser:ErrorPage":
+        this._handleErrorPage(aMessage);
+        break;
     }
   }
 };
 
 
 Browser.MainDragger = function MainDragger() {
   this._horizontalScrollbar = document.getElementById("horizontal-scroller");
   this._verticalScrollbar = document.getElementById("vertical-scroller");
@@ -2966,27 +2979,30 @@ Tab.prototype = {
 
     return this._browser.getBoundingClientRect().width / browserW;
   },
 
   get allowZoom() {
     return this.metadata.allowZoom && !Util.isURLEmpty(this.browser.currentURI.spec);
   },
 
-  updateThumbnail: function updateThumbnail() {
+  updateThumbnail: function updateThumbnail(options) {
+    let options = options || {};
     let browser = this._browser;
 
     if (this._loading) {
       this._drawThumb = true;
       return;
     }
 
+    let forceUpdate = ("force" in options && options.force);
+
     // Do not repaint thumbnail if we already painted for this load. Bad things
     // happen when we do async canvas draws in quick succession.
-    if (!browser || this._thumbnailWindowId == browser.contentWindowId)
+    if (!forceUpdate && (!browser || this._thumbnailWindowId == browser.contentWindowId))
       return;
 
     // Do not try to paint thumbnails if contentWindowWidth/Height have not been
     // set yet. This also blows up for async canvas draws.
     if (!browser.contentWindowWidth || !browser.contentWindowHeight)
       return;
 
     this._thumbnailWindowId = browser.contentWindowId;
--- a/mobile/chrome/content/content.js
+++ b/mobile/chrome/content/content.js
@@ -274,16 +274,17 @@ let Content = {
     addMessageListener("Browser:ContextCommand", this);
     addMessageListener("Browser:CanUnload", this);
     addMessageListener("Browser:CanCaptureMouse", this);
 
     if (Util.isParentProcess())
       addEventListener("DOMActivate", this, true);
 
     addEventListener("MozApplicationManifest", this, false);
+    addEventListener("DOMContentLoaded", this, false);
     addEventListener("pagehide", this, false);
     addEventListener("keypress", this, false, false);
 
     // Attach a listener to watch for "click" events bubbling up from error
     // pages and other similar page. This lets us fix bugs like 401575 which
     // require error page UI to do privileged things, without letting error
     // pages have any privilege themselves.
     addEventListener("click", this, false);
@@ -379,16 +380,20 @@ let Content = {
             // TODO: We'll need to impl notifications in the parent process and use the preference code found here:
             //       http://hg.mozilla.org/mozilla-central/file/855e5cd3c884/browser/base/content/browser.js#l2672
             //       http://hg.mozilla.org/mozilla-central/file/855e5cd3c884/browser/components/safebrowsing/content/globalstore.js
           }
         }
         break;
       }
 
+      case "DOMContentLoaded":
+        this._maybeNotifyErroPage();
+        break;
+
       case "pagehide":
         if (aEvent.target == content.document)
           this._resetFontSize();          
         break;
     }
   },
 
   receiveMessage: function receiveMessage(aMessage) {
@@ -597,16 +602,24 @@ let Content = {
         sendAsyncMessage("Browser:CanCaptureMouse:Return", {
           contentMightCaptureMouse: content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).mayHaveTouchEventListeners
         });
         break;
       }
     }
   },
 
+  _maybeNotifyErroPage: function _maybeNotifyErroPage() {
+    // Notify browser that an error page is being shown instead
+    // of the target location. Necessary to get proper thumbnail
+    // updates on chrome for error pages.
+    if (content.location.href !== content.document.documentURI)
+      sendAsyncMessage("Browser:ErrorPage", null);
+  },
+
   _resetFontSize: function _resetFontSize() {
     this._isZoomedToElement = false;
     this._setMinFontSize(0);
   },
 
   _highlightElement: null,
 
   _doTapHighlight: function _doTapHighlight(aElement) {