bug 1533831: remote: disable remote agent; r=ochameau
authorAndreas Tolfsen <ato@sny.no>
Wed, 24 Apr 2019 17:18:37 +0000
changeset 471180 8d48c69e7f8e52eec5a7188e343eb6796575dd74
parent 471179 da2d4529a200f41df8978b0310f1f1c9d7f9cb4e
child 471181 242ca1013e276fa1b75ebe777b615f1875ccdea6
push id35912
push userbtara@mozilla.com
push dateThu, 25 Apr 2019 09:46:25 +0000
treeherdermozilla-central@0ec836eceb96 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1533831
milestone68.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 1533831: remote: disable remote agent; r=ochameau This disables the remote agent through flipping the remote.enabled preference to false. This will cause the help text to disappear from --help and the RemoteAgent#init() (in remote/RemoteAgent.jsm) to fail. We also change RemoteAgent.jsm to being loaded lazily so that it isn't imported. Differential Revision: https://phabricator.services.mozilla.com/D27539
remote/README
remote/command-line-handler.js
remote/doc/Building.md
remote/doc/Debugging.md
remote/doc/Prefs.md
remote/doc/Testing.md
remote/pref/remote.js
remote/test/browser/browser.ini
--- a/remote/README
+++ b/remote/README
@@ -15,9 +15,9 @@ See https://firefox-source-docs.mozilla.
 The remote agent is not by default included in Firefox builds.  To
 build it, put this in your mozconfig:
 
 	ac_add_options --enable-cdp
 
 This exposes a --remote-debugger flag you can use to start the
 remote agent:
 
-	% ./mach run --remote-debugger
+	% ./mach run --setpref "remote.enabled=true" --remote-debugger
--- a/remote/command-line-handler.js
+++ b/remote/command-line-handler.js
@@ -1,24 +1,31 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 // Stopgap module until we can land bug 1536862 and remove this temporary file
 
-const {RemoteAgent} = ChromeUtils.import("chrome://remote/content/RemoteAgent.jsm");
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
+ChromeUtils.defineModuleGetter(this, "RemoteAgent",
+    "chrome://remote/content/RemoteAgent.jsm");
+
 const RemoteAgentFactory = {
   createInstance(outer, iid) {
     if (outer) {
       throw Cr.NS_ERROR_NO_AGGREGATION;
     }
+    // we can't use Preferences.jsm before first paint
+    if (!Services.prefs.getBoolPref("remote.enabled")) {
+      return {};
+    }
 
     return RemoteAgent.QueryInterface(iid);
   },
 };
 
 function RemoteAgentComponent() {}
 
 RemoteAgentComponent.prototype = {
--- a/remote/doc/Building.md
+++ b/remote/doc/Building.md
@@ -4,17 +4,17 @@ Building
 The remote agent is by default not included in Firefox builds.
 To build it, put this in your [mozconfig]:
 
 	ac_add_options --enable-cdp
 
 This exposes a `--remote-debugger` flag you can use to start the
 remote agent:
 
-	% ./mach run --remote-debugger
+	% ./mach run --setpref="remote.enabled=true" --remote-debugger
 
 When you make changes to the XPCOM component you need to rebuild
 in order for the changes to take effect.  The most efficient way to
 do this, provided you haven’t touched any compiled code (C++ or Rust):
 
 	% ./mach build faster
 
 Component files include the likes of RemoteAgent.js, RemoteAgent.manifest,
--- a/remote/doc/Debugging.md
+++ b/remote/doc/Debugging.md
@@ -4,11 +4,11 @@ Debugging
 Increasing the logging verbosity
 --------------------------------
 
 To increase the internal logging verbosity you can use the
 `remote.log.level` [preference].
 
 If you use mach to start the Firefox:
 
-	./mach run --setpref "remote.log.level=Debug" --remote-debugger
+	./mach run --setpref "remote.enabled=true" --setpref "remote.log.level=Debug" --remote-debugger
 
 [preference]: ./Prefs.md
--- a/remote/doc/Prefs.md
+++ b/remote/doc/Prefs.md
@@ -5,19 +5,21 @@ There are a couple of preferences associ
 
 
 Configurable preferences
 ------------------------
 
 ### `remote.enabled`
 
 Indicates whether the remote agent is enabled.  When the remote
-agent is enabled, it exposes a `--remote-debugger` flag for Firefox.
+agent is enabled, it exposes a [`--remote-debugger` flag] for Firefox.
 When set to false, the remote agent will not be loaded on startup.
 
+[`--remote-debugger` flag]: Usage.html
+
 ### `remote.force-local`
 
 Limits the remote agent to be allowed to listen on loopback devices,
 e.g. 127.0.0.1, localhost, and ::1.
 
 ### `remote.log.level`
 
 Defines the verbosity of the internal logger.  Available levels
--- a/remote/doc/Testing.md
+++ b/remote/doc/Testing.md
@@ -1,35 +1,35 @@
 Testing
 =======
 
 The remote agent has unit- and functional tests located under
 `remote/test/{unit,browser}`.
 
 You may run all the tests locally using `mach test` like this:
 
-	% ./mach test remote/test
+	% ./mach test --setpref "remote.enabled=true" remote/test
 
 The tests are currently not run on try.
 
 
 Unit tests
 ----------
 
 Because tests are run in parallel and [xpcshell] itself is quite
 chatty, it can sometimes be useful to run the tests in sequence:
 
-	% ./mach xcpshell --sequential remote/test/unit/test_Assert.js
+	% ./mach xcpshell-test --setpref "remote.enabled=true" --sequential remote/test/unit/test_Assert.js
 
 The unit tests will appear as part of the `X` jobs on Treeherder.
 
 [xpcshell]: https://developer.mozilla.org/en-US/docs/Mozilla/QA/Writing_xpcshell-based_unit_tests
 
 
 Functional tests
 ----------------
 
 We also have a set of functional [browser chrome] tests located
 under _remote/test/browser_:
 
-	% ./mach mochitest -f browser remote/test/browser/browser_cdp.js
+	% ./mach mochitest --setpref "remote.enabled=true" -f browser remote/test/browser/browser_cdp.js
 
 [browser chrome]: https://developer.mozilla.org/en-US/docs/Mozilla/Browser_chrome_tests
--- a/remote/pref/remote.js
+++ b/remote/pref/remote.js
@@ -1,11 +1,11 @@
 // Indicates whether the remote agent is enabled.
 // If it is false, the remote agent will not be loaded.
-pref("remote.enabled", true);
+pref("remote.enabled", false);
 
 // Limits remote agent to listen on loopback devices,
 // e.g. 127.0.0.1, localhost, and ::1.
 pref("remote.force-local", true);
 
 // Defines the verbosity of the internal logger.
 //
 // Available levels are, in descending order of severity,
--- a/remote/test/browser/browser.ini
+++ b/remote/test/browser/browser.ini
@@ -1,11 +1,12 @@
 [DEFAULT]
 tags = remote
 subsuite = remote
+prefs = remote.enabled=true
 support-files =
   chrome-remote-interface.js
   head.js
 
 [browser_cdp.js]
 [browser_main_target.js]
 [browser_tabs.js]
 [browser_target.js]