bug 1544393: remote: ship remote agent in Firefox Nightly r=remote-protocol-reviewers,whimboo,maja_zf
authorAndreas Tolfsen <ato@sny.no>
Mon, 02 Dec 2019 15:39:51 +0000
changeset 505117 5a69d75cf9b12a85b66c844eb8758b41f1e13db5
parent 505116 45ad5d36d9241f40bccabd897ba7c99ca21bf2a5
child 505118 6e9e91f92efdaecf48a87d512a0c881340b70fe1
push id36879
push userncsoregi@mozilla.com
push dateTue, 03 Dec 2019 21:53:45 +0000
treeherdermozilla-central@3c08edf74d03 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersremote-protocol-reviewers, whimboo, maja_zf
bugs1544393, 1542229
milestone73.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 1544393: remote: ship remote agent in Firefox Nightly r=remote-protocol-reviewers,whimboo,maja_zf Now that the security review in bug 1542229 and the follow-up work that came out of it is complete, we should go ahead and flip the remote.enabled preference. This patch causes the remote agent to be available to users on the Firefox Nightly release channel. This meansusing --remote-debugger will no longer cause a fatal error Differential Revision: https://phabricator.services.mozilla.com/D55137
modules/libpref/init/all.js
remote/README
remote/doc/Building.md
remote/doc/Debugging.md
remote/doc/Security.md
remote/doc/Usage.md
remote/test/demo.js
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4843,23 +4843,29 @@ pref("marionette.port", 2828);
 pref("marionette.prefs.recommended", true);
 
 // Whether content scripts can be safely reused.
 //
 // Deprecated and scheduled for removal with
 // https://bugzil.la/marionette-window-tracking
 pref("marionette.contentListener", false);
 
-// Indicates whether the remote agent is enabled. If it is false, the remote
-// agent will not be loaded.
-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);
+#if defined(ENABLE_REMOTE_AGENT)
+  // Indicates whether the remote agent is enabled.
+  // If it is false, the remote agent will not be loaded.
+  #if defined(NIGHTLY_BUILD)
+    pref("remote.enabled", true);
+  #else
+    pref("remote.enabled", false);
+  #endif
+
+  // Limits remote agent to listen on loopback devices,
+  // e.g. 127.0.0.1, localhost, and ::1.
+  pref("remote.force-local", true);
+#endif
 
 // Defines the verbosity of the internal logger.
 //
 // Available levels are, in descending order of severity, "Trace", "Debug",
 // "Config", "Info", "Warn", "Error", and "Fatal". The value is treated
 // case-sensitively.
 pref("remote.log.level", "Info");
 
--- a/remote/README
+++ b/remote/README
@@ -7,12 +7,11 @@ simulate user interaction for automation
 JavaScript execution.
 
 This component provides an experimental and partial implementation
 of a remote devtools interface using the CDP protocol and transport
 layer.
 
 See https://firefox-source-docs.mozilla.org/remote/ for documentation.
 
-The remote agent is disabled by default, but can be enabled by
-setting a preference before running it:
+It is available in Firefox Nightly and is started this way:
 
-	% ./mach run --setpref "remote.enabled=true" --remote-debugger
+	% ./mach run --remote-debugger
--- a/remote/doc/Building.md
+++ b/remote/doc/Building.md
@@ -1,18 +1,19 @@
 Building
 ========
 
-The remote agent is included in the default Firefox build, but
-disabled by default.  To expose the remote agent you can set the
-`remote.enabled` preference to true before running it:
+The remote agent is included in the default Firefox build, but only
+ships on the Firefox Nightly release channel:
 
-	% ./mach run --setpref="remote.enabled=true" --remote-debugger
+	% ./mach run --remote-debugger
 
-The source code is found under `$(topsrcdir)/remote`.
+The source code can be found under [remote/ in central].
+
+There are two build modes to choose from:
 
 Full build mode
 ---------------
 
 The remote agent supports only Firefox, and is included when you
 build in the usual way:
 
 	% ./mach build
@@ -42,10 +43,11 @@ Artifact mode
 You may also use [artifact builds] when working on the remote agent.
 This fast build mode downloads pre-built components from the Mozilla
 build servers, rendering local compilation unnecessary.  To use
 them, place this in your [mozconfig]:
 
 	ac_add_options --enable-artifact-builds
 
 
+[remote/ in central]: https://searchfox.org/mozilla-central/source/remote
 [mozconfig]: ../build/buildsystem/mozconfigs.html
 [artifact builds]: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions/Artifact_builds
--- a/remote/doc/Debugging.md
+++ b/remote/doc/Debugging.md
@@ -5,27 +5,27 @@ 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 Firefox:
 
-	./mach run --setpref "remote.enabled=true" --setpref "remote.log.level=Debug" --remote-debugger
+	./mach run --setpref "remote.log.level=Debug" --remote-debugger
 
 
 Enabling logging of emitted events
 ----------------------------------
 
 To dump events produced by EventEmitter,
 including CDP events produced by the remote agent,
 you can use the `toolkit.dump.emit` [preference]:
 
-    ./mach run --setpref "remote.enabled=true" --setpref "toolkit.dump.emit=true" --remote-debugger
+    ./mach run --setpref "toolkit.dump.emit=true" --remote-debugger
 
 
 Logging observer notifications
 ------------------------------
 
 [System observer notifications] are used extensively throughout the
 code and it can sometimes be useful to log these to see what is
 available and when they are fired.
--- a/remote/doc/Security.md
+++ b/remote/doc/Security.md
@@ -86,13 +86,14 @@ Security model
 It shares the same security model as DevTools and Marionette, in
 that there is no other mechanism for enabling the remote agent than
 by passing a command-line flag.
 
 It is our assumption that if an attacker has shell access to the
 user account, there is little we can do to prevent secrets from
 being accessed or leaked.
 
-The preference `remote.enabled` defaults to false in Nightly, and
-it is the purpose to flip this to true to ship the remote agent for
-Firefox Nightly users following [a security review].
+The preference `remote.enabled` is true on the Firefox Nightly
+release channel.  The [security review] was completed in November
+2019.
 
-[a security review]: https://bugzilla.mozilla.org/show_bug.cgi?id=1542229
+
+[security review]: https://bugzilla.mozilla.org/show_bug.cgi?id=1542229
--- a/remote/doc/Usage.md
+++ b/remote/doc/Usage.md
@@ -9,31 +9,36 @@ three different programs/components runn
     and retrieve information out of Firefox;
 
   * the __agent__ that the client connects to which is an HTTPD living
     inside Firefox, facilitating communication between clients
     and targets;
 
   * and the __target__, which is the web document being debugging.
 
-The remote agent currently only ships with builds of [Firefox
-Nightly] and is __not enabled by default__.  To enable it, you must
-flip the [`remote.enabled` preference] to true.
+The remote agent ships in [Firefox Nightly] only.
 
 To check if your Firefox binary has the remote agent enabled, you
 can look in its help message for this:
 
 	% ./firefox -h

 	  --remote-debugging-port <port>
 	  --remote-debugger [<host>][:<port>] Start the Firefox remote agent, which is
 	                     a low-level debugging interface based on the CDP protocol.
 	                     Defaults to listen on localhost:9222.

 
+When used, the remote agent will start an HTTP server and print a
+message on stderr with the location of the main target’s WebSocket
+listener:
+
+	% firefox --remote-debugger
+	DevTools listening on ws://localhost:9222/devtools/browser/7b4e84a4-597f-4839-ac6d-c9e86d16fb83
+
 As you will tell from the flag description, `--remote-debugger`
 takes an optional address spec as input:
 
 	[<host>][:<port>]
 
 You can use this to instruct the remote agent to bind to a particular
 interface and port on your system.  Either host and port are optional,
 which means `./firefox --remote-debugger` will bind the HTTPD to
@@ -60,9 +65,8 @@ free port.
 
 Allocating an atomic port can be useful if you want to avoid race
 conditions.  The atomically allocated port will be somewhere in the
 ephemeral port range, which varies depending on your system and
 system configuration, but is always guaranteed to be free thus
 eliminating the risk of binding to a port that is already in use.
 
 [Firefox Nightly]: https://www.mozilla.org/en-GB/firefox/channel/desktop/#nightly
-[`remote.enabled` preference]: ./Prefs.html
--- a/remote/test/demo.js
+++ b/remote/test/demo.js
@@ -1,24 +1,26 @@
 "use strict";
 
-/**
- * nodejs script to test basic CDP behaviors against Firefox and Chromium.
- *
- * Install chrome-remote-interface, the npm package for a CDP client in node:
- * $ npm install chrome-remote-interface
- *
- * Run Firefox or Chromium with server turned on:
- * $ ./mach run --setpref "remote.enabled=true" --remote-debugging-port 9222
- * $ firefox --remote-debugging-port 9222
- * $ chromium-browser --remote-debugging-port=9222
- *
- * Run this script:
- * $ node demo.js
- */
+// Node.js script to test basic CDP behaviors against Firefox and Chromium.
+//
+// Install chrome-remote-interface, the npm package for a CDP client in node:
+//
+// 	% npm install chrome-remote-interface
+//
+// Run Firefox or Chromium with server turned on:
+//
+// 	% ./mach run --remote-debugging-port 9222
+// 	% firefox --remote-debugging-port 9222
+// 	% chromium-browser --remote-debugging-port=9222
+//
+// Then run this script:
+//
+// 	% node demo.js
+
 const CDP = require("chrome-remote-interface");
 
 async function demo() {
   let client;
   try {
     client = await CDP();
     const {Log, Network, Page, Runtime} = client;