Bug 1344748 - Gate recommended prefs on a preference; r=maja_zf,whimboo, a=test-only
authorAndreas Tolfsen <ato@mozilla.com>
Tue, 07 Mar 2017 21:02:05 +0000
changeset 395541 4b03583a265bbb01ec70f4246d1d88795da42766
parent 395540 5917cc5857187180d63ee7c38b2864f84b47390b
child 395542 df3bfa03df6da4403697aff2facfd77bd5dcfcea
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf, whimboo, test-only
bugs1344748
milestone54.0a2
Bug 1344748 - Gate recommended prefs on a preference; r=maja_zf,whimboo, a=test-only 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);