Bug 726301: SummaryFrameManager logic is wrong r=squib,a=Standard8
authorJonathan Protzenko <jonathan.protzenko@gmail.com>
Tue, 14 Feb 2012 09:03:49 +0100
changeset 10175 f1f57e95314c50a862cbfae578eed557b92e482c
parent 10174 5e76697585898561fce46452894e91d8a4ffa548
child 10176 f3400b6e0c7eec79638554981cec87df79426b84
child 10181 2c181a24360fa42c93eae88012d4b2eea537bcca
push idunknown
push userunknown
push dateunknown
reviewerssquib, Standard8
bugs726301
Bug 726301: SummaryFrameManager logic is wrong r=squib,a=Standard8
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);
     }
   }
 };