Backed out changeset f41bca9ebd0b (bug 1350887)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Mon, 03 Apr 2017 21:40:08 +0200
changeset 399131 02838ca872766c63522ede9bebc8d29fb6c8b83e
parent 399130 c68909a45262aec5381079b268430e1bc087ddca
child 399132 02a0f61b5bd1400ed3b796e7c6d806605ef1527b
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)
bugs1350887
milestone55.0a1
backs outf41bca9ebd0b827d859b5b88818949e1c67fefcf
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
Backed out changeset f41bca9ebd0b (bug 1350887)
testing/marionette/components/marionette.js
--- a/testing/marionette/components/marionette.js
+++ b/testing/marionette/components/marionette.js
@@ -20,37 +20,25 @@ const PREF_PORT = "marionette.port";
 const PREF_PORT_FALLBACK = "marionette.defaultPrefs.port";
 const PREF_LOG_LEVEL = "marionette.log.level";
 const PREF_LOG_LEVEL_FALLBACK = "marionette.logging";
 const PREF_FORCE_LOCAL = "marionette.forcelocal";
 const PREF_FORCE_LOCAL_FALLBACK = "marionette.force-local";
 
 const DEFAULT_PORT = 2828;
 const DEFAULT_LOG_LEVEL = "info";
-const LOG_LEVELS = new class extends Map {
-  constructor () {
-    super([
-      ["fatal", Log.Level.Fatal],
-      ["error", Log.Level.Error],
-      ["warn", Log.Level.Warn],
-      ["info", Log.Level.Info],
-      ["config", Log.Level.Config],
-      ["debug", Log.Level.Debug],
-      ["trace", Log.Level.Trace],
-    ]);
-  }
-
-  get (level) {
-    let s = new String(level).toLowerCase();
-    if (!this.has(s)) {
-      return DEFAULT_LOG_LEVEL;
-    }
-    return super.get(s);
-  }
-};
+const LOG_LEVELS = new Map([
+  ["fatal", Log.Level.Fatal],
+  ["error", Log.Level.Error],
+  ["warn", Log.Level.Warn],
+  ["info", Log.Level.Info],
+  ["config", Log.Level.Config],
+  ["debug", Log.Level.Debug],
+  ["trace", Log.Level.Trace],
+]);
 
 // Besides starting based on existing prefs in a profile and a command
 // line flag, we also support inheriting prefs out of an env var, and to
 // start Marionette that way.
 //
 // This allows marionette prefs to persist when we do a restart into
 // a different profile in order to test things like Firefox refresh.
 // The environment variable itself, if present, is interpreted as a
@@ -60,42 +48,55 @@ const LOG_LEVELS = new class extends Map
 // pref being set to true, thus triggering marionette being enabled for
 // that startup.
 const ENV_PREF_VAR = "MOZ_MARIONETTE_PREF_STATE_ACROSS_RESTARTS";
 
 const ServerSocket = CC("@mozilla.org/network/server-socket;1",
     "nsIServerSocket",
     "initSpecialConnection");
 
-// Get preference value of |preferred|, falling back to |fallback|
-// if |preferred| is not user-modified and |fallback| exists.
-function getPref (preferred, fallback) {
-  if (!Preferences.isSet(preferred) && Preferences.has(fallback)) {
-    return Preferences.get(fallback, Preferences.get(preferred));
-  }
-  return Preferences.get(preferred);
-}
-
 // Marionette preferences recently changed names.  This is an abstraction
 // that first looks for the new name, but falls back to using the old name
 // if the new does not exist.
 //
 // This shim can be removed when Firefox 55 ships.
 const prefs = {
   get port () {
-    return getPref(PREF_PORT, PREF_PORT_FALLBACK);
+    let fallback = Preferences.get(PREF_PORT_FALLBACK, DEFAULT_PORT);
+    return Preferences.get(PREF_PORT, fallback);
   },
 
   get logLevel () {
-    let s = getPref(PREF_LOG_LEVEL, PREF_LOG_LEVEL_FALLBACK);
-    return LOG_LEVELS.get(s);
+    let level = DEFAULT_LOG_LEVEL;
+    let fallback = Preferences.get(PREF_LOG_LEVEL_FALLBACK, level);
+    let p = Preferences.get(PREF_LOG_LEVEL, fallback);
+
+    switch (typeof p) {
+      // Gecko >= 46
+      case "string":
+        let s = p.toLowerCase();
+        if (LOG_LEVELS.has(s)) {
+          level = LOG_LEVELS.get(s);
+        }
+        break;
+
+      // Gecko <= 45
+      case "boolean":
+        if (p) {
+          level = Log.Level.Trace;
+        }
+        break;
+    }
+
+    return level;
   },
 
   get forceLocal () {
-    return getPref(PREF_FORCE_LOCAL, PREF_FORCE_LOCAL_FALLBACK);
+    let fallback = Preferences.get(PREF_FORCE_LOCAL_FALLBACK, true);
+    return Preferences.get(PREF_FORCE_LOCAL, fallback);
   },
 
   readFromEnvironment (key) {
     const env = Cc["@mozilla.org/process/environment;1"]
         .getService(Ci.nsIEnvironment);
 
     if (env.exists(key)) {
       let prefs;