Bug 1344748 - Gate recommended prefs on a preference; r=maja_zf,whimboo
authorAndreas Tolfsen <ato@mozilla.com>
Tue, 07 Mar 2017 21:02:05 +0000
changeset 397849 0701ad4bd9f69a71e4c3daebc23bcec6b26f80ee
parent 397848 65aee3ceefec4af57f77b88c1352780fb9de49df
child 397850 1598e2db1cf6bc8df116cff6a90ff382820801b8
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf, whimboo
bugs1344748
milestone55.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 1344748 - Gate recommended prefs on a preference; r=maja_zf,whimboo MozReview-Commit-ID: FnqBDAXpg6v
testing/marionette/prefs.js
testing/marionette/server.js
--- a/testing/marionette/prefs.js
+++ b/testing/marionette/prefs.js
@@ -9,8 +9,12 @@ pref("marionette.enabled", false);
 pref("marionette.port", 2828);
 
 // Forces client connections to come from a loopback device.
 pref("marionette.forcelocal", true);
 
 // Marionette logging verbosity.  Allowed values are "fatal", "error",
 // "warn", "info", "config", "debug", and "trace".
 pref("marionette.log.level", "info");
+
+// Sets preferences recommended when using Firefox in automation with
+// Marionette.
+pref("marionette.prefs.recommended", true);
--- a/testing/marionette/server.js
+++ b/testing/marionette/server.js
@@ -22,19 +22,21 @@ Cu.import("chrome://marionette/content/m
 // Bug 1083711: Load transport.js as an SDK module instead of subscript
 loader.loadSubScript("resource://devtools/shared/transport/transport.js");
 
 const logger = Log.repository.getLogger("Marionette");
 
 this.EXPORTED_SYMBOLS = ["server"];
 this.server = {};
 
-const CONTENT_LISTENER_PREF = "marionette.contentListener";
 const PROTOCOL_VERSION = 3;
 
+const PREF_CONTENT_LISTENER = "marionette.contentListener";
+const PREF_RECOMMENDED = "marionette.prefs.recommended";
+
 // Marionette sets preferences recommended for automation when it starts,
 // unless |marionette.prefs.recommended| has been set to false.
 // Where noted, some prefs should also be set in the profile passed to
 // Marionette to prevent them from affecting startup, since some of these
 // are checked before Marionette initialises.
 const RECOMMENDED_PREFS = new Map([
 
   // Disable automatic downloading of new releases.
@@ -281,17 +283,17 @@ server.TCPListener = class {
    * Function produces a GeckoDriver.
    *
    * Determines application nameto initialise the driver with.
    *
    * @return {GeckoDriver}
    *     A driver instance.
    */
   driverFactory () {
-    Preferences.set(CONTENT_LISTENER_PREF, false);
+    Preferences.set(PREF_CONTENT_LISTENER, false);
     return new GeckoDriver(Services.appinfo.name, this);
   }
 
   set acceptConnections (value) {
     if (!value) {
       logger.info("New connections will no longer be accepted");
     } else {
       logger.info("New connections are accepted again");
@@ -300,22 +302,24 @@ server.TCPListener = class {
     this._acceptConnections = value;
   }
 
   start () {
     if (this.alive) {
       return;
     }
 
-    // set recommended preferences if they are not already user-defined
-    for (let [k, v] of RECOMMENDED_PREFS) {
-      if (!Preferences.isSet(k)) {
-        logger.debug(`Setting recommended pref ${k} to ${v}`);
-        Preferences.set(k, v);
-        this.alteredPrefs.add(k);
+    if (Preferences.get(PREF_RECOMMENDED)) {
+      // set recommended prefs if they are not already user-defined
+      for (let [k, v] of RECOMMENDED_PREFS) {
+        if (!Preferences.isSet(k)) {
+          logger.debug(`Setting recommended pref ${k} to ${v}`);
+          Preferences.set(k, v);
+          this.alteredPrefs.add(k);
+        }
       }
     }
 
     let flags = Ci.nsIServerSocket.KeepWhenOffline;
     if (this.forceLocal) {
       flags |= Ci.nsIServerSocket.LoopbackOnly;
     }
     this.listener = new ServerSocket(this.port, flags, 1);