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 260525 f44dff585598
parent 260524 f5828f333524
child 260526 f81271987769
child 260528 573c47bc1bf2
push id808
push userryanvm@gmail.com
push date2015-05-18 18:53 +0000
treeherdermozilla-release@f44dff585598 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, jaws, lmandel
bugs1147487
milestone38.0.5
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.