Bug 1441810 - Ensure session save/restore works even if no ContentDelegate is set. r=jchen
authorDylan Roeh <droeh@mozilla.com>
Wed, 25 Apr 2018 09:39:52 -0500
changeset 415637 2197be608baf332f861a4a5a5fc75a6b9dca3786
parent 415636 b3fc868b50a2d8879b2136e32ea90253ed6b3f28
child 415638 1b29fa5bb80221c4ef0b70851de5c0b4bad078a6
push id33901
push userapavel@mozilla.com
push dateThu, 26 Apr 2018 06:05:37 +0000
treeherdermozilla-central@b62ad926cf2a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1441810
milestone61.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 1441810 - Ensure session save/restore works even if no ContentDelegate is set. r=jchen
mobile/android/chrome/geckoview/GeckoViewContent.js
mobile/android/modules/geckoview/GeckoViewContent.jsm
--- a/mobile/android/chrome/geckoview/GeckoViewContent.js
+++ b/mobile/android/chrome/geckoview/GeckoViewContent.js
@@ -36,21 +36,16 @@ class GeckoViewContent extends GeckoView
     addEventListener("contextmenu", this, { capture: true });
 
     this.messageManager.addMessageListener("GeckoView:DOMFullscreenEntered",
                                            this);
     this.messageManager.addMessageListener("GeckoView:DOMFullscreenExited",
                                            this);
     this.messageManager.addMessageListener("GeckoView:ZoomToInput",
                                            this);
-
-    this.progressFilter =
-      Cc["@mozilla.org/appshell/component/browser-status-filter;1"]
-      .createInstance(Ci.nsIWebProgress);
-    this.flags = Ci.nsIWebProgress.NOTIFY_LOCATION;
   }
 
   onDisable() {
     debug `onDisable`;
 
     removeEventListener("DOMTitleChanged", this);
     removeEventListener("DOMWindowFocus", this);
     removeEventListener("DOMWindowClose", this);
@@ -201,16 +196,23 @@ class GeckoViewContent extends GeckoView
         this._savedState = JSON.parse(aMsg.data.state);
 
         if (this._savedState.history) {
           let restoredHistory = SessionHistory.restore(docShell, this._savedState.history);
 
           addEventListener("load", this, {capture: true, mozSystemGroup: true, once: true});
           addEventListener("pageshow", this, {capture: true, mozSystemGroup: true, once: true});
 
+          if (!this.progressFilter) {
+            this.progressFilter =
+              Cc["@mozilla.org/appshell/component/browser-status-filter;1"]
+              .createInstance(Ci.nsIWebProgress);
+            this.flags = Ci.nsIWebProgress.NOTIFY_LOCATION;
+          }
+
           this.progressFilter.addProgressListener(this, this.flags);
           let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
                                     .getInterface(Ci.nsIWebProgress);
           webProgress.addProgressListener(this.progressFilter, this.flags);
 
           restoredHistory.QueryInterface(Ci.nsISHistory).reloadCurrentEntry();
         }
         break;
--- a/mobile/android/modules/geckoview/GeckoViewContent.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewContent.jsm
@@ -11,16 +11,18 @@ ChromeUtils.import("resource://gre/modul
 
 class GeckoViewContent extends GeckoViewModule {
   onInit() {
     this.eventDispatcher.registerListener(this, [
       "GeckoView:SetActive",
       "GeckoView:SaveState",
       "GeckoView:RestoreState"
     ]);
+
+    this.messageManager.addMessageListener("GeckoView:SaveStateFinish", this);
   }
 
   onEnable() {
     this.registerContent("chrome://geckoview/content/GeckoViewContent.js");
 
     this.window.addEventListener("MozDOMFullScreen:Entered", this,
                                  /* capture */ true, /* untrusted */ false);
     this.window.addEventListener("MozDOMFullScreen:Exited", this,
@@ -28,17 +30,16 @@ class GeckoViewContent extends GeckoView
 
     this.registerListener([
         "GeckoViewContent:ExitFullScreen",
         "GeckoView:ZoomToInput",
     ]);
 
     this.messageManager.addMessageListener("GeckoView:DOMFullscreenExit", this);
     this.messageManager.addMessageListener("GeckoView:DOMFullscreenRequest", this);
-    this.messageManager.addMessageListener("GeckoView:SaveStateFinish", this);
   }
 
   onDisable() {
     this.window.removeEventListener("MozDOMFullScreen:Entered", this,
                                     /* capture */ true);
     this.window.removeEventListener("MozDOMFullScreen:Exited", this,
                                     /* capture */ true);