Bug 1147487 - Don't try to reader-ize non-HTML documents. r=margaret, r=jaws, a=lmandel
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 01 Apr 2015 13:40:25 +0100
changeset 267469 490bc4e9a9df75cafffd07781901330a779a8559
parent 267468 d314b3559a93f4e85aff65339d50b97c6d977d1e
child 267470 360a68921cd5e083bf940a1cf45172612df38222
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, jaws, lmandel
bugs1147487
milestone39.0
Bug 1147487 - Don't try to reader-ize non-HTML documents. r=margaret, r=jaws, a=lmandel
toolkit/components/reader/ReaderMode.jsm
--- a/toolkit/components/reader/ReaderMode.jsm
+++ b/toolkit/components/reader/ReaderMode.jsm
@@ -113,18 +113,22 @@ this.ReaderMode = {
 
   /**
    * Decides whether or not a document is reader-able without parsing the whole thing.
    *
    * @param doc A document to parse.
    * @return boolean Whether or not we should show the reader mode button.
    */
   isProbablyReaderable: function(doc) {
+    // Only care about 'real' HTML documents:
+    if (doc.mozSyntheticDocument || !(doc instanceof doc.defaultView.HTMLDocument)) {
+      return false;
+    }
+
     let uri = Services.io.newURI(doc.location.href, null, null);
-
     if (!this._shouldCheckUri(uri)) {
       return false;
     }
 
     let utils = this.getUtilsForWin(doc.defaultView);
     // We pass in a helper function to determine if a node is visible, because
     // it uses gecko APIs that the engine-agnostic readability code can't rely
     // upon.