Bug 1454441 - 4. Fix Fennec remote debugging; r=esawin
☠☠ backed out by 85d1752bed2e ☠ ☠
authorJim Chen <nchen@mozilla.com>
Fri, 20 Apr 2018 15:51:30 -0400
changeset 468326 d924aed5046046f3530d1e3f24e60acab505f64c
parent 468325 976d9622bf5c466e38ae1b28a027d8d6157dec69
child 468327 d625d007d1249a1ce8f9cca281f57931882f2e13
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1454441
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 1454441 - 4. Fix Fennec remote debugging; r=esawin Currently Fennec remote debugging has a bug where custom tabs / PWA can permanently override debugging of Fennec tabs. Fix that bug by switching between the browser/geckoview window types depending on if the Fennec window is gaining or losing focus. MozReview-Commit-ID: KEXPwAfl32X
mobile/android/chrome/content/RemoteDebugger.js
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/RemoteDebugger.js
+++ b/mobile/android/chrome/content/RemoteDebugger.js
@@ -7,19 +7,40 @@
 
 XPCOMUtils.defineLazyGetter(this, "DebuggerServer", () => {
   let { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
   let { DebuggerServer } = require("devtools/server/main");
   return DebuggerServer;
 });
 
 var RemoteDebugger = {
-  init() {
+  init(aWindow) {
+    this._windowType = "navigator:browser";
+
     USBRemoteDebugger.init();
     WiFiRemoteDebugger.init();
+
+    const listener = (event) => {
+      if (event.target !== aWindow) {
+        return;
+      }
+
+      const newType = (event.type === "activate") ? "navigator:browser"
+                                                  : "navigator:geckoview";
+      if (this._windowType === newType) {
+        return;
+      }
+
+      this._windowType = newType;
+      if (this.isAnyEnabled) {
+        this.initServer();
+      }
+    };
+    aWindow.addEventListener("activate", listener, { mozSystemGroup: true });
+    aWindow.addEventListener("deactivate", listener, { mozSystemGroup: true });
   },
 
   get isAnyEnabled() {
     return USBRemoteDebugger.isEnabled || WiFiRemoteDebugger.isEnabled;
   },
 
   /**
    * Prompt the user to accept or decline the incoming connection.
@@ -179,16 +200,17 @@ var RemoteDebugger = {
     DebuggerServer.init();
 
     // Add browser and Fennec specific actors
     DebuggerServer.registerAllActors();
     DebuggerServer.registerModule("resource://gre/modules/dbg-browser-actors.js");
 
     // Allow debugging of chrome for any process
     DebuggerServer.allowChromeProcess = true;
+    DebuggerServer.chromeWindowType = this._windowType;
   }
 };
 
 RemoteDebugger.allowConnection =
   RemoteDebugger.allowConnection.bind(RemoteDebugger);
 RemoteDebugger.receiveOOB =
   RemoteDebugger.receiveOOB.bind(RemoteDebugger);
 
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -423,17 +423,17 @@ var BrowserApp = {
       }
     });
 
     NativeWindow.init();
     IndexedDB.init();
     XPInstallObserver.init();
     CharacterEncoding.init();
     ActivityObserver.init();
-    RemoteDebugger.init();
+    RemoteDebugger.init(window);
     DesktopUserAgent.init();
     Distribution.init();
     Tabs.init();
     SearchEngines.init();
     Experiments.init();
 
     // XXX maybe we don't do this if the launch was kicked off from external
     Services.io.offline = false;