Bug 1125364 - Check to make sure content window isn't null after paring document (Android patch). r=mfinkle
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Fri, 23 Jan 2015 15:58:53 -0800
changeset 239788 0219a6e83e4bba27ab785c8a80ce9ba6f1316cb4
parent 239787 eddbe152474e754687a0472e8524a708462d0858
child 239789 34cada2f7c27ff5c5c3574946422754ca64b0605
push id506
push usermleibovic@mozilla.com
push dateThu, 29 Jan 2015 12:40:10 +0000
reviewersmfinkle
bugs1125364
milestone38.0a1
Bug 1125364 - Check to make sure content window isn't null after paring document (Android patch). r=mfinkle
mobile/android/chrome/content/content.js
--- a/mobile/android/chrome/content/content.js
+++ b/mobile/android/chrome/content/content.js
@@ -61,22 +61,25 @@ let AboutReaderListener = {
           return;
         }
 
         // Reader mode is disabled until proven enabled.
         this._savedArticle = null;
         sendAsyncMessage("Reader:UpdateReaderButton", { isArticle: false });
 
         ReaderMode.parseDocument(content.document).then(article => {
+          // Do nothing if there is no article, or if the content window has been destroyed.
+          if (article === null || content === null) {
+            return;
+          }
+
           // The loaded page may have changed while we were parsing the document.
           // Make sure we've got the current one.
           let currentURL = Services.io.newURI(content.document.documentURI, null, null).specIgnoringRef;
-
-          // Do nothing if there's no article or the page in this tab has changed.
-          if (article == null || (article.url != currentURL)) {
+          if (article.url !== currentURL) {
             return;
           }
 
           this._savedArticle = article;
           sendAsyncMessage("Reader:UpdateReaderButton", { isArticle: true });
 
         }).catch(e => Cu.reportError("Error parsing document: " + e));
         break;