Bug 1496848 - Make RemoteWebProgressManager survive remote-to-remote process flips. r=Felipe
authorMike Conley <mconley@mozilla.com>
Fri, 05 Oct 2018 22:29:00 +0000
changeset 439873 c5bbbe511ec5
parent 439872 e9c7d14fc4a9
child 439874 2c3fc67d57b9
push id70494
push usermconley@mozilla.com
push dateFri, 05 Oct 2018 22:46:28 +0000
treeherderautoland@9f11d400d1cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFelipe
bugs1496848
milestone64.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 1496848 - Make RemoteWebProgressManager survive remote-to-remote process flips. r=Felipe For simplicity, we do not support remote-to-non-remote or non-remote-to-remote nsIWebProgressListener persistence. Differential Revision: https://phabricator.services.mozilla.com/D7936
devtools/client/responsive.html/browser/swap.js
toolkit/content/widgets/browser.xml
toolkit/modules/RemoteWebProgress.jsm
--- a/devtools/client/responsive.html/browser/swap.js
+++ b/devtools/client/responsive.html/browser/swap.js
@@ -401,16 +401,19 @@ function addXULBrowserDecorations(browse
   if (browser._remoteWebNavigationImpl == undefined) {
     browser._remoteWebNavigationImpl = {
       swapBrowser() {},
     };
   }
   if (browser._remoteWebProgressManager == undefined) {
     browser._remoteWebProgressManager = {
       swapBrowser() {},
+      get progressListeners() {
+        return [];
+      },
     };
   }
   if (browser._remoteWebProgress == undefined) {
     browser._remoteWebProgress = {
       addProgressListener() {},
       removeProgressListener() {},
     };
   }
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -1004,17 +1004,26 @@
             this.messageManager.addMessageListener("FullZoomChange", this);
             this.messageManager.addMessageListener("TextZoomChange", this);
             this.messageManager.addMessageListener("ZoomChangeUsingMouseWheel", this);
 
             // browser-child messages, such as Content:LocationChange, are handled in
             // RemoteWebProgress, ensure it is loaded and ready.
             let jsm = "resource://gre/modules/RemoteWebProgress.jsm";
             let { RemoteWebProgressManager } = ChromeUtils.import(jsm, {});
+
+            let oldManager = this._remoteWebProgressManager;
             this._remoteWebProgressManager = new RemoteWebProgressManager(this);
+            if (oldManager) {
+              // We're transitioning from one remote type to another. This means that
+              // the RemoteWebProgress listener is listening to the old message manager,
+              // and needs to be pointed at the new one.
+              this._remoteWebProgressManager.swapListeners(oldManager);
+            }
+
             this._remoteWebProgress = this._remoteWebProgressManager.topLevelWebProgress;
 
             this.messageManager.loadFrameScript("chrome://global/content/browser-child.js", true);
 
             if (this.hasAttribute("selectmenulist")) {
               this.messageManager.addMessageListener("Forms:ShowDropDown", this);
               this.messageManager.addMessageListener("Forms:HideDropDown", this);
             }
@@ -1065,16 +1074,21 @@
           // the other browser (and go through the proper getter and setter).
           if (this.hasOwnProperty("sameProcessAsFrameLoader")) {
             var sameProcessAsFrameLoader = this.sameProcessAsFrameLoader;
             delete this.sameProcessAsFrameLoader;
             this.sameProcessAsFrameLoader = sameProcessAsFrameLoader;
           }
 
           if (!this.isRemoteBrowser) {
+            // If we've transitioned from remote to non-remote, we'll give up trying to
+            // keep the web progress listeners persisted during the transition.
+            delete this._remoteWebProgressManager;
+            delete this._remoteWebProgress;
+
             this.addEventListener("pagehide", this.onPageHide, true);
           }
 
           if (this.messageManager) {
             this.messageManager.addMessageListener("PopupBlocking:UpdateBlockedPopups", this);
             this.messageManager.addMessageListener("Autoscroll:Start", this);
             this.messageManager.addMessageListener("Autoscroll:Cancel", this);
             this.messageManager.addMessageListener("AudioPlayback:Start", this);
--- a/toolkit/modules/RemoteWebProgress.jsm
+++ b/toolkit/modules/RemoteWebProgress.jsm
@@ -87,16 +87,26 @@ RemoteWebProgressManager.prototype = {
     this._messageManager.addMessageListener("Content:StateChange", this);
     this._messageManager.addMessageListener("Content:LocationChange", this);
     this._messageManager.addMessageListener("Content:SecurityChange", this);
     this._messageManager.addMessageListener("Content:StatusChange", this);
     this._messageManager.addMessageListener("Content:ProgressChange", this);
     this._messageManager.addMessageListener("Content:LoadURIResult", this);
   },
 
+  swapListeners(aOtherRemoteWebProgressManager) {
+    let temp = aOtherRemoteWebProgressManager.progressListeners;
+    aOtherRemoteWebProgressManager._progressListeners = this._progressListeners;
+    this._progressListeners = temp;
+  },
+
+  get progressListeners() {
+    return this._progressListeners;
+  },
+
   get topLevelWebProgress() {
     return this._topLevelWebProgress;
   },
 
   addProgressListener(aListener, aNotifyMask) {
     let listener = aListener.QueryInterface(Ci.nsIWebProgressListener);
     this._progressListeners.push({
       listener,