Bug 1320900 - Do not show Reader View icon on error pages. r=sebastian
authorNevin Chen <cnevinchen@gmail.com>
Fri, 30 Dec 2016 11:11:09 +0800
changeset 375591 b67585d1f51838b66cbc0854f74210c8120affbd
parent 375590 e7c232eb0efa4076d3402a919671edeff7e9de28
child 375592 2472110ff7862ce333a0d89615364e097ed0e970
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1320900
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1320900 - Do not show Reader View icon on error pages. r=sebastian MozReview-Commit-ID: GrQqKqccicf
mobile/android/chrome/content/content.js
--- a/mobile/android/chrome/content/content.js
+++ b/mobile/android/chrome/content/content.js
@@ -51,16 +51,22 @@ var AboutReaderListener = {
         break;
     }
   },
 
   get isAboutReader() {
     return content.document.documentURI.startsWith("about:reader");
   },
 
+  get isErrorPage() {
+    return content.document.documentURI.startsWith("about:neterror") ||
+        content.document.documentURI.startsWith("about:certerror") ||
+        content.document.documentURI.startsWith("about:blocked");
+  },
+
   handleEvent: function(aEvent) {
     if (aEvent.originalTarget.defaultView != content) {
       return;
     }
 
     switch (aEvent.type) {
       case "AboutReaderContentLoaded":
         if (!this.isAboutReader) {
@@ -95,23 +101,26 @@ var AboutReaderListener = {
         }
         break;
       case "DOMContentLoaded":
         this.updateReaderButton();
         break;
     }
   },
   updateReaderButton: function(forceNonArticle) {
-    if (!ReaderMode.isEnabledForParseOnLoad || this.isAboutReader ||
+    // Do not show Reader View icon on error pages (bug 1320900)
+    if (this.isErrorPage) {
+        sendAsyncMessage("Reader:UpdateReaderButton", { isArticle: false });
+    } else if (!ReaderMode.isEnabledForParseOnLoad || this.isAboutReader ||
         !(content.document instanceof content.HTMLDocument) ||
         content.document.mozSyntheticDocument) {
       return;
+    } else {
+        this.scheduleReadabilityCheckPostPaint(forceNonArticle);
     }
-
-    this.scheduleReadabilityCheckPostPaint(forceNonArticle);
   },
 
   cancelPotentialPendingReadabilityCheck: function() {
     if (this._pendingReadabilityCheck) {
       removeEventListener("MozAfterPaint", this._pendingReadabilityCheck);
       delete this._pendingReadabilityCheck;
     }
   },