Bug 1239371 - Consider state of boolean values for marionette.logging pref; r?AutomatedTester draft
authorAndreas Tolfsen <ato@mozilla.com>
Wed, 13 Jan 2016 18:47:58 +0000
changeset 321504 a89912020864cc69fde61ec1c146cec751530100
parent 321498 60f6a26a2e14a8e1f9ca2f211deff623ff139b06
child 512912 bc2b6dcda50a6c291168845ade1f0362d03dd4d1
push id9391
push useratolfsen@mozilla.com
push dateWed, 13 Jan 2016 19:14:37 +0000
reviewersAutomatedTester
bugs1239371, 1239363
milestone46.0a1
Bug 1239371 - Consider state of boolean values for marionette.logging pref; r?AutomatedTester The patch for bug 1239363 treated the marionette.logging preference as a defined/undefined state, and didn't look specifically at the state of the variable itself. This meant that if it was set to false, logging would still be enabled. As this was not the original behaviour were adding backwards compatibility for, this patch corrects this problem by making false equivalent to the default (Log.Level.Info).
testing/marionette/components/marionettecomponent.js
--- a/testing/marionette/components/marionettecomponent.js
+++ b/testing/marionette/components/marionettecomponent.js
@@ -56,23 +56,32 @@ MarionetteComponent.prototype.determineL
   let level = Log.Level.Info;
 #ifdef DEBUG
   level = Log.Level.Trace;
 #endif
 
   // marionette.logging pref can override default
   // with an entry from the Log.Level enum
   if (Preferences.has(LOG_PREF)) {
-    let s = Preferences.get(LOG_PREF);
-    if (typeof s == "string") {
-      s = s.toLowerCase();
-      s = s.charAt(0).toUpperCase() + s.slice(1);
-      level = Log.Level[s];
-    } else {
-      level = Log.Level.Trace;
+    let p = Preferences.get(LOG_PREF);
+
+    switch (typeof p) {
+      // Gecko >= 46
+      case "string":
+        let s = p.toLowerCase();
+        s = s.charAt(0).toUpperCase() + s.slice(1);
+        level = Log.Level[s];
+        break;
+
+      // Gecko <= 45
+      case "boolean":
+        if (p) {
+          level = Log.Level.Trace;
+        }
+        break;
     }
   }
 
   return level;
 };
 
 MarionetteComponent.prototype.onSocketAccepted = function(
     socket, transport) {