Bug 1458327 - 4. Always register some events / frame scripts; r=esawin
authorJim Chen <nchen@mozilla.com>
Fri, 04 May 2018 21:08:10 -0400
changeset 473115 3647f62ed6b6f4a45120208a4a1423791ce672e6
parent 473114 5ab8f1a1eb577852a578f643958b8008921da806
child 473116 3e1d4faf82ad10e52917fa47a61fc6b67537c27e
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1458327
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 1458327 - 4. Always register some events / frame scripts; r=esawin The problem is we rely on some events / frame scripts for session calls that should still work even if we don't have a delegate assigned, so we should always register these events / frame scripts. MozReview-Commit-ID: 6TvvMhc7qOf
mobile/android/chrome/geckoview/GeckoViewContent.js
mobile/android/chrome/geckoview/GeckoViewNavigationContent.js
mobile/android/modules/geckoview/GeckoViewContent.jsm
mobile/android/modules/geckoview/GeckoViewContentModule.jsm
--- a/mobile/android/chrome/geckoview/GeckoViewContent.js
+++ b/mobile/android/chrome/geckoview/GeckoViewContent.js
@@ -18,56 +18,48 @@ XPCOMUtils.defineLazyModuleGetters(this,
 class GeckoViewContent extends GeckoViewContentModule {
   onInit() {
     debug `onInit`;
 
     this.messageManager.addMessageListener("GeckoView:SaveState",
                                            this);
     this.messageManager.addMessageListener("GeckoView:RestoreState",
                                            this);
+    this.messageManager.addMessageListener("GeckoView:DOMFullscreenEntered",
+                                           this);
+    this.messageManager.addMessageListener("GeckoView:DOMFullscreenExited",
+                                           this);
+    this.messageManager.addMessageListener("GeckoView:ZoomToInput",
+                                           this);
   }
 
   onEnable() {
     debug `onEnable`;
 
     addEventListener("DOMTitleChanged", this, false);
     addEventListener("DOMWindowFocus", this, false);
     addEventListener("DOMWindowClose", this, false);
     addEventListener("MozDOMFullscreen:Entered", this, false);
     addEventListener("MozDOMFullscreen:Exit", this, false);
     addEventListener("MozDOMFullscreen:Exited", this, false);
     addEventListener("MozDOMFullscreen:Request", this, false);
     addEventListener("contextmenu", this, { capture: true });
-
-    this.messageManager.addMessageListener("GeckoView:DOMFullscreenEntered",
-                                           this);
-    this.messageManager.addMessageListener("GeckoView:DOMFullscreenExited",
-                                           this);
-    this.messageManager.addMessageListener("GeckoView:ZoomToInput",
-                                           this);
   }
 
   onDisable() {
     debug `onDisable`;
 
     removeEventListener("DOMTitleChanged", this);
     removeEventListener("DOMWindowFocus", this);
     removeEventListener("DOMWindowClose", this);
     removeEventListener("MozDOMFullscreen:Entered", this);
     removeEventListener("MozDOMFullscreen:Exit", this);
     removeEventListener("MozDOMFullscreen:Exited", this);
     removeEventListener("MozDOMFullscreen:Request", this);
     removeEventListener("contextmenu", this, { capture: true });
-
-    this.messageManager.removeMessageListener("GeckoView:DOMFullscreenEntered",
-                                              this);
-    this.messageManager.removeMessageListener("GeckoView:DOMFullscreenExited",
-                                              this);
-    this.messageManager.removeMessageListener("GeckoView:ZoomToInput",
-                                              this);
   }
 
   collectSessionState() {
     let history = SessionHistory.collect(docShell);
     let [formdata, scrolldata] = Utils.mapFrameTree(content, FormData.collect, ScrollPosition.collect);
 
     // Save the current document resolution.
     let zoom = { value: 1 };
--- a/mobile/android/chrome/geckoview/GeckoViewNavigationContent.js
+++ b/mobile/android/chrome/geckoview/GeckoViewNavigationContent.js
@@ -8,16 +8,20 @@ ChromeUtils.import("resource://gre/modul
 
 XPCOMUtils.defineLazyModuleGetters(this, {
   ErrorPageEventHandler: "chrome://geckoview/content/ErrorPageEventHandler.js",
   LoadURIDelegate: "resource://gre/modules/LoadURIDelegate.jsm",
 });
 
 // Implements nsILoadURIDelegate.
 class GeckoViewNavigationContent extends GeckoViewContentModule {
+  onInit() {
+    this.onEnable();
+  }
+
   onEnable() {
     debug `onEnable`;
 
     docShell.loadURIDelegate = this;
   }
 
   onDisable() {
     debug `onDisable`;
--- a/mobile/android/modules/geckoview/GeckoViewContent.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewContent.jsm
@@ -6,50 +6,45 @@
 
 var EXPORTED_SYMBOLS = ["GeckoViewContent"];
 
 ChromeUtils.import("resource://gre/modules/GeckoViewModule.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 class GeckoViewContent extends GeckoViewModule {
   onInit() {
-    this.eventDispatcher.registerListener(this, [
-      "GeckoView:SetActive",
-      "GeckoView:SaveState",
-      "GeckoView:RestoreState"
+    this.registerListener([
+        "GeckoViewContent:ExitFullScreen",
+        "GeckoView:RestoreState",
+        "GeckoView:SaveState",
+        "GeckoView:SetActive",
+        "GeckoView:ZoomToInput",
     ]);
 
     this.messageManager.addMessageListener("GeckoView:SaveStateFinish", this);
+
+    this.registerContent("chrome://geckoview/content/GeckoViewContent.js");
   }
 
   onEnable() {
-    this.registerContent("chrome://geckoview/content/GeckoViewContent.js");
-
     this.window.addEventListener("MozDOMFullScreen:Entered", this,
                                  /* capture */ true, /* untrusted */ false);
     this.window.addEventListener("MozDOMFullScreen:Exited", this,
                                  /* capture */ true, /* untrusted */ false);
 
-    this.registerListener([
-        "GeckoViewContent:ExitFullScreen",
-        "GeckoView:ZoomToInput",
-    ]);
-
     this.messageManager.addMessageListener("GeckoView:DOMFullscreenExit", this);
     this.messageManager.addMessageListener("GeckoView:DOMFullscreenRequest", this);
   }
 
   onDisable() {
     this.window.removeEventListener("MozDOMFullScreen:Entered", this,
                                     /* capture */ true);
     this.window.removeEventListener("MozDOMFullScreen:Exited", this,
                                     /* capture */ true);
 
-    this.unregisterListener();
-
     this.messageManager.removeMessageListener("GeckoView:DOMFullscreenExit", this);
     this.messageManager.removeMessageListener("GeckoView:DOMFullscreenRequest", this);
   }
 
   // Bundle event handler.
   onEvent(aEvent, aData, aCallback) {
     debug `onEvent: event=${aEvent}, data=${aData}`;
 
--- a/mobile/android/modules/geckoview/GeckoViewContentModule.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewContentModule.jsm
@@ -47,31 +47,32 @@ class GeckoViewContentModule {
       }
     );
     this.messageManager.addMessageListener(
       "GeckoView:Register",
       aMsg => {
         if (aMsg.data.module == this.moduleName) {
           this.settings = aMsg.data.settings;
           this.onEnable();
-          this.messageManager.sendAsyncMessage(
-            "GeckoView:ContentRegistered", { module: this.moduleName });
         }
       }
     );
     this.messageManager.addMessageListener(
       "GeckoView:Unregister",
       aMsg => {
         if (aMsg.data.module == this.moduleName) {
           this.onDisable();
         }
       }
     );
 
     this.onInit();
+
+    this.messageManager.sendAsyncMessage(
+      "GeckoView:ContentRegistered", { module: this.moduleName });
   }
 
   // Override to initialize module.
   onInit() {}
 
   // Override to detect settings change. Access settings via this.settings.
   onSettingsUpdate() {}