Bug 1139678 - (Part 3) Don't try interacting with the window in AboutReader if it has been unloaded. r=Gijs a=readinglist
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Tue, 17 Mar 2015 14:41:28 -0700
changeset 248432 b7c0318cd5b0ac571011aca8e6dfa1ad2298a52a
parent 248431 ead131a382fe5b74190dce9a0fca78c88563d192
child 248433 8492c9dae13c3f5ab25ea54b052393adafa6a8ca
push id7837
push userjwein@mozilla.com
push dateFri, 27 Mar 2015 00:27:16 +0000
treeherdermozilla-aurora@cb0db44ce60e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, readinglist
bugs1139678
milestone38.0a2
Bug 1139678 - (Part 3) Don't try interacting with the window in AboutReader if it has been unloaded. r=Gijs a=readinglist
toolkit/components/reader/AboutReader.jsm
--- a/toolkit/components/reader/AboutReader.jsm
+++ b/toolkit/components/reader/AboutReader.jsm
@@ -220,16 +220,17 @@ AboutReader.prototype = {
         this._handleVisibilityChange();
         break;
 
       case "unload":
         this._mm.removeMessageListener("Reader:Added", this);
         this._mm.removeMessageListener("Reader:Removed", this);
         this._mm.removeMessageListener("Sidebar:VisibilityChange", this);
         this._mm.removeMessageListener("ReadingList:VisibilityStatus", this);
+        this._windowUnloaded = true;
         break;
     }
   },
 
   _updateToggleButton: function Reader_updateToggleButton() {
     let button = this._doc.getElementById("toggle-button");
 
     if (this._isReadingListItem == 1) {
@@ -560,16 +561,20 @@ AboutReader.prototype = {
 
     let article;
     if (this._articlePromise) {
       article = yield this._articlePromise;
     } else {
       article = yield this._getArticle(url);
     }
 
+    if (this._windowUnloaded) {
+      return;
+    }
+
     if (article && article.url == url) {
       this._showContent(article);
     } else {
       this._win.location.href = url;
     }
   }),
 
   _getArticle: function(url) {
@@ -719,20 +724,21 @@ AboutReader.prototype = {
 
   _hideContent: function Reader_hideContent() {
     this._headerElement.style.display = "none";
     this._contentElement.style.display = "none";
   },
 
   _showProgressDelayed: function Reader_showProgressDelayed() {
     this._win.setTimeout(function() {
-      // Article has already been loaded, no need to show
-      // progress anymore.
-      if (this._article)
+      // No need to show progress if the article has been loaded,
+      // or if the window has been unloaded.
+      if (this._article || this._windowUnloaded) {
         return;
+      }
 
       this._headerElement.style.display = "none";
       this._contentElement.style.display = "none";
 
       this._messageElement.innerHTML = gStrings.GetStringFromName("aboutReader.loading");
       this._messageElement.style.display = "block";
     }.bind(this), 300);
   },