Bug 1107706: Part 13: Style fixes
☠☠ backed out by c44d46087f59 ☠ ☠
authorAndreas Tolfsen <ato@mozilla.com>
Mon, 23 Mar 2015 20:43:18 +0000
changeset 265515 ec2b1317d3c6389826da0e8e8c12176ff2cf9eeb
parent 265514 91b35cb3308bc80d736e63434f9702e73115c41f
child 265516 3b7cdf06f4b96ee708c5fc2573cebda852627568
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1107706
milestone39.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 1107706: Part 13: Style fixes Linting; no functional changes.
testing/marionette/common.js
testing/marionette/components/marionettecomponent.js
testing/marionette/driver.js
testing/marionette/emulator.js
testing/marionette/modal.js
--- a/testing/marionette/common.js
+++ b/testing/marionette/common.js
@@ -68,17 +68,17 @@ MarionetteLogObj.prototype = {
    * @param msgs Object
    *        Takes a list of strings
    */
   addLogs: function ML_addLogs(msgs) {
     for (let i = 0; i < msgs.length; i++) {
       this.logs.push(msgs[i]);
     }
   },
-  
+
   /**
    * Return all logged messages.
    */
   getLogs: function ML_getLogs() {
     let logs = this.logs;
     this.clearLogs();
     return logs;
   },
--- a/testing/marionette/components/marionettecomponent.js
+++ b/testing/marionette/components/marionettecomponent.js
@@ -86,17 +86,17 @@ MarionetteComponent.prototype.observe = 
       // so we wait for that by adding an observer here.
       this.observerService.addObserver(this, "final-ui-startup", false);
 #ifdef ENABLE_MARIONETTE
       try {
         this.enabled = Services.prefs.getBoolPref(ENABLED_PREF);
       } catch(e) {}
       if (this.enabled) {
         this.logger.info("Marionette enabled via build flag and pref");
-  
+
         // We want to suppress the modal dialog that's shown
         // when starting up in safe-mode to enable testing.
         if (Services.appinfo.inSafeMode) {
           this.observerService.addObserver(this, "domwindowopened", false);
         }
       }
 #endif
       break;
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -71,18 +71,19 @@ Services.obs.addObserver(function () {
 
 this.Context = {
   CHROME: "chrome",
   CONTENT: "content",
 };
 
 this.Context.fromString = function(s) {
   s = s.toUpperCase();
-  if (s in this)
+  if (s in this) {
     return this[s];
+  }
   return null;
 };
 
 /**
  * Creates a transparent interface between the chrome- and content
  * processes.
  *
  * Calls to this object will  be proxied via the message manager to the active
@@ -165,20 +166,21 @@ ListenerProxy.prototype.__noSuchMethod__
 
     // start content process listeners, and install observers for global-
     // and tab modal dialogues
     listeners.add();
     modal.addHandler(handleDialog);
 
     // convert to array if passed arguments
     let msg;
-    if (args.length == 1 && typeof args[0] == "object" && args[0] !== null)
+    if (args.length == 1 && typeof args[0] == "object" && args[0] !== null) {
       msg = args[0];
-    else
+    } else {
       msg = Array.prototype.slice.call(args);
+    }
 
     this.sendAsync(name, msg, this.curCmdId);
   });
 
   return proxy;
 };
 
 ListenerProxy.prototype.isOutOfSync = function(id) {
@@ -268,18 +270,19 @@ this.GeckoDriver = function(appName, dev
   this.listener = new ListenerProxy(
       () => this.mm,
       this.sendAsync.bind(this),
       () => this.curBrowser);
 
   this.dialog = null;
   let handleDialog = (subject, topic) => {
     let winr;
-    if (topic == modal.COMMON_DIALOG_LOADED)
+    if (topic == modal.COMMON_DIALOG_LOADED) {
       winr = Cu.getWeakReference(subject);
+    }
     this.dialog = new modal.Dialog(() => this.curBrowser, winr);
   };
   modal.addHandler(handleDialog);
 };
 
 GeckoDriver.prototype.QueryInterface = XPCOMUtils.generateQI([
   Ci.nsIMessageListener,
   Ci.nsIObserver,
@@ -315,18 +318,19 @@ GeckoDriver.prototype.switchToGlobalMess
  *     JSON serialisable object to send to the listener.
  * @param {number=} cmdId
  *     Command ID to ensure synchronisity.
  */
 GeckoDriver.prototype.sendAsync = function(name, msg, cmdId) {
   let curRemoteFrame = this.curBrowser.frameManager.currentRemoteFrame;
   name = `Marionette:${name}`;
 
-  if (cmdId)
+  if (cmdId) {
     msg.command_id = cmdId;
+  }
 
   if (curRemoteFrame === null) {
     this.curBrowser.executeWhenReady(() => {
       this.mm.broadcastAsyncMessage(name + this.curBrowser.curFrameId, msg);
     });
   } else {
     let remoteFrameId = curRemoteFrame.targetFrameId;
     try {
@@ -498,18 +502,19 @@ GeckoDriver.prototype.getVisibleText = f
 /**
   * Given a file name, this will delete the file from the temp directory
   * if it exists.
   *
   * @param {string} filename
   */
 GeckoDriver.prototype.deleteFile = function(filename) {
   let file = FileUtils.getFile("TmpD", [filename.toString()]);
-  if (file.exists())
+  if (file.exists()) {
     file.remove(true);
+  }
 };
 
 /**
  * Handles registration of new content listener browsers.  Depending on
  * their type they are either accepted or ignored.
  */
 GeckoDriver.prototype.registerBrowser = function(id, be) {
   let nullPrevious = this.curBrowser.curFrameId == null;
@@ -542,47 +547,50 @@ GeckoDriver.prototype.registerBrowser = 
     let uid = this.generateFrameId(id);
     reg.id = uid;
     reg.remotenessChange = this.curBrowser.register(uid, be);
   }
 
   // set to true if we updated mainContentId
   mainContent = mainContent == true &&
       this.curBrowser.mainContentId != null;
-  if (mainContent)
+  if (mainContent) {
     this.mainContentFrameId = this.curBrowser.curFrameId;
+  }
 
   this.curBrowser.elementManager.seenItems[reg.id] =
       Cu.getWeakReference(listenerWindow);
   if (nullPrevious && (this.curBrowser.curFrameId != null)) {
     this.sendAsync("newSession",
         {
           B2G: (this.appName == "B2G"),
           raisesAccessibilityExceptions:
               this.sessionCapabilities.raisesAccessibilityExceptions
         },
         this.newSessionCommandId);
-    if (this.curBrowser.isNewSession)
+    if (this.curBrowser.isNewSession) {
       this.newSessionCommandId = null;
+    }
   }
 
   return [reg, mainContent];
 };
 
 GeckoDriver.prototype.registerPromise = function() {
   const li = "Marionette:register";
 
   return new Promise((resolve) => {
     this.mm.addMessageListener(li, function cb(msg) {
       let wid = msg.json.value;
       let be = msg.target;
       let rv = this.registerBrowser(wid, be);
 
-      if (this.curBrowser.frameRegsPending > 0)
+      if (this.curBrowser.frameRegsPending > 0) {
         this.curBrowser.frameRegsPending--;
+      }
 
       if (this.curBrowser.frameRegsPending == 0) {
         this.mm.removeMessageListener(li, cb);
         resolve();
       }
 
       // this is a sync message and listeners expect the ID back
       return rv;
@@ -639,18 +647,19 @@ GeckoDriver.prototype.newSession = funct
       let checkTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
       checkTimer.initWithCallback(waitForWindow.bind(this), 100,
           Ci.nsITimer.TYPE_ONE_SHOT);
     } else if (win.document.readyState != "complete") {
       // otherwise, wait for it to be fully loaded before proceeding
       let listener = ev => {
         // ensure that we proceed, on the top level document load event
         // (not an iframe one...)
-        if (ev.target != win.document)
+        if (ev.target != win.document) {
           return;
+        }
         win.removeEventListener("load", listener);
         waitForWindow.call(this);
       };
       win.addEventListener("load", listener, true);
     } else {
       let clickToStart;
       try {
         clickToStart = Services.prefs.getBoolPref(CLICK_TO_START_PREF);
@@ -738,18 +747,19 @@ GeckoDriver.prototype.setSessionCapabili
             errors[caps] = from[key][caps] + " does not equal " +
                 this.sessionCapabilities[caps];
           }
         }
       }
       to[key] = from[key];
     }
 
-    if (Object.keys(errors).length == 0)
+    if (Object.keys(errors).length == 0) {
       return to;
+    }
 
     throw new SessionNotCreatedError(
         `Not all requiredCapabilities could be met: ${JSON.stringify(errors)}`);
   };
 
   // clone, overwrite, and set
   let caps = copy(this.sessionCapabilities);
   caps = copy(newCaps, caps);
@@ -779,18 +789,19 @@ GeckoDriver.prototype.getLogs = function
  *
  * @param {string} value
  *     Name of the context to be switched to.  Must be one of "chrome" or
  *     "content".
  */
 GeckoDriver.prototype.setContext = function(cmd, resp) {
   let val = cmd.parameters.value;
   let ctx = Context.fromString(val);
-  if (ctx === null)
+  if (ctx === null) {
     throw new WebDriverError(`Invalid context: ${val}`);
+  }
   this.context = ctx;
 };
 
 /** Gets the context of the server, either "chrome" or "content". */
 GeckoDriver.prototype.getContext = function(cmd, resp) {
   resp.value = this.context.toString();
 };
 
@@ -881,18 +892,19 @@ GeckoDriver.prototype.executeScriptInSan
     let data = NetUtil.readInputStreamToString(stream, stream.available());
     stream.close();
     script = data + script;
   }
 
   let res = Cu.evalInSandbox(script, sandbox, "1.8", "dummy file", 0);
 
   if (directInject && !async &&
-      (res == undefined || res.passed == undefined))
+      (res == undefined || res.passed == undefined)) {
     throw new WebDriverError("finish() not called");
+  }
 
   if (!async) {
     // It's fine to pass on and modify resp here because
     // executeScriptInSandbox is the last function to be called
     // in execute and executeWithCallback respectively.
     resp.value = this.curBrowser.elementManager.wrapValue(res);
   }
 };
@@ -909,20 +921,22 @@ GeckoDriver.prototype.execute = function
        scriptTimeout,
        script,
        newSandbox,
        args,
        specialPowers,
        filename,
        line} = cmd.parameters;
 
-  if (!scriptTimeout)
+  if (!scriptTimeout) {
     scriptTimeout = this.scriptTimeout;
-  if (typeof newSandbox == "undefined")
+  }
+  if (typeof newSandbox == "undefined") {
     newSandbox = true;
+  }
 
   if (this.context == Context.CONTENT) {
     resp.value = yield this.listener.executeScript({
       script: script,
       args: args,
       newSandbox: newSandbox,
       timeout: scriptTimeout,
       specialPowers: specialPowers,
@@ -959,30 +973,33 @@ GeckoDriver.prototype.execute = function
         this.marionetteLog,
         scriptTimeout,
         this.heartbeatCallback,
         this.testName);
     this.sandbox = this.createExecuteSandbox(
         win,
         marionette,
         specialPowers);
-    if (!this.sandbox)
+    if (!this.sandbox) {
       return;
+    }
   }
   this.applyArgumentsToSandbox(win, this.sandbox, args);
 
   try {
     this.sandbox.finish = () => {
-      if (this.inactivityTimer != null)
+      if (this.inactivityTimer != null) {
         this.inactivityTimer.cancel();
+      }
       return this.sandbox.generate_results();
     };
 
-    if (!directInject)
+    if (!directInject) {
       script = `let func = function() { ${script} }; func.apply(null, __marionetteParams);`;
+    }
     this.executeScriptInSandbox(
         resp,
         this.sandbox,
         script,
         directInject,
         false /* async */,
         scriptTimeout);
   } catch (e) {
@@ -993,18 +1010,19 @@ GeckoDriver.prototype.execute = function
 /**
  * Set the timeout for asynchronous script execution.
  *
  * @param {number} ms
  *     Time in milliseconds.
  */
 GeckoDriver.prototype.setScriptTimeout = function(cmd, resp) {
   let ms = parseInt(cmd.parameters.ms);
-  if (isNaN(ms))
+  if (isNaN(ms)) {
     throw new WebDriverError("Not a Number");
+  }
   this.scriptTimeout = ms;
 };
 
 /**
  * Execute pure JavaScript.  Used to execute mochitest-like Marionette
  * tests.
  */
 GeckoDriver.prototype.executeJSScript = function(cmd, resp) {
@@ -1014,20 +1032,21 @@ GeckoDriver.prototype.executeJSScript = 
   if (typeof cmd.newSandbox == "undefined") {
     // If client does not send a value in newSandbox,
     // then they expect the same behaviour as WebDriver.
     cmd.newSandbox = true;
   }
 
   switch (this.context) {
     case Context.CHROME:
-      if (cmd.parameters.async)
+      if (cmd.parameters.async) {
         yield this.executeWithCallback(cmd, resp, cmd.parameters.async);
-      else
+      } else {
         this.execute(cmd, resp, true /* async */);
+      }
       break;
 
     case Context.CONTENT:
       resp.value = yield this.listener.executeJSScript({
         script: cmd.parameters.script,
         args: cmd.parameters.args,
         newSandbox: cmd.parameters.newSandbox,
         async: cmd.parameters.async,
@@ -1062,20 +1081,22 @@ GeckoDriver.prototype.executeWithCallbac
       args,
       newSandbox,
       inactivityTimeout,
       scriptTimeout,
       specialPowers,
       filename,
       line} = cmd.parameters;
 
-  if (!scriptTimeout)
+  if (!scriptTimeout) {
     scriptTimeout = this.scriptTimeout;
-  if (typeof newSandbox == "undefined")
+  }
+  if (typeof newSandbox == "undefined") {
     newSandbox = true;
+  }
 
   if (this.context == Context.CONTENT) {
     resp.value = yield this.listener.executeAsyncScript({
       script: script,
       args: args,
       id: cmd.id,
       newSandbox: newSandbox,
       timeout: scriptTimeout,
@@ -1121,24 +1142,26 @@ GeckoDriver.prototype.executeWithCallbac
       if (cmd.id == that.sandbox.command_id) {
         if (that.timer != null) {
           that.timer.cancel();
           that.timer = null;
         }
 
         win.onerror = origOnError;
 
-        if (error.isError(val))
+        if (error.isError(val)) {
           reject(val);
-        else
+        } else {
           resolve(val);
+        }
       }
 
-      if (that.inactivityTimer != null)
+      if (that.inactivityTimer != null) {
         that.inactivityTimer.cancel();
+      }
     };
 
     let chromeAsyncFinish = function() {
       let res = that.sandbox.generate_results();
       chromeAsyncReturnFunc(res);
     };
 
     let chromeAsyncError = function(e, func, file, line, script) {
@@ -1151,18 +1174,19 @@ GeckoDriver.prototype.executeWithCallbac
           this,
           win,
           "chrome",
           this.marionetteLog,
           scriptTimeout,
           this.heartbeatCallback,
           this.testName);
       this.sandbox = this.createExecuteSandbox(win, marionette, specialPowers);
-      if (!this.sandbox)
+      if (!this.sandbox) {
         return;
+      }
     }
     this.sandbox.command_id = cmd.id;
     this.sandbox.runEmulatorCmd = (cmd, cb) => {
       let ecb = new EmulatorCallback();
       ecb.onresult = cb;
       ecb.onerror = chromeAsyncError;
       this.emulator.pushCallback(ecb);
       this.emulator.send({emulator_cmd: cmd, id: ecb.id});
@@ -1265,18 +1289,19 @@ GeckoDriver.prototype.get = function(cmd
       break;
 
     case Context.CHROME:
       // At least on desktop, navigating in chrome scope does not
       // correspond to something a user can do, and leaves marionette
       // and the browser in an unusable state. Return a generic error insted.
       // TODO: Error codes need to be refined as a part of bug 1100545 and
       // bug 945729.
-      if (this.appName == "Firefox")
+      if (this.appName == "Firefox") {
         throw new UnknownError("Cannot navigate in chrome context");
+      }
 
       this.getCurrentWindow().location.href = url;
       yield this.pageLoadPromise();
       break;
   }
 };
 
 GeckoDriver.prototype.pageLoadPromise = function() {
@@ -1286,20 +1311,21 @@ GeckoDriver.prototype.pageLoadPromise = 
   let start = new Date().getTime();
   let end = null;
 
   return new Promise((resolve) => {
     let checkLoad = function() {
       end = new Date().getTime();
       let elapse = end - start;
       if (timeout == null || elapse <= timeout) {
-        if (win.document.readyState == "complete")
+        if (win.document.readyState == "complete") {
           resolve();
-        else
+        } else {
           checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT);
+        }
       } else {
         throw new UnknownError("Error loading page");
       }
     };
     checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT);
   });
 };
 
@@ -1525,23 +1551,25 @@ GeckoDriver.prototype.getWindowPosition 
  * @param {number} x
  *     X coordinate of the top/left of the window that it will be
  *     moved to.
  * @param {number} y
  *     Y coordinate of the top/left of the window that it will be
  *     moved to.
  */
 GeckoDriver.prototype.setWindowPosition = function(cmd, resp) {
-  if (this.appName != "Firefox")
+  if (this.appName != "Firefox") {
     throw new WebDriverError("Unable to set the window position on mobile");
+  }
 
   let x = parseInt(cmd.parameters.x);
   let y  = parseInt(cmd.parameters.y);
-  if (isNaN(x) || isNaN(y))
+  if (isNaN(x) || isNaN(y)) {
     throw new UnknownError("x and y arguments should be integers");
+  }
 
   let win = this.getCurrentWindow();
   win.moveTo(x, y);
 };
 
 /**
  * Switch current top-level browsing context by name or server-assigned ID.
  * Searches for windows by name, then ID.  Content windows take precedence.
@@ -1630,19 +1658,20 @@ GeckoDriver.prototype.switchToWindow = f
   }
 };
 
 GeckoDriver.prototype.getActiveFrame = function(cmd, resp) {
   switch (this.context) {
     case Context.CHROME:
       // no frame means top-level
       resp.value = null;
-      if (this.curFrame)
+      if (this.curFrame) {
         resp.value = this.curBrowser.elementManager
             .addToKnownElements(this.curFrame.frameElement);
+      }
       break;
 
     case Context.CONTENT:
       resp.value = this.currentFrameElement;
       break;
   }
 };
 
@@ -1783,34 +1812,36 @@ GeckoDriver.prototype.switchToFrame = fu
 /**
  * Set timeout for searching for elements.
  *
  * @param {number} ms
  *     Search timeout in milliseconds.
  */
 GeckoDriver.prototype.setSearchTimeout = function(cmd, resp) {
   let ms = parseInt(cmd.parameters.ms);
-  if (isNaN(ms))
+  if (isNaN(ms)) {
     throw new WebDriverError("Not a Number");
+  }
   this.searchTimeout = ms;
 };
 
 /**
  * Set timeout for page loading, searching, and scripts.
  *
  * @param {string} type
  *     Type of timeout.
  * @param {number} ms
  *     Timeout in milliseconds.
  */
 GeckoDriver.prototype.timeouts = function(cmd, resp) {
   let typ = cmd.parameters.type;
   let ms = parseInt(cmd.parameters.ms);
-  if (isNaN(ms))
+  if (isNaN(ms)) {
     throw new WebDriverError("Not a Number");
+  }
 
   switch (typ) {
     case "implicit":
       this.setSearchTimeout(cmd, resp);
       break;
 
     case "script":
       this.setScriptTimeout(cmd, resp);
@@ -1865,24 +1896,24 @@ GeckoDriver.prototype.actionChain = func
  *
  * @param {Object} value
  *     A nested array where the inner array represents eache vent,
  *     the middle array represents a collection of events for each
  *     finger, and the outer array represents all fingers.
  */
 GeckoDriver.prototype.multiAction = function(cmd, resp) {
   switch (this.context) {
-  case Context.CHROME:
-    throw new WebDriverError("Command 'multiAction' is not available in chrome context");
-
-  case Context.CONTENT:
-    this.addFrameCloseListener("multi action chain");
-    yield this.listener.multiAction(
-        {value: value, maxlen: max_len} = cmd.parameters);
-    break;
+    case Context.CHROME:
+      throw new WebDriverError("Command 'multiAction' is not available in chrome context");
+
+    case Context.CONTENT:
+      this.addFrameCloseListener("multi action chain");
+      yield this.listener.multiAction(
+          {value: value, maxlen: max_len} = cmd.parameters);
+      break;
   }
 };
 
 /**
  * Find an element using the indicated search strategy.
  *
  * @param {string} using
  *     Indicates which search method to use.
@@ -2356,60 +2387,65 @@ GeckoDriver.prototype.deleteCookie = fun
 /**
  * Close the current window, ending the session if it's the last
  * window currently open.
  *
  * On B2G this method is a noop and will return immediately.
  */
 GeckoDriver.prototype.close = function(cmd, resp) {
   // can't close windows on B2G
-  if (this.appName == "B2G")
+  if (this.appName == "B2G") {
     return;
+  }
 
   let nwins = 0;
   let winEn = this.getWinEnumerator();
   while (winEn.hasMoreElements()) {
     let win = winEn.getNext();
 
     // count both windows and tabs
-    if (win.gBrowser)
+    if (win.gBrowser) {
       nwins += win.gBrowser.browsers.length;
-    else
+    } else {
       nwins++;
+    }
   }
 
   // if there is only 1 window left, delete the session
   if (nwins == 1) {
     this.sessionTearDown();
     return;
   }
 
   try {
-    if (this.mm != globalMessageManager)
+    if (this.mm != globalMessageManager) {
       this.mm.removeDelayedFrameScript(FRAME_SCRIPT);
-
-    if (this.curBrowser.tab)
+    }
+
+    if (this.curBrowser.tab) {
       this.curBrowser.closeTab();
-    else
+    } else {
       this.getCurrentWindow().close();
+    }
   } catch (e) {
     throw new UnknownError(`Could not close window: ${e.message}`);
   }
 };
 
 /**
  * Close the currently selected chrome window, ending the session if it's the last
  * window currently open.
  *
  * On B2G this method is a noop and will return immediately.
  */
 GeckoDriver.prototype.closeChromeWindow = function(cmd, resp) {
   // can't close windows on B2G
-  if (this.appName == "B2G")
+  if (this.appName == "B2G") {
     return;
+  }
 
   // Get the total number of windows
   let nwins = 0;
   let winEn = this.getWinEnumerator();
   while (winEn.hasMoreElements()) {
     nwins++;
     winEn.getNext();
   }
@@ -2468,18 +2504,19 @@ GeckoDriver.prototype.sessionTearDown = 
     this.curBrowser.frameManager.removeMessageManagerListeners(
         globalMessageManager);
   }
 
   this.switchToGlobalMessageManager();
 
   // reset frame to the top-most frame
   this.curFrame = null;
-  if (this.mainFrame)
+  if (this.mainFrame) {
     this.mainFrame.focus();
+  }
 
   this.sessionId = null;
   this.deleteFile("marionetteChromeScripts");
   this.deleteFile("marionetteContentScripts");
 
   if (this.observing !== null) {
     for (let topic in this.observing) {
       Services.obs.removeObserver(this.observing[topic], topic);
@@ -2509,18 +2546,19 @@ GeckoDriver.prototype.importScript = fun
   converter.charset = "UTF-8";
   let result = {};
   let data = converter.convertToByteArray(cmd.parameters.script, result);
   let ch = Cc["@mozilla.org/security/hash;1"].createInstance(Ci.nsICryptoHash);
   ch.init(ch.MD5);
   ch.update(data, data.length);
   let hash = ch.finish(true);
   // return if we've already imported this script
-  if (this.importedScriptHashes[this.context].indexOf(hash) > -1)
+  if (this.importedScriptHashes[this.context].indexOf(hash) > -1) {
     return;
+  }
   this.importedScriptHashes[this.context].push(hash);
 
   switch (this.context) {
     case Context.CHROME:
       let file;
       if (this.importedScripts.exists()) {
         file = FileUtils.openFileOutputStream(this.importedScripts,
             FileUtils.MODE_APPEND | FileUtils.MODE_WRONLY);
@@ -2577,20 +2615,21 @@ GeckoDriver.prototype.clearImportedScrip
  *     PNG image encoded as base64 encoded string.
  */
 GeckoDriver.prototype.takeScreenshot = function(cmd, resp) {
   switch (this.context) {
     case Context.CHROME:
       let win = this.getCurrentWindow();
       let canvas = win.document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
       let doc;
-      if (this.appName == "B2G")
+      if (this.appName == "B2G") {
         doc = win.document.body;
-      else
+      } else {
         doc = win.document.getElementsByTagName("window")[0];
+      }
       let docRect = doc.getBoundingClientRect();
       let width = docRect.width;
       let height = docRect.height;
 
       // Convert width and height from CSS pixels (potentially fractional)
       // to device pixels (integer).
       let scale = win.devicePixelRatio;
       canvas.setAttribute("width", Math.round(width * scale));
@@ -2652,22 +2691,24 @@ GeckoDriver.prototype.setScreenOrientati
   const ors = [
     "portrait", "landscape",
     "portrait-primary", "landscape-primary",
     "portrait-secondary", "landscape-secondary"
   ];
 
   let or = String(cmd.parameters.orientation);
   let mozOr = or.toLowerCase();
-  if (ors.indexOf(mozOr) < 0)
+  if (ors.indexOf(mozOr) < 0) {
     throw new WebDriverError(`Unknown screen orientation: ${or}`);
+  }
 
   let win = this.getCurrentWindow();
-  if (!win.screen.mozLockOrientation(mozOr))
+  if (!win.screen.mozLockOrientation(mozOr)) {
     throw new WebDriverError(`Unable to set screen orientation: ${or}`);
+  }
 };
 
 /**
  * Get the size of the browser window currently in focus.
  *
  * Will return the current browser window size in pixels. Refers to
  * window outerWidth and outerHeight values, which include scroll bars,
  * title bars, etc.
@@ -2683,100 +2724,108 @@ GeckoDriver.prototype.getWindowSize = fu
  * Not supported on B2G. The supplied width and height values refer to
  * the window outerWidth and outerHeight values, which include scroll
  * bars, title bars, etc.
  *
  * An error will be returned if the requested window size would result
  * in the window being in the maximized state.
  */
 GeckoDriver.prototype.setWindowSize = function(cmd, resp) {
-  if (this.appName !== "Firefox")
+  if (this.appName !== "Firefox") {
     throw new UnsupportedOperationError("Not supported on mobile");
+  }
 
   let width = parseInt(cmd.parameters.width);
   let height = parseInt(cmd.parameters.height);
 
   let win = this.getCurrentWindow();
-  if (width >= win.screen.availWidth && height >= win.screen.availHeight)
+  if (width >= win.screen.availWidth && height >= win.screen.availHeight) {
     throw new UnsupportedOperationError("Invalid requested size, cannot maximize");
+  }
 
   win.resizeTo(width, height);
 };
 
 /**
  * Maximizes the user agent window as if the user pressed the maximise
  * button.
  *
  * Not Supported on B2G or Fennec.
  */
 GeckoDriver.prototype.maximizeWindow = function(cmd, resp) {
-  if (this.appName != "Firefox")
+  if (this.appName != "Firefox") {
     throw new UnsupportedOperationError("Not supported for mobile");
+  }
 
   let win = this.getCurrentWindow();
   win.moveTo(0,0);
   win.resizeTo(win.screen.availWidth, win.screen.availHeight);
 };
 
 /**
  * Dismisses a currently displayed tab modal, or returns no such alert if
  * no modal is displayed.
  */
 GeckoDriver.prototype.dismissDialog = function(cmd, resp) {
-  if (!this.dialog)
+  if (!this.dialog) {
     throw new NoAlertOpenError(
         "No tab modal was open when attempting to dismiss the dialog");
+  }
 
   let {button0, button1} = this.dialog.ui;
   (button1 ? button1 : button0).click();
   this.dialog = null;
 };
 
 /**
  * Accepts a currently displayed tab modal, or returns no such alert if
  * no modal is displayed.
  */
 GeckoDriver.prototype.acceptDialog = function(cmd, resp) {
-  if (!this.dialog)
+  if (!this.dialog) {
     throw new NoAlertOpenError(
         "No tab modal was open when attempting to accept the dialog");
+  }
 
   let {button0} = this.dialog.ui;
   button0.click();
   this.dialog = null;
 };
 
 /**
  * Returns the message shown in a currently displayed modal, or returns a no such
  * alert error if no modal is currently displayed.
  */
 GeckoDriver.prototype.getTextFromDialog = function(cmd, resp) {
-  if (!this.dialog)
+  if (!this.dialog) {
     throw new NoAlertOpenError(
         "No tab modal was open when attempting to get the dialog text");
+  }
 
   let {infoBody} = this.dialog.ui;
   resp.value = infoBody.textContent;
 };
 
 /**
  * Sends keys to the input field of a currently displayed modal, or
  * returns a no such alert error if no modal is currently displayed. If
  * a tab modal is currently displayed but has no means for text input,
  * an element not visible error is returned.
  */
 GeckoDriver.prototype.sendKeysToDialog = function(cmd, resp) {
-  if (!this.dialog)
+  if (!this.dialog) {
     throw new NoAlertOpenError(
         "No tab modal was open when attempting to send keys to a dialog");
+  }
 
   // see toolkit/components/prompts/content/commonDialog.js
   let {loginContainer, loginTextbox} = this.dialog.ui;
-  if (loginContainer.hidden)
+  if (loginContainer.hidden) {
     throw new ElementNotVisibleError("This prompt does not accept text input");
+  }
 
   let win = this.dialog.window ? this.dialog.window : this.getCurrentWindow();
   utils.sendKeysToElement(
       win,
       loginTextbox,
       cmd.parameters.value,
       () => {},
       e => { throw e; },
@@ -2805,18 +2854,19 @@ GeckoDriver.prototype.receiveMessage = f
   switch (message.name) {
     case "Marionette:log":
       // log server-side messages
       logger.info(message.json.message);
       break;
 
     case "Marionette:shareData":
       // log messages from tests
-      if (message.json.log)
+      if (message.json.log) {
         this.marionetteLog.addLogs(message.json.log);
+      }
       break;
 
     case "Marionette:runEmulatorCmd":
     case "Marionette:runEmulatorShell":
       this.emulator.send(message.json);
       break;
 
     case "Marionette:switchToModalOrigin":
@@ -2827,18 +2877,19 @@ GeckoDriver.prototype.receiveMessage = f
 
     case "Marionette:switchedToFrame":
       if (message.json.restorePrevious) {
         this.currentFrameElement = this.previousFrameElement;
       } else {
         // we don't arbitrarily save previousFrameElement, since
         // we allow frame switching after modals appear, which would
         // override this value and we'd lose our reference
-        if (message.json.storePrevious)
+        if (message.json.storePrevious) {
           this.previousFrameElement = this.currentFrameElement;
+        }
         this.currentFrameElement = message.json.frameValue;
       }
       break;
 
     case "Marionette:getVisibleCookies":
       let [currentPath, host] = message.json.value;
       let isForCurrentPath = path => currentPath.indexOf(path) != -1;
       let results = [];
@@ -2873,17 +2924,17 @@ GeckoDriver.prototype.receiveMessage = f
           cookieToAdd.path,
           cookieToAdd.name,
           cookieToAdd.value,
           cookieToAdd.secure,
           false,
           false,
           cookieToAdd.expiry);
       return true;
- 
+
     case "Marionette:deleteCookie":
       let cookieToDelete = message.json.value;
       cookieManager.remove(
           cookieToDelete.host,
           cookieToDelete.name,
           cookieToDelete.path,
           false);
       return true;
@@ -3080,18 +3131,19 @@ Object.defineProperty(BrowserObj.prototy
 });
 
 /**
  * Retrieves the current tabmodal UI object.  According to the browser
  * associated with the currently selected tab.
  */
 BrowserObj.prototype.getTabModalUI = function() {
   let br = this.browserForTab;
-  if (!br.hasAttribute("tabmodalPromptShowing"))
+  if (!br.hasAttribute("tabmodalPromptShowing")) {
     return null;
+  }
 
   // The modal is a direct sibling of the browser element.
   // See tabbrowser.xml's getTabModalPromptBox.
   let modals = br.parentNode.getElementsByTagNameNS(
       XUL_NS, "tabmodalprompt");
   return modals[0].ui;
 };
 
@@ -3166,18 +3218,19 @@ BrowserObj.prototype.switchToTab = funct
  * @param the XUL <browser> that was the target of the originating message.
  */
 BrowserObj.prototype.register = function(uid, target) {
   let remotenessChange = this.hasRemotenessChange();
   if (this.curFrameId === null || remotenessChange) {
     if (this.browser) {
       // If we're setting up a new session on Firefox, we only process the
       // registration for this frame if it belongs to the current tab.
-      if (!this.tab)
+      if (!this.tab) {
         this.switchToTab(this.browser.selectedIndex);
+      }
 
       if (target == this.browserForTab) {
         this.updateIdForBrowser(this.browserForTab, uid);
         this.mainContentId = uid;
       }
     } else {
       this._curFrameId = uid;
       this.mainContentId = uid;
@@ -3192,35 +3245,38 @@ BrowserObj.prototype.register = function
 /**
  * When navigating between pages results in changing a browser's
  * process, we need to take measures not to lose contact with a listener
  * script. This function does the necessary bookkeeping.
  */
 BrowserObj.prototype.hasRemotenessChange = function() {
   // None of these checks are relevant on b2g or if we don't have a tab yet,
   // and may not apply on Fennec.
-  if (this.driver.appName != "Firefox" || this.tab === null)
+  if (this.driver.appName != "Firefox" || this.tab === null) {
     return false;
-
-  if (this._hasRemotenessChange)
+  }
+
+  if (this._hasRemotenessChange) {
     return true;
+  }
 
   let currentIsRemote = this.browserForTab.isRemoteBrowser;
   this._hasRemotenessChange = this._browserWasRemote !== currentIsRemote;
   this._browserWasRemote = currentIsRemote;
   return this._hasRemotenessChange;
 };
 
 /**
  * Flushes any pending commands queued when a remoteness change is being
  * processed and mark this remotenessUpdate as complete.
  */
 BrowserObj.prototype.flushPendingCommands = function() {
-  if (!this._hasRemotenessChange)
+  if (!this._hasRemotenessChange) {
     return;
+  }
 
   this._hasRemotenessChange = false;
   this.pendingCommands.forEach(cb => cb());
   this.pendingCommands = [];
 };
 
 /**
   * This function intercepts commands interacting with content and queues
@@ -3228,13 +3284,14 @@ BrowserObj.prototype.flushPendingCommand
   *
   * No commands interacting with content are safe to process until
   * the new listener script is loaded and registers itself.
   * This occurs when a command whose effect is asynchronous (such
   * as goBack) results in a remoteness change and new commands
   * are subsequently posted to the server.
   */
 BrowserObj.prototype.executeWhenReady = function(cb) {
-  if (this.hasRemotenessChange())
+  if (this.hasRemotenessChange()) {
     this.pendingCommands.push(cb);
-  else
+  } else {
     cb();
+  }
 };
--- a/testing/marionette/emulator.js
+++ b/testing/marionette/emulator.js
@@ -48,18 +48,19 @@ Emulator.prototype.popCallback = functio
   let f, fi;
   for (let i = 0; i < this.cbs.length; ++i) {
     if (this.cbs[i].id == id) {
       f = this.cbs[i];
       fi = i;
     }
   }
 
-  if (!f)
+  if (!f) {
     return null;
+  }
 
   this.cbs.splice(fi, 1);
   return f;
 };
 
 /**
  * Pushes callback on to the stack.
  *
@@ -98,21 +99,24 @@ EmulatorCallback.prototype.command = fun
 };
 
 EmulatorCallback.prototype.shell = function(args, cb) {
   this.onresult = cb;
   this.send_({emulator_shell: args, id: this.id});
 };
 
 EmulatorCallback.prototype.result = function(msg) {
-  if (this.send_ === null)
+  if (this.send_ === null) {
     throw new TypeError(
       "EmulatorCallback must be registered with Emulator to fire");
+  }
 
   try {
-    if (!this.onresult)
+    if (!this.onresult) {
       return;
+    }
     this.onresult(msg.result);
   } catch (e) {
-    if (this.onerror)
+    if (this.onerror) {
       this.onerror(e);
+    }
   }
 };
--- a/testing/marionette/modal.js
+++ b/testing/marionette/modal.js
@@ -91,23 +91,25 @@ modal.Dialog = function(curBrowserFn, wi
 /**
  * Returns the ChromeWindow associated with an open dialog window if it
  * is currently attached to the DOM.
  */
 Object.defineProperty(modal.Dialog.prototype, "window", {
   get() {
     if (this.win_ !== null) {
       let win = this.win_.get();
-      if (win && win.parent)
+      if (win && win.parent) {
         return win;
+      }
     }
     return null;
   }
 });
 
 Object.defineProperty(modal.Dialog.prototype, "ui", {
   get() {
     let win = this.window;
-    if (win)
+    if (win) {
       return win.Dialog.ui;
+    }
     return this.curBrowser.getTabModalUI();
   }
 });