diff --git a/mobile/chrome/content/browser.js b/mobile/chrome/content/browser.js index 1b200ca3f6a..fbbf5faf398 100644 --- a/mobile/chrome/content/browser.js +++ b/mobile/chrome/content/browser.js @@ -381,6 +381,7 @@ var Browser = { 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"); @@ -483,6 +484,7 @@ var Browser = { 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"); @@ -935,6 +937,14 @@ var Browser = { } }, + /** + * 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. * @@ -1225,6 +1235,9 @@ var Browser = { case "Browser:BlockedSite": this._handleBlockedSite(aMessage); break; + case "Browser:ErrorPage": + this._handleErrorPage(aMessage); + break; } } }; @@ -2971,7 +2984,8 @@ Tab.prototype = { 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) { @@ -2979,9 +2993,11 @@ Tab.prototype = { 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 diff --git a/mobile/chrome/content/content.js b/mobile/chrome/content/content.js index fddb821773e..2a23667bf64 100644 --- a/mobile/chrome/content/content.js +++ b/mobile/chrome/content/content.js @@ -279,6 +279,7 @@ let Content = { addEventListener("DOMActivate", this, true); addEventListener("MozApplicationManifest", this, false); + addEventListener("DOMContentLoaded", this, false); addEventListener("pagehide", this, false); addEventListener("keypress", this, false, false); @@ -384,6 +385,10 @@ let Content = { break; } + case "DOMContentLoaded": + this._maybeNotifyErroPage(); + break; + case "pagehide": if (aEvent.target == content.document) this._resetFontSize(); @@ -602,6 +607,14 @@ let Content = { } }, + _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);