Bug 898170 - nsIWebProgress.isToplevel should be true when not notifying listeners (r=billm)
authorFelipe Gomes <felipc@gmail.com>
Fri, 26 Jul 2013 14:26:43 -0700
changeset 152501 be0befd009cb1b598531025b16f3ee375ee46655
parent 152500 3aef6df154540cc214bf586aeca5527942aac4df
child 152502 7c02ec2b89883536305b1de12d8a1c0cf25cdfc5
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs898170
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 898170 - nsIWebProgress.isToplevel should be true when not notifying listeners (r=billm)
toolkit/modules/RemoteWebProgress.jsm
--- a/toolkit/modules/RemoteWebProgress.jsm
+++ b/toolkit/modules/RemoteWebProgress.jsm
@@ -23,17 +23,17 @@ RemoteWebProgressRequest.prototype = {
   get URI() { return this.uri.clone(); }
 };
 
 function RemoteWebProgress(browser)
 {
   this._browser = browser;
   this._isDocumentLoading = false;
   this._DOMWindow = null;
-  this._isTopLevel = true;
+  this._isTopLevel = null;
   this._progressListeners = [];
 }
 
 RemoteWebProgress.prototype = {
   NOTIFY_STATE_REQUEST:  0x00000001,
   NOTIFY_STATE_DOCUMENT: 0x00000002,
   NOTIFY_STATE_NETWORK:  0x00000004,
   NOTIFY_STATE_WINDOW:   0x00000008,
@@ -54,17 +54,25 @@ RemoteWebProgress.prototype = {
 
   _destroy: function WP_Destroy() {
     this._browser = null;
   },
 
   get isLoadingDocument() { return this._isDocumentLoading },
   get DOMWindow() { return this._DOMWindow; },
   get DOMWindowID() { return 0; },
-  get isTopLevel() { return this._isTopLevel; },
+  get isTopLevel() {
+    // When this object is accessed directly, it's usually obtained
+    // through browser.webProgress and thus represents the top-level
+    // document.
+    // However, during message handling it temporarily represents
+    // the webProgress that generated the notification, which may or
+    // may not be a toplevel frame.
+    return this._isTopLevel === null ? true : this._isTopLevel;
+  },
 
   addProgressListener: function WP_AddProgressListener (aListener) {
     let listener = aListener.QueryInterface(Ci.nsIWebProgressListener);
     this._progressListeners.push(listener);
   },
 
   removeProgressListener: function WP_RemoveProgressListener (aListener) {
     this._progressListeners =
@@ -119,10 +127,12 @@ RemoteWebProgress.prototype = {
       break;
 
     case "Content:StatusChange":
       for each (let p in this._progressListeners) {
         p.onStatusChange(this, req, aMessage.json.status, aMessage.json.message);
       }
       break;
     }
+
+    this._isTopLevel = null;
   }
 };