Bug 1245496 - Fix eslint errors in about:debugging. r=janx
authorJoe Whitfield-Seed <joeseed86@gmail.com>
Thu, 04 Feb 2016 20:10:08 +0000
changeset 306268 f868ae3daac3fbd463c04978157d63fa287f1aaf
parent 306267 cb9d869cb735b0dee8dc23287cff11c143662417
child 306269 745013040734a4d2ffdd239be3f0662b98a8d3cb
push id9214
push userraliiev@mozilla.com
push dateMon, 07 Mar 2016 14:25:21 +0000
treeherdermozilla-aurora@8849dd1a4a79 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanx
bugs1245496
milestone47.0a1
Bug 1245496 - Fix eslint errors in about:debugging. r=janx
.eslintignore
devtools/client/aboutdebugging/aboutdebugging.js
devtools/client/aboutdebugging/test/addons/unpacked/bootstrap.js
devtools/client/aboutdebugging/test/browser_addons_install.js
devtools/client/aboutdebugging/test/browser_service_workers.js
devtools/client/aboutdebugging/test/browser_service_workers_timeout.js
devtools/client/aboutdebugging/test/head.js
devtools/client/aboutdebugging/test/service-workers/empty-sw.html
--- a/.eslintignore
+++ b/.eslintignore
@@ -77,17 +77,16 @@ browser/extensions/pocket/content/panels
 browser/extensions/shumway/**
 browser/locales/**
 
 # Ignore all of loop since it is imported from github and checked at source.
 browser/extensions/loop/**
 
 # devtools/ exclusions
 devtools/*.js
-devtools/client/aboutdebugging/**
 devtools/client/animationinspector/**
 devtools/client/canvasdebugger/**
 devtools/client/commandline/**
 devtools/client/debugger/**
 devtools/client/eyedropper/**
 devtools/client/framework/**
 # devtools/client/inspector/shared/*.js files are eslint-clean, so they aren't
 # included in the ignore list.
--- a/devtools/client/aboutdebugging/aboutdebugging.js
+++ b/devtools/client/aboutdebugging/aboutdebugging.js
@@ -1,19 +1,19 @@
 /* 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/. */
 
 /* eslint-env browser */
 /* global AddonsComponent, DebuggerClient, DebuggerServer, React,
-   RuntimesComponent, WorkersComponent */
+   WorkersComponent */
 
 "use strict";
 
-const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
+const { classes: Cc, interfaces: Ci } = Components;
 const { loader } = Components.utils.import(
   "resource://devtools/shared/Loader.jsm", {});
 
 loader.lazyRequireGetter(this, "AddonsComponent",
   "devtools/client/aboutdebugging/components/addons", true);
 loader.lazyRequireGetter(this, "DebuggerClient",
   "devtools/shared/client/main", true);
 loader.lazyRequireGetter(this, "DebuggerServer",
@@ -139,17 +139,17 @@ var AboutDebugging = {
     let file = fp.file;
     // AddonManager.installTemporaryAddon accepts either
     // addon directory or final xpi file.
     if (!file.isDirectory() && !file.leafName.endsWith(".xpi")) {
       file = file.parent;
     }
     try {
       AddonManager.installTemporaryAddon(file);
-    } catch(e) {
+    } catch (e) {
       alert("Error while installing the addon:\n" + e.message + "\n");
       throw e;
     }
   },
 
   destroy() {
     let telemetry = this._telemetry;
     telemetry.toolClosed("aboutdebugging");
--- a/devtools/client/aboutdebugging/test/addons/unpacked/bootstrap.js
+++ b/devtools/client/aboutdebugging/test/addons/unpacked/bootstrap.js
@@ -1,7 +1,15 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/* eslint-env browser */
+/* exported startup, shutdown, install, uninstall */
+
+"use strict";
+
 Components.utils.import("resource://gre/modules/Services.jsm");
 function startup() {
   Services.obs.notifyObservers(null, "test-devtools", null);
 }
 function shutdown() {}
 function install() {}
 function uninstall() {}
--- a/devtools/client/aboutdebugging/test/browser_addons_install.js
+++ b/devtools/client/aboutdebugging/test/browser_addons_install.js
@@ -1,27 +1,30 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 "use strict";
 
 const ADDON_ID = "test-devtools@mozilla.org";
 const ADDON_NAME = "test-devtools";
 
-add_task(function *() {
+add_task(function* () {
   let { tab, document } = yield openAboutDebugging("addons");
 
   yield installAddon(document, "addons/unpacked/install.rdf", "test-devtools");
 
   // Check that the addon appears in the UI
   let names = [...document.querySelectorAll("#addons .target-name")];
   names = names.map(element => element.textContent);
-  ok(names.includes(ADDON_NAME), "The addon name appears in the list of addons: " + names);
+  ok(names.includes(ADDON_NAME),
+    "The addon name appears in the list of addons: " + names);
 
   // Now uninstall this addon
   yield uninstallAddon(ADDON_ID);
 
   // Ensure that the UI removes the addon from the list
   names = [...document.querySelectorAll("#addons .target-name")];
   names = names.map(element => element.textContent);
-  ok(!names.includes(ADDON_NAME), "After uninstall, the addon name disappears from the list of addons: " + names);
+  ok(!names.includes(ADDON_NAME),
+    "After uninstall, the addon name disappears from the list of addons: "
+    + names);
 
   yield closeAboutDebugging(tab);
 });
--- a/devtools/client/aboutdebugging/test/browser_service_workers.js
+++ b/devtools/client/aboutdebugging/test/browser_service_workers.js
@@ -1,52 +1,57 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/* eslint-disable mozilla/no-cpows-in-tests */
+/* global sendAsyncMessage */
+
 "use strict";
 
 // Service workers can't be loaded from chrome://,
 // but http:// is ok with dom.serviceWorkers.testing.enabled turned on.
 const HTTP_ROOT = CHROME_ROOT.replace("chrome://mochitests/content/",
                                       "http://mochi.test:8888/");
 const SERVICE_WORKER = HTTP_ROOT + "service-workers/empty-sw.js";
 const TAB_URL = HTTP_ROOT + "service-workers/empty-sw.html";
 
-add_task(function *() {
+add_task(function* () {
   yield new Promise(done => {
     let options = {"set": [
-                    ["dom.serviceWorkers.testing.enabled", true],
-                  ]};
+      ["dom.serviceWorkers.testing.enabled", true],
+    ]};
     SpecialPowers.pushPrefEnv(options, done);
   });
 
   let { tab, document } = yield openAboutDebugging("workers");
 
   let swTab = yield addTab(TAB_URL);
 
   let serviceWorkersElement = document.getElementById("service-workers");
   yield waitForMutation(serviceWorkersElement, { childList: true });
 
   // Check that the service worker appears in the UI
   let names = [...document.querySelectorAll("#service-workers .target-name")];
   names = names.map(element => element.textContent);
-  ok(names.includes(SERVICE_WORKER), "The service worker url appears in the list: " + names);
+  ok(names.includes(SERVICE_WORKER),
+    "The service worker url appears in the list: " + names);
 
   // Finally, unregister the service worker itself
   let aboutDebuggingUpdate = waitForMutation(serviceWorkersElement,
     { childList: true });
 
   // Use message manager to work with e10s
-  let frameScript = function () {
+  let frameScript = function() {
     // Retrieve the `sw` promise created in the html page
     let { sw } = content.wrappedJSObject;
-    sw.then(function (registration) {
-      registration.unregister().then(function (success) {
+    sw.then(function(registration) {
+      registration.unregister().then(function() {
         sendAsyncMessage("sw-unregistered");
       },
-      function (e) {
+      function(e) {
         dump("SW not unregistered; " + e + "\n");
       });
     });
   };
   let mm = swTab.linkedBrowser.messageManager;
   mm.loadFrameScript("data:,(" + encodeURIComponent(frameScript) + ")()", true);
 
   yield new Promise(done => {
@@ -57,13 +62,14 @@ add_task(function *() {
   });
   ok(true, "Service worker registration unregistered");
 
   yield aboutDebuggingUpdate;
 
   // Check that the service worker disappeared from the UI
   names = [...document.querySelectorAll("#service-workers .target-name")];
   names = names.map(element => element.textContent);
-  ok(!names.includes(SERVICE_WORKER), "The service worker url is no longer in the list: " + names);
+  ok(!names.includes(SERVICE_WORKER),
+    "The service worker url is no longer in the list: " + names);
 
   yield removeTab(swTab);
   yield closeAboutDebugging(tab);
 });
--- a/devtools/client/aboutdebugging/test/browser_service_workers_timeout.js
+++ b/devtools/client/aboutdebugging/test/browser_service_workers_timeout.js
@@ -1,54 +1,59 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/* eslint-disable mozilla/no-cpows-in-tests */
+/* global sendAsyncMessage */
+
 "use strict";
 
 // Service workers can't be loaded from chrome://,
 // but http:// is ok with dom.serviceWorkers.testing.enabled turned on.
 const HTTP_ROOT = CHROME_ROOT.replace("chrome://mochitests/content/",
                                       "http://mochi.test:8888/");
 const SERVICE_WORKER = HTTP_ROOT + "service-workers/empty-sw.js";
 const TAB_URL = HTTP_ROOT + "service-workers/empty-sw.html";
 
 const SW_TIMEOUT = 1000;
 
 function assertHasWorker(expected, document, type, name) {
   let names = [...document.querySelectorAll("#" + type + " .target-name")];
   names = names.map(element => element.textContent);
-  is(names.includes(name), expected, "The " + type + " url appears in the list: " + names);
+  is(names.includes(name), expected,
+      "The " + type + " url appears in the list: " + names);
 }
 
-add_task(function *() {
+add_task(function* () {
   yield new Promise(done => {
     let options = {"set": [
-                    // Accept workers from mochitest's http
-                    ["dom.serviceWorkers.testing.enabled", true],
-                    // Reduce the timeout to expose issues when service worker
-                    // freezing is broken
-                    ["dom.serviceWorkers.idle_timeout", SW_TIMEOUT],
-                    ["dom.serviceWorkers.idle_extended_timeout", SW_TIMEOUT],
-                  ]};
+      // Accept workers from mochitest's http
+      ["dom.serviceWorkers.testing.enabled", true],
+      // Reduce the timeout to expose issues when service worker
+      // freezing is broken
+      ["dom.serviceWorkers.idle_timeout", SW_TIMEOUT],
+      ["dom.serviceWorkers.idle_extended_timeout", SW_TIMEOUT],
+    ]};
     SpecialPowers.pushPrefEnv(options, done);
   });
 
   let { tab, document } = yield openAboutDebugging("workers");
 
   let swTab = yield addTab(TAB_URL);
 
   let serviceWorkersElement = document.getElementById("service-workers");
   yield waitForMutation(serviceWorkersElement, { childList: true });
 
   assertHasWorker(true, document, "service-workers", SERVICE_WORKER);
 
   // Ensure that the registration resolved before trying to connect to the sw
-  let frameScript = function () {
+  let frameScript = function() {
     // Retrieve the `sw` promise created in the html page
     let { sw } = content.wrappedJSObject;
-    sw.then(function (registration) {
+    sw.then(function() {
       sendAsyncMessage("sw-registered");
     });
   };
   let mm = swTab.linkedBrowser.messageManager;
   mm.loadFrameScript("data:,(" + encodeURIComponent(frameScript) + ")()", true);
 
   yield new Promise(done => {
     mm.addMessageListener("sw-registered", function listener() {
@@ -62,17 +67,17 @@ add_task(function *() {
   let names = [...document.querySelectorAll("#service-workers .target-name")];
   let name = names.filter(element => element.textContent === SERVICE_WORKER)[0];
   ok(name, "Found the service worker in the list");
   let debugBtn = name.parentNode.parentNode.querySelector("button");
   ok(debugBtn, "Found its debug button");
 
   // Click on it and wait for the toolbox to be ready
   let onToolboxReady = new Promise(done => {
-    gDevTools.once("toolbox-ready", function (e, toolbox) {
+    gDevTools.once("toolbox-ready", function(e, toolbox) {
       done(toolbox);
     });
   });
   debugBtn.click();
 
   let toolbox = yield onToolboxReady;
 
   // Wait for more than the regular timeout,
@@ -91,24 +96,24 @@ add_task(function *() {
   // after we destroy the toolbox.
   // The list should update once it get destroyed.
   yield waitForMutation(serviceWorkersElement, { childList: true });
 
   assertHasWorker(false, document, "service-workers", SERVICE_WORKER);
 
   // Finally, unregister the service worker itself
   // Use message manager to work with e10s
-  frameScript = function () {
+  frameScript = function() {
     // Retrieve the `sw` promise created in the html page
     let { sw } = content.wrappedJSObject;
-    sw.then(function (registration) {
-      registration.unregister().then(function (success) {
+    sw.then(function(registration) {
+      registration.unregister().then(function() {
         sendAsyncMessage("sw-unregistered");
       },
-      function (e) {
+      function(e) {
         dump("SW not unregistered; " + e + "\n");
       });
     });
   };
   mm = swTab.linkedBrowser.messageManager;
   mm.loadFrameScript("data:,(" + encodeURIComponent(frameScript) + ")()", true);
 
   yield new Promise(done => {
--- a/devtools/client/aboutdebugging/test/head.js
+++ b/devtools/client/aboutdebugging/test/head.js
@@ -1,11 +1,15 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+/* eslint-env browser */
+/* exported openAboutDebugging, closeAboutDebugging, installAddon,
+   uninstallAddon, waitForMutation */
+
 "use strict";
 
 var {utils: Cu, classes: Cc, interfaces: Ci} = Components;
 
 const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
 const {AddonManager} = Cu.import("resource://gre/modules/AddonManager.jsm", {});
 const Services = require("Services");
 const DevToolsUtils = require("devtools/shared/DevToolsUtils");
@@ -32,65 +36,66 @@ function openAboutDebugging(page) {
   });
 }
 
 function closeAboutDebugging(tab) {
   info("Closing about:debugging");
   return removeTab(tab);
 }
 
-function addTab(aUrl, aWindow) {
-  info("Adding tab: " + aUrl);
+function addTab(url, win) {
+  info("Adding tab: " + url);
 
   return new Promise(done => {
-    let targetWindow = aWindow || window;
+    let targetWindow = win || window;
     let targetBrowser = targetWindow.gBrowser;
 
     targetWindow.focus();
-    let tab = targetBrowser.selectedTab = targetBrowser.addTab(aUrl);
+    let tab = targetBrowser.selectedTab = targetBrowser.addTab(url);
     let linkedBrowser = tab.linkedBrowser;
 
     linkedBrowser.addEventListener("load", function onLoad() {
       linkedBrowser.removeEventListener("load", onLoad, true);
-      info("Tab added and finished loading: " + aUrl);
+      info("Tab added and finished loading: " + url);
       done(tab);
     }, true);
   });
 }
 
-function removeTab(aTab, aWindow) {
+function removeTab(tab, win) {
   info("Removing tab.");
 
   return new Promise(done => {
-    let targetWindow = aWindow || window;
+    let targetWindow = win || window;
     let targetBrowser = targetWindow.gBrowser;
     let tabContainer = targetBrowser.tabContainer;
 
-    tabContainer.addEventListener("TabClose", function onClose(aEvent) {
+    tabContainer.addEventListener("TabClose", function onClose() {
       tabContainer.removeEventListener("TabClose", onClose, false);
       info("Tab removed and finished closing.");
       done();
     }, false);
 
-    targetBrowser.removeTab(aTab);
+    targetBrowser.removeTab(tab);
   });
 }
 
-function get_supports_file(path) {
-  let cr = Cc["@mozilla.org/chrome/chrome-registry;1"].
-  getService(Ci.nsIChromeRegistry);
-  let fileurl = cr.convertChromeURL(Services.io.newURI(CHROME_ROOT + path, null, null));
+function getSupportsFile(path) {
+  let cr = Cc["@mozilla.org/chrome/chrome-registry;1"]
+    .getService(Ci.nsIChromeRegistry);
+  let uri = Services.io.newURI(CHROME_ROOT + path, null, null);
+  let fileurl = cr.convertChromeURL(uri);
   return fileurl.QueryInterface(Ci.nsIFileURL);
 }
 
 function installAddon(document, path, evt) {
   // Mock the file picker to select a test addon
   let MockFilePicker = SpecialPowers.MockFilePicker;
   MockFilePicker.init(null);
-  let file = get_supports_file(path);
+  let file = getSupportsFile(path);
   MockFilePicker.returnFiles = [file.file];
 
   // Wait for a message sent by the addon's bootstrap.js file
   let onAddonInstalled = new Promise(done => {
     Services.obs.addObserver(function listener() {
       Services.obs.removeObserver(listener, evt, false);
       ok(true, "Addon installed and running its bootstrap.js file");
       done();
--- a/devtools/client/aboutdebugging/test/service-workers/empty-sw.html
+++ b/devtools/client/aboutdebugging/test/service-workers/empty-sw.html
@@ -1,20 +1,22 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <meta charset="UTF-8">
   <title>Service worker test</title>
 </head>
 <body>
 <script type="text/javascript">
+"use strict";
+
 var sw = navigator.serviceWorker.register("empty-sw.js");
 sw.then(
-  function (registration) {
+  function() {
     dump("SW registered\n");
   },
-  function (e) {
+  function(e) {
     dump("SW not registered: " + e + "\n");
   }
 );
 </script>
 </body>
 </html>