Bug 1147122 - Restore reader view error message if about:reader fails when user clicks reader button. r=Gijs, a=sledru
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Tue, 24 Mar 2015 17:30:43 -0700
changeset 258267 a2a4bbc864ad
parent 258266 fd67405ba1de
child 258268 180f3c3634e3
push id4632
push userryanvm@gmail.com
push date2015-04-06 15:16 +0000
treeherdermozilla-beta@887be7f12f1e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, sledru
bugs1147122
milestone38.0
Bug 1147122 - Restore reader view error message if about:reader fails when user clicks reader button. r=Gijs, a=sledru
toolkit/components/reader/AboutReader.jsm
--- a/toolkit/components/reader/AboutReader.jsm
+++ b/toolkit/components/reader/AboutReader.jsm
@@ -574,17 +574,22 @@ AboutReader.prototype = {
     }
 
     if (this._windowUnloaded) {
       return;
     }
 
     if (article && article.url == url) {
       this._showContent(article);
+    } else if (this._articlePromise) {
+      // If we were promised an article, show an error message if there's a failure.
+      this._showError();
     } else {
+      // Otherwise, just load the original URL. We can encounter this case when
+      // loading an about:reader URL directly (e.g. opening a reading list item).
       this._win.location.href = url;
     }
   }),
 
   _getArticle: function(url) {
     return new Promise((resolve, reject) => {
       let listener = (message) => {
         this._mm.removeMessageListener("Reader:ArticleData", listener);
@@ -666,24 +671,27 @@ AboutReader.prototype = {
     if(!article.dir)
       return;
 
     //Set "dir" attribute on content
     this._contentElement.setAttribute("dir", article.dir);
     this._headerElement.setAttribute("dir", article.dir);
   },
 
-  _showError: function Reader_showError(error) {
+  _showError: function() {
     this._headerElement.style.display = "none";
     this._contentElement.style.display = "none";
 
-    this._messageElement.innerHTML = error;
+    let errorMessage = gStrings.GetStringFromName("aboutReader.loadError");
+    this._messageElement.textContent = errorMessage;
     this._messageElement.style.display = "block";
 
-    this._doc.title = error;
+    this._doc.title = errorMessage;
+
+    this._error = true;
   },
 
   // This function is the JS version of Java's StringUtils.stripCommonSubdomains.
   _stripHost: function Reader_stripHost(host) {
     if (!host)
       return host;
 
     let start = 0;
@@ -732,25 +740,26 @@ AboutReader.prototype = {
   _hideContent: function Reader_hideContent() {
     this._headerElement.style.display = "none";
     this._contentElement.style.display = "none";
   },
 
   _showProgressDelayed: function Reader_showProgressDelayed() {
     this._win.setTimeout(function() {
       // No need to show progress if the article has been loaded,
-      // or if the window has been unloaded.
-      if (this._article || this._windowUnloaded) {
+      // if the window has been unloaded, or if there was an error
+      // trying to load the article.
+      if (this._article || this._windowUnloaded || this._error) {
         return;
       }
 
       this._headerElement.style.display = "none";
       this._contentElement.style.display = "none";
 
-      this._messageElement.innerHTML = gStrings.GetStringFromName("aboutReader.loading");
+      this._messageElement.textContent = gStrings.GetStringFromName("aboutReader.loading");
       this._messageElement.style.display = "block";
     }.bind(this), 300);
   },
 
   /**
    * Returns the original article URL for this about:reader view.
    */
   _getOriginalUrl: function(win) {