Bug 726301: SummaryFrameManager logic is wrong r=squib
authorJonathan Protzenko <jonathan.protzenko@gmail.com>
Tue, 14 Feb 2012 09:03:49 +0100
changeset 10828 e4fa0ccbfb0345e872109aff091a1f556975d3bb
parent 10827 06c52cc3c7f9661345d607f62ff43d8e5ad971ee
child 10829 e887b06284816a8528ae8874f849bc841bef25f7
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssquib
bugs726301
Bug 726301: SummaryFrameManager logic is wrong r=squib
mail/base/modules/summaryFrameManager.js
--- a/mail/base/modules/summaryFrameManager.js
+++ b/mail/base/modules/summaryFrameManager.js
@@ -48,16 +48,19 @@ const EXPORTED_SYMBOLS = ["SummaryFrameM
  *
  * @param aFrame the iframe that we're managing
  */
 function SummaryFrameManager(aFrame) {
   this.iframe = aFrame;
   this.iframe.addEventListener("DOMContentLoaded", this._onLoad.bind(this),
                                true);
   this.pendingCallback = null;
+  this.pendingOrLoadedUrl = this.iframe.docShell
+    ? this.iframe.contentDocument.location.href
+    : "about:blank";
   this.callback = null;
   this.url = "";
 }
 
 SummaryFrameManager.prototype = {
   /**
    * Clear the summary frame.
    */
@@ -71,22 +74,23 @@ SummaryFrameManager.prototype = {
    * is already loaded.
    *
    * @param aUrl the URL to load
    * @param aCallback the callback to run when the URL has loaded; this function
    *        is passed a single boolean indicating if the URL was changed
    */
   loadAndCallback: function(aUrl, aCallback) {
     this.url = aUrl;
-    if (this.iframe.contentDocument.location.href != aUrl) {
+    if (this.pendingOrLoadedUrl != aUrl) {
       // We're changing the document. Stash the callback that we want to call
       // when it's done loading
       this.pendingCallback = aCallback;
       this.callback = null; // clear it
       this.iframe.contentDocument.location.href = aUrl;
+      this.pendingOrLoadedUrl = aUrl;
     }
     else {
       // We're being called, but the document has been set already -- either
       // we've already received the DOMContentLoaded event, in which case we can
       // just call the callback directly, or we're still loading in which case
       // we should just wait for the dom event handler, but update the callback.
 
       if (!this.pendingCallback) {
@@ -105,16 +109,20 @@ SummaryFrameManager.prototype = {
     try {
       // Make sure we're responding to the summary frame being loaded, and not
       // some subnode.
       if (event.originalTarget != this.iframe.contentDocument)
         return;
 
       this.callback = this.pendingCallback;
       this.pendingCallback = null;
-      if (this.callback)
+      if (this.pendingOrLoadedUrl != this.iframe.contentDocument.location.href)
+        Components.utils.reportError(
+          "Please do not load stuff in the multimessage browser directly, "+
+          "use the SummaryFrameManager instead.");
+      else if (this.callback)
         this.callback(true);
     }
     catch (e) {
       Components.utils.reportError(e);
     }
   }
 };