Bug 1385547 - Lint testing/marionette. r=automatedtester
authorAndreas Tolfsen <ato@sny.no>
Sat, 29 Jul 2017 10:03:00 +0100
changeset 420785 9360c4975d3652abcae684e4af531fae7eb93789
parent 420784 423b51b215196a7da2b81b74cee28c836597dabc
child 420786 91637b17112c15230feaeaae15034f7f5cf3aaab
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersautomatedtester
bugs1385547
milestone56.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 1385547 - Lint testing/marionette. r=automatedtester Automatic fixes from './mach lint --fix testing/marionette'. MozReview-Commit-ID: 4UOLrLLxMbH
testing/marionette/components/marionette.js
testing/marionette/driver.js
testing/marionette/element.js
testing/marionette/error.js
testing/marionette/event.js
testing/marionette/l10n.js
testing/marionette/listener.js
testing/marionette/message.js
testing/marionette/packets.js
testing/marionette/proxy.js
testing/marionette/reftest.js
testing/marionette/stream-utils.js
testing/marionette/transport.js
--- a/testing/marionette/components/marionette.js
+++ b/testing/marionette/components/marionette.js
@@ -9,17 +9,17 @@ const {Constructor: CC, interfaces: Ci, 
 Cu.import("resource://gre/modules/Log.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(
     this, "env", "@mozilla.org/process/environment;1", "nsIEnvironment");
 
 XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
-  "resource://gre/modules/Preferences.jsm");
+    "resource://gre/modules/Preferences.jsm");
 
 const MARIONETTE_CONTRACT_ID = "@mozilla.org/remote/marionette;1";
 const MARIONETTE_CID = Components.ID("{786a1369-dca5-4adc-8486-33d23c88010a}");
 
 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";
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -175,17 +175,17 @@ this.GeckoDriver = function(appName, ser
   this.inactivityTimer = null;
 
   this.testName = null;
 
   this.capabilities = new session.Capabilities();
 
   this.mm = globalMessageManager;
   this.listener = proxy.toListener(() => this.mm, this.sendAsync.bind(this),
-                                   () => this.curBrowser);
+      () => this.curBrowser);
 
   // points to an alert instance if a modal dialog is present
   this.dialog = null;
   this.dialogHandler = this.globalModalDialogHandler.bind(this);
 };
 
 Object.defineProperty(GeckoDriver.prototype, "a11yChecks", {
   get() {
@@ -1195,17 +1195,17 @@ GeckoDriver.prototype.goForward = functi
  *     A modal dialog is open, blocking this operation.
  */
 GeckoDriver.prototype.refresh = function* (cmd, resp) {
   assert.content(this.context);
   assert.window(this.getCurrentWindow());
   assert.noUserPrompt(this.dialog);
 
   let refresh = this.listener.refresh(
-      {pageTimeout: this.timeouts.pageLoad})
+      {pageTimeout: this.timeouts.pageLoad});
 
   // If a reload of the frame script interrupts our page load, this will
   // never return. We need to re-issue this request to correctly poll for
   // readyState and send errors.
   this.curBrowser.pendingCommands.push(() => {
     let parameters = {
       // TODO(ato): Bug 1242595
       command_id: this.listener.activeMessageId,
@@ -1277,17 +1277,17 @@ GeckoDriver.prototype.getWindowHandle = 
  * Each window handle is assigned by the server and is guaranteed unique,
  * however the return array does not have a specified ordering.
  *
  * @return {Array.<string>}
  *     Unique window handles.
  */
 GeckoDriver.prototype.getWindowHandles = function(cmd, resp) {
   return this.windowHandles.map(String);
-}
+};
 
 /**
  * Get the current window's handle.  This corresponds to a window that
  * may itself contain tabs.
  *
  * Return an opaque server-assigned identifier to this window that
  * uniquely identifies it within this Marionette instance.  This can
  * be used to switch to this window at a later point.
@@ -1313,17 +1313,17 @@ GeckoDriver.prototype.getChromeWindowHan
  * Returns identifiers for each open chrome window for tests interested in
  * managing a set of chrome windows and tabs separately.
  *
  * @return {Array.<string>}
  *     Unique window handles.
  */
 GeckoDriver.prototype.getChromeWindowHandles = function(cmd, resp) {
   return this.chromeWindowHandles.map(String);
-}
+};
 
 /**
  * Get the current position and 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.
  *
@@ -1368,17 +1368,17 @@ GeckoDriver.prototype.getWindowRect = fu
  * @throws {UnsupportedOperationError}
  *     Not applicable to application.
  * @throws {NoSuchWindowError}
  *     Top-level browsing context has been discarded.
  * @throws {UnexpectedAlertOpenError}
  *     A modal dialog is open, blocking this operation.
  */
 GeckoDriver.prototype.setWindowRect = async function(cmd, resp) {
-  assert.firefox()
+  assert.firefox();
   const win = assert.window(this.getCurrentWindow());
   assert.noUserPrompt(this.dialog);
 
   let {x, y, width, height} = cmd.parameters;
   let origRect = this.curBrowser.rect;
 
   // Throttle resize event by forcing the event queue to flush and delay
   // until the main thread is idle.
@@ -3103,17 +3103,17 @@ GeckoDriver.prototype._checkIfAlertIsPre
  * marionette.quit() or marionette.restart(), like File -> Quit.
  *
  * @param {boolean} state
  *     True if the server should accept new socket connections.
  */
 GeckoDriver.prototype.acceptConnections = function(cmd, resp) {
   assert.boolean(cmd.parameters.value);
   this._server.acceptConnections = cmd.parameters.value;
-}
+};
 
 /**
  * Quits the application with the provided flags.
  *
  * Marionette will stop accepting new connections before ending the
  * current session, and finally attempting to quit the application.
  *
  * Optional {@link nsIAppStartup} flags may be provided as
@@ -3142,17 +3142,17 @@ GeckoDriver.prototype.quit = function* (
   const quits = ["eConsiderQuit", "eAttemptQuit", "eForceQuit"];
 
   let flags = [];
   if (typeof cmd.parameters.flags != "undefined") {
     flags = assert.array(cmd.parameters.flags);
   }
 
   // bug 1298921
-  assert.firefox()
+  assert.firefox();
 
   let quitSeen;
   let mode = 0;
   if (flags.length > 0) {
     for (let k of flags) {
       assert.in(k, Ci.nsIAppStartup);
 
       if (quits.includes(k)) {
@@ -3182,30 +3182,30 @@ GeckoDriver.prototype.quit = function* (
   Services.startup.quit(mode);
 
   yield quitApplication
       .then(cause => resp.body.cause = cause)
       .then(() => resp.send());
 };
 
 GeckoDriver.prototype.installAddon = function(cmd, resp) {
-  assert.firefox()
+  assert.firefox();
 
   let path = cmd.parameters.path;
   let temp = cmd.parameters.temporary || false;
   if (typeof path == "undefined" || typeof path != "string" ||
       typeof temp != "boolean") {
     throw InvalidArgumentError();
   }
 
   return addon.install(path, temp);
 };
 
 GeckoDriver.prototype.uninstallAddon = function(cmd, resp) {
-  assert.firefox()
+  assert.firefox();
 
   let id = cmd.parameters.id;
   if (typeof id == "undefined" || typeof id != "string") {
     throw new InvalidArgumentError();
   }
 
   return addon.uninstall(id);
 };
@@ -3300,17 +3300,17 @@ GeckoDriver.prototype.localizeEntity = f
   if (!Array.isArray(urls)) {
     throw new InvalidArgumentError("Value of `urls` should be of type 'Array'");
   }
   if (typeof id != "string") {
     throw new InvalidArgumentError("Value of `id` should be of type 'string'");
   }
 
   resp.body.value = l10n.localizeEntity(urls, id);
-}
+};
 
 /**
  * Retrieve the localized string for the specified property id.
  *
  * Example:
  *
  *     localizeProperty(
  *         ["chrome://global/locale/findbar.properties"], "FastFind");
@@ -3329,17 +3329,17 @@ GeckoDriver.prototype.localizeProperty =
   if (!Array.isArray(urls)) {
     throw new InvalidArgumentError("Value of `urls` should be of type 'Array'");
   }
   if (typeof id != "string") {
     throw new InvalidArgumentError("Value of `id` should be of type 'string'");
   }
 
   resp.body.value = l10n.localizeProperty(urls, id);
-}
+};
 
 /**
  * Initialize the reftest mode
  */
 GeckoDriver.prototype.setupReftest = function* (cmd, resp) {
   if (this._reftest) {
     throw new UnsupportedOperationError("Called reftest:setup with a reftest session already active");
   }
--- a/testing/marionette/element.js
+++ b/testing/marionette/element.js
@@ -1022,10 +1022,10 @@ element.isBooleanAttribute = function(el
   const customElement = !el.localName.includes("-");
   if ((attr == "hidden" || attr == "itemscope") && customElement) {
     return true;
   }
 
   if (!boolEls.hasOwnProperty(el.localName)) {
     return false;
   }
-  return boolEls[el.localName].includes(attr)
+  return boolEls[el.localName].includes(attr);
 };
--- a/testing/marionette/error.js
+++ b/testing/marionette/error.js
@@ -238,17 +238,17 @@ class WebDriverError extends Error {
    * @return {Object.<string, string>}
    *     JSON serialisation of error prototype.
    */
   toJSON() {
     return {
       error: this.status,
       message: this.message || "",
       stacktrace: this.stack || "",
-    }
+    };
   }
 
   /**
    * Unmarshals a JSON error representation to the appropriate Marionette
    * error type.
    *
    * @param {Object.<string, string>} json
    *     Error object.
--- a/testing/marionette/event.js
+++ b/testing/marionette/event.js
@@ -626,43 +626,43 @@ function emulateToActivateModifiers_(TIP
     ],
     lockable: [
       {key: "CapsLock",   attr: "capsLockKey"},
       {key: "FnLock",     attr: "fnLockKey"},
       {key: "NumLock",    attr: "numLockKey"},
       {key: "ScrollLock", attr: "scrollLockKey"},
       {key: "SymbolLock", attr: "symbolLockKey"},
     ],
-  }
+  };
 
   for (let i = 0; i < modifiers.normal.length; i++) {
     if (!keyEvent[modifiers.normal[i].attr]) {
       continue;
     }
     if (TIP.getModifierState(modifiers.normal[i].key)) {
       continue; // already activated.
     }
     let event = new KeyboardEvent("", {key: modifiers.normal[i].key});
     TIP.keydown(event,
-      TIP.KEY_NON_PRINTABLE_KEY | TIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT);
+        TIP.KEY_NON_PRINTABLE_KEY | TIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT);
     modifiers.normal[i].activated = true;
   }
 
   for (let j = 0; j < modifiers.lockable.length; j++) {
     if (!keyEvent[modifiers.lockable[j].attr]) {
       continue;
     }
     if (TIP.getModifierState(modifiers.lockable[j].key)) {
       continue; // already activated.
     }
     let event = new KeyboardEvent("", {key: modifiers.lockable[j].key});
     TIP.keydown(event,
-      TIP.KEY_NON_PRINTABLE_KEY | TIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT);
+        TIP.KEY_NON_PRINTABLE_KEY | TIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT);
     TIP.keyup(event,
-      TIP.KEY_NON_PRINTABLE_KEY | TIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT);
+        TIP.KEY_NON_PRINTABLE_KEY | TIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT);
     modifiers.lockable[j].activated = true;
   }
 
   return modifiers;
 }
 
 function emulateToInactivateModifiers_(TIP, modifiers, win = window) {
   if (!modifiers) {
@@ -670,30 +670,30 @@ function emulateToInactivateModifiers_(T
   }
   let KeyboardEvent = getKeyboardEvent_(win);
   for (let i = 0; i < modifiers.normal.length; i++) {
     if (!modifiers.normal[i].activated) {
       continue;
     }
     let event = new KeyboardEvent("", {key: modifiers.normal[i].key});
     TIP.keyup(event,
-      TIP.KEY_NON_PRINTABLE_KEY | TIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT);
+        TIP.KEY_NON_PRINTABLE_KEY | TIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT);
   }
   for (let j = 0; j < modifiers.lockable.length; j++) {
     if (!modifiers.lockable[j].activated) {
       continue;
     }
     if (!TIP.getModifierState(modifiers.lockable[j].key)) {
       continue; // who already inactivated this?
     }
     let event = new KeyboardEvent("", {key: modifiers.lockable[j].key});
     TIP.keydown(event,
-      TIP.KEY_NON_PRINTABLE_KEY | TIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT);
+        TIP.KEY_NON_PRINTABLE_KEY | TIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT);
     TIP.keyup(event,
-      TIP.KEY_NON_PRINTABLE_KEY | TIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT);
+        TIP.KEY_NON_PRINTABLE_KEY | TIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT);
   }
 }
 
 function isMac_(win = window) {
   if (win) {
     try {
       return win.navigator.platform.indexOf("Mac") > -1;
     } catch (ex) {}
--- a/testing/marionette/l10n.js
+++ b/testing/marionette/l10n.js
@@ -45,17 +45,17 @@ this.l10n = {};
  * @return {string}
  *     The localized string for the requested entity.
  */
 l10n.localizeEntity = function(urls, id) {
   // Build a string which contains all possible entity locations
   let locations = [];
   urls.forEach((url, index) => {
     locations.push(`<!ENTITY % dtd_${index} SYSTEM "${url}">%dtd_${index};`);
-  })
+  });
 
   // Use the DOM parser to resolve the entity and extract its real value
   let header = `<?xml version="1.0"?><!DOCTYPE elem [${locations.join("")}]>`;
   let elem = `<elem id="elementID">&${id};</elem>`;
   let doc = domParser.parseFromString(header + elem, "text/xml");
   let element = doc.querySelector("elem[id='elementID']");
 
   if (element === null) {
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -351,17 +351,17 @@ var loadListener = {
         //
         // Otherwise the timeout waiting for the document to start
         // navigating is increased by 5000 ms to ensure a possible load
         // event is not missed. In the common case such an event should
         // occur pretty soon after beforeunload, and we optimise for this.
         if (this.seenBeforeUnload) {
           this.seenBeforeUnload = null;
           this.timerPageUnload.initWithCallback(
-              this, 5000, Ci.nsITimer.TYPE_ONE_SHOT)
+              this, 5000, Ci.nsITimer.TYPE_ONE_SHOT);
 
         // If no page unload has been detected, ensure to properly stop
         // the load listener, and return from the currently active command.
         } else if (!this.seenUnload) {
           logger.debug("Canceled page load listener because no navigation " +
               "has been detected");
           this.stop();
           sendOk(this.command_id);
@@ -465,17 +465,17 @@ var loadListener = {
       if (loadEventExpected) {
         this.stop();
       }
 
       sendError(err, command_id);
 
     });
   },
-}
+};
 
 /**
  * Called when listener is first started up.  The listener sends its
  * unique window ID and its current URI to the actor.  If the actor returns
  * an ID, we start the listeners. Otherwise, nothing happens.
  */
 function registerSelf() {
   let msg = {value: winUtil.outerWindowID};
@@ -983,24 +983,24 @@ function emitMultiEvents(type, touch, to
     return ((t.target === target) &&
         ((type != "touchcancel") || (type != "touchend")));
   }));
   // Create changed touches
   let changedTouches = doc.createTouchList(touch);
   // Create the event object
   let event = doc.createEvent("TouchEvent");
   event.initTouchEvent(type,
-                       true,
-                       true,
-                       win,
-                       0,
-                       false, false, false, false,
-                       documentTouches,
-                       targetTouches,
-                       changedTouches);
+      true,
+      true,
+      win,
+      0,
+      false, false, false, false,
+      documentTouches,
+      targetTouches,
+      changedTouches);
   target.dispatchEvent(event);
 }
 
 function setDispatch(batches, touches, batchIndex = 0) {
   // check if all the sets have been fired
   if (batchIndex >= batches.length) {
     multiLast = {};
     return;
@@ -1361,19 +1361,19 @@ function clickElement(msg) {
     let target = getElementAttribute(id, "target");
 
     if (target === "_blank") {
       loadEventExpected = false;
     }
 
     loadListener.navigate(() => {
       return interaction.clickElement(
-        seenEls.get(id, curContainer),
-        capabilities.get("moz:accessibilityChecks"),
-        capabilities.get("specificationLevel") >= 1
+          seenEls.get(id, curContainer),
+          capabilities.get("moz:accessibilityChecks"),
+          capabilities.get("specificationLevel") >= 1
       );
     }, command_id, pageTimeout, loadEventExpected, true);
 
   } catch (e) {
     sendError(e, command_id);
   }
 }
 
--- a/testing/marionette/message.js
+++ b/testing/marionette/message.js
@@ -184,17 +184,17 @@ const validator = {
           throw new TypeError(`${t} set, cannot set ${prop}`);
         }
       }
     }
 
     obj[prop] = val;
     return true;
   },
-}
+};
 
 /**
  * The response body is exposed as an argument to commands.
  * Commands can set fields on the body through defining properties.
  *
  * Setting properties invokes a validator that performs tests for
  * mutually exclusionary fields on the input against the existing data
  * in the body.
--- a/testing/marionette/packets.js
+++ b/testing/marionette/packets.js
@@ -304,17 +304,17 @@ BulkPacket.prototype.write = function(st
     // Format the serialized packet header to a buffer
     this._outgoingHeader = "bulk " + this.actor + " " + this.type + " " +
                            this.length + ":";
   }
 
   // Write the header, or whatever's left of it to write.
   if (this._outgoingHeader.length) {
     let written = stream.write(this._outgoingHeader,
-                               this._outgoingHeader.length);
+        this._outgoingHeader.length);
     this._outgoingHeader = this._outgoingHeader.slice(written);
     return;
   }
 
   // Temporarily pause the monitoring of the output stream
   this._transport.pauseOutgoing();
 
   let deferred = defer();
--- a/testing/marionette/proxy.js
+++ b/testing/marionette/proxy.js
@@ -148,17 +148,17 @@ proxy.AsyncMessageChannel = class {
 
         switch (event.type) {
           case "TabClose":
           case "unload":
             this.removeHandlers();
             resolve();
             break;
         }
-      }
+      };
 
       // A modal or tab modal dialog has been opened. To be able to handle it,
       // the active command has to be aborted. Therefore remove all handlers,
       // and cancel any ongoing requests in the listener.
       this.dialogueObserver_ = (subject, topic) => {
         logger.debug(`Received observer notification "${topic}"`);
 
         this.removeAllListeners_();
--- a/testing/marionette/reftest.js
+++ b/testing/marionette/reftest.js
@@ -95,20 +95,21 @@ reftest.Runner = class {
       .getInterface(Ci.nsIDOMWindowUtils);
     this.reftestWin = reftestWin;
     return reftestWin;
   }
 
   *openWindow() {
     let reftestWin;
     yield new Promise(resolve => {
-      reftestWin = this.parentWindow.openDialog("chrome://marionette/content/reftest.xul",
-                                                "reftest",
-                                                "chrome,dialog,height=600,width=600,all",
-                                                () => resolve());
+      reftestWin = this.parentWindow.openDialog(
+          "chrome://marionette/content/reftest.xul",
+          "reftest",
+          "chrome,dialog,height=600,width=600,all",
+          () => resolve());
     });
 
     let browser = reftestWin.document.createElementNS(XUL_NS, "xul:browser");
     browser.permanentKey = {};
     browser.setAttribute("id", "browser");
     browser.setAttribute("anonid", "initialBrowser");
     browser.setAttribute("type", "content");
     browser.setAttribute("primary", "true");
--- a/testing/marionette/stream-utils.js
+++ b/testing/marionette/stream-utils.js
@@ -1,24 +1,28 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
-const {Constructor: CC, classes: Cc, interfaces: Ci, utils: Cu, results: Cr} =
-    Components;
+const {
+  Constructor: CC,
+  classes: Cc,
+  interfaces: Ci,
+  utils: Cu,
+  results: Cr,
+} = Components;
 
 Cu.import("resource://gre/modules/EventEmitter.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 const IOUtil = Cc["@mozilla.org/io-util;1"].getService(Ci.nsIIOUtil);
-const ScriptableInputStream =
-  CC("@mozilla.org/scriptableinputstream;1",
-     "nsIScriptableInputStream", "init");
+const ScriptableInputStream = CC("@mozilla.org/scriptableinputstream;1",
+    "nsIScriptableInputStream", "init");
 
 this.EXPORTED_SYMBOLS = ["StreamUtils"];
 
 const BUFFER_SIZE = 0x8000;
 
 /**
  * This helper function (and its companion object) are used by bulk
  * senders and receivers to read and write data in and out of other streams.
--- a/testing/marionette/transport.js
+++ b/testing/marionette/transport.js
@@ -35,17 +35,17 @@ const flags = {wantVerbose: false, wantL
 const dumpv =
   flags.wantVerbose ?
   function(msg) { dump(msg + "\n"); } :
   function() {};
 
 const Pipe = CC("@mozilla.org/pipe;1", "nsIPipe", "init");
 
 const ScriptableInputStream = CC("@mozilla.org/scriptableinputstream;1",
-  "nsIScriptableInputStream", "init");
+    "nsIScriptableInputStream", "init");
 
 this.EXPORTED_SYMBOLS = ["DebuggerTransport"];
 
 const PACKET_HEADER_MAX = 200;
 
 /**
  * An adapter that handles data transfers between the debugger client
  * and server. It can work with both nsIPipe and nsIServerSocket