Bug 1342144 - Fix ESLint errors in browser/. r=Paolo draft
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Fri, 24 Feb 2017 23:25:45 +0900
changeset 489773 af62eeccdc22b63022ac18e46023c153798caa94
parent 489772 3e55a893d12ea2c6073313d5f5d55daf847137bc
child 489774 750a58b1d258a7112d3def04940ad3e610b19747
push id46895
push userVYV03354@nifty.ne.jp
push dateSun, 26 Feb 2017 03:42:29 +0000
reviewersPaolo
bugs1342144
milestone54.0a1
Bug 1342144 - Fix ESLint errors in browser/. r=Paolo MozReview-Commit-ID: ByMEEcTQQtd
browser/base/content/aboutProviderDirectory.xhtml
browser/base/content/aboutSocialError.xhtml
browser/base/content/test/general/accounts_testRemoteCommands.html
browser/base/content/test/general/healthreport_testRemoteCommands.html
browser/components/originattributes/test/browser/file_broadcastChannel.html
browser/components/originattributes/test/browser/file_broadcastChanneliFrame.html
browser/components/originattributes/test/mochitest/test_permissions_api.html
--- a/browser/base/content/aboutProviderDirectory.xhtml
+++ b/browser/base/content/aboutProviderDirectory.xhtml
@@ -39,17 +39,17 @@
   </body>
 
   <script type="text/javascript"><![CDATA[
     const Cu = Components.utils;
 
     Cu.import("resource://gre/modules/Services.jsm");
 
     function openDirectory() {
-      let url = Services.prefs.getCharPref("social.directories").split(',')[0];
+      let url = Services.prefs.getCharPref("social.directories").split(",")[0];
       window.open(url);
       window.close();
     }
     
     if (Services.prefs.getBoolPref("social.share.activationPanelEnabled")) {
       let url = Services.prefs.getCharPref("social.shareDirectory");
       document.getElementById("activation-frame").setAttribute("src", url);
       document.getElementById("activation").removeAttribute("hidden");
--- a/browser/base/content/aboutSocialError.xhtml
+++ b/browser/base/content/aboutSocialError.xhtml
@@ -56,20 +56,20 @@
       if (!config.origin) {
         let URI = Services.io.newURI(url);
         config.origin =
           Services.scriptSecurityManager.createCodebasePrincipal(URI, {}).origin;
       }
 
       switch (mode) {
         case "compactInfo":
-          document.getElementById("btnTryAgain").style.display = 'none';
+          document.getElementById("btnTryAgain").style.display = "none";
           break;
         case "tryAgainOnly":
-          //intentional fall-through
+          // intentional fall-through
         case "tryAgain":
           config.tryAgainCallback = loadQueryURL;
           config.queryURL = url;
           break;
         default:
           break;
       }
     }
--- a/browser/base/content/test/general/accounts_testRemoteCommands.html
+++ b/browser/base/content/test/general/accounts_testRemoteCommands.html
@@ -1,83 +1,83 @@
-<html>
-  <head>
-    <meta charset="utf-8">
-
-<script type="text/javascript">
-
-function init() {
-  window.addEventListener("message", function process(e) {doTest(e)});
-  // unless we relinquish the eventloop,
-  // tests will run before the chrome event handlers are ready
-  setTimeout(doTest, 0);
-}
-
-function checkStatusValue(payload, expectedValue) {
-  return payload.status == expectedValue;
-}
-
-let tests = [
-{
-  info: "Check account log in",
-  event: "login",
-  data: {
-    email: "foo@example.com",
-    uid: "1234@lcip.org",
-    assertion: "foobar",
-    sessionToken: "dead",
-    kA: "beef",
-    kB: "cafe",
-    verified: true
-  },
-  payloadType: "message",
-  validateResponse: function(payload) {
-    return checkStatusValue(payload, "login");
-  },
-},
-];
-
-let currentTest = -1;
-function doTest(evt) {
-  if (evt) {
-    if (currentTest < 0 || !evt.data.content)
-      return; // not yet testing
-
-    let test = tests[currentTest];
-    if (evt.data.type != test.payloadType)
-      return; // skip unrequested events
-
-    let error = JSON.stringify(evt.data.content);
-    let pass = false;
-    try {
-      pass = test.validateResponse(evt.data.content)
-    } catch (e) {}
-    reportResult(test.info, pass, error);
-  }
-  // start the next test if there are any left
-  if (tests[++currentTest])
-    sendToBrowser(tests[currentTest].event, tests[currentTest].data);
-  else
-    reportFinished();
-}
-
-function reportResult(info, pass, error) {
-  let data = {type: "testResult", info: info, pass: pass, error: error};
-  let event = new CustomEvent("FirefoxAccountsTestResponse", {detail: {data: data}, bubbles: true});
-  document.dispatchEvent(event);
-}
-
-function reportFinished(cmd) {
-  let data = {type: "testsComplete", count: tests.length};
-  let event = new CustomEvent("FirefoxAccountsTestResponse", {detail: {data: data}, bubbles: true});
-  document.dispatchEvent(event);
-}
-
-function sendToBrowser(type, data) {
-  let event = new CustomEvent("FirefoxAccountsCommand", {detail: {command: type, data: data}, bubbles: true});
-  document.dispatchEvent(event);
-}
-
-</script>
-  </head>
-  <body onload="init()">
-  </body>
-</html>
+<html>
+  <head>
+    <meta charset="utf-8">
+
+<script type="text/javascript">
+
+function init() {
+  window.addEventListener("message", function process(e) { doTest(e) });
+  // unless we relinquish the eventloop,
+  // tests will run before the chrome event handlers are ready
+  setTimeout(doTest, 0);
+}
+
+function checkStatusValue(payload, expectedValue) {
+  return payload.status == expectedValue;
+}
+
+let tests = [
+{
+  info: "Check account log in",
+  event: "login",
+  data: {
+    email: "foo@example.com",
+    uid: "1234@lcip.org",
+    assertion: "foobar",
+    sessionToken: "dead",
+    kA: "beef",
+    kB: "cafe",
+    verified: true
+  },
+  payloadType: "message",
+  validateResponse(payload) {
+    return checkStatusValue(payload, "login");
+  },
+},
+];
+
+let currentTest = -1;
+function doTest(evt) {
+  if (evt) {
+    if (currentTest < 0 || !evt.data.content)
+      return; // not yet testing
+
+    let test = tests[currentTest];
+    if (evt.data.type != test.payloadType)
+      return; // skip unrequested events
+
+    let error = JSON.stringify(evt.data.content);
+    let pass = false;
+    try {
+      pass = test.validateResponse(evt.data.content)
+    } catch (e) {}
+    reportResult(test.info, pass, error);
+  }
+  // start the next test if there are any left
+  if (tests[++currentTest])
+    sendToBrowser(tests[currentTest].event, tests[currentTest].data);
+  else
+    reportFinished();
+}
+
+function reportResult(info, pass, error) {
+  let data = {type: "testResult", info, pass, error};
+  let event = new CustomEvent("FirefoxAccountsTestResponse", {detail: {data}, bubbles: true});
+  document.dispatchEvent(event);
+}
+
+function reportFinished(cmd) {
+  let data = {type: "testsComplete", count: tests.length};
+  let event = new CustomEvent("FirefoxAccountsTestResponse", {detail: {data}, bubbles: true});
+  document.dispatchEvent(event);
+}
+
+function sendToBrowser(type, data) {
+  let event = new CustomEvent("FirefoxAccountsCommand", {detail: {command: type, data}, bubbles: true});
+  document.dispatchEvent(event);
+}
+
+</script>
+  </head>
+  <body onload="init()">
+  </body>
+</html>
--- a/browser/base/content/test/general/healthreport_testRemoteCommands.html
+++ b/browser/base/content/test/general/healthreport_testRemoteCommands.html
@@ -11,17 +11,17 @@ function init() {
   doTest();
 }
 
 function checkSubmissionValue(payload, expectedValue) {
   return payload.enabled == expectedValue;
 }
 
 function isArray(arg) {
-  return Object.prototype.toString.call(arg) === '[object Array]';
+  return Object.prototype.toString.call(arg) === "[object Array]";
 }
 
 function writeDiagnostic(text) {
   let node = document.createTextNode(text);
   let br = document.createElement("br");
   document.body.appendChild(node);
   document.body.appendChild(br);
 }
@@ -57,31 +57,31 @@ function validateTelemetryPingList(list)
   list = list.filter(p => TEST_TYPES_REGEX.test(p.type));
 
   if (list.length != TEST_PINGS.length) {
     console.log("Telemetry ping length is not correct.");
     return false;
   }
 
   let valid = true;
-  for (let i=0; i<list.length; ++i) {
+  for (let i = 0; i < list.length; ++i) {
     let received = list[i];
     let expected = TEST_PINGS[i];
     if (received.type != expected.type ||
         received.timestampCreated != expected.date.getTime()) {
       writeDiagnostic("Telemetry ping " + i + " does not match.");
       writeDiagnostic("Expected: " + JSON.stringify(expected));
       writeDiagnostic("Received: " + JSON.stringify(received));
       valid = false;
     } else {
       writeDiagnostic("Telemetry ping " + i + " matches.");
     }
   }
 
-  return true;
+  return valid;
 }
 
 function validateTelemetryPingData(expected, received) {
   const receivedDate = new Date(received.creationDate);
   if (received.id != expected.id ||
       received.type != expected.type ||
       receivedDate.getTime() != expected.date.getTime()) {
     writeDiagnostic("Telemetry ping data for " + expected.id + " doesn't match.");
@@ -94,97 +94,97 @@ function validateTelemetryPingData(expec
   return true;
 }
 
 var tests = [
 {
   info: "Checking initial value is enabled",
   event: "RequestCurrentPrefs",
   payloadType: "prefs",
-  validateResponse: function(payload) {
+  validateResponse(payload) {
     return checkSubmissionValue(payload, true);
   },
 },
 {
   info: "Verifying disabling works",
   event: "DisableDataSubmission",
   payloadType: "prefs",
-  validateResponse: function(payload) {
+  validateResponse(payload) {
     return checkSubmissionValue(payload, false);
   },
 },
 {
   info: "Verifying we're still disabled",
   event: "RequestCurrentPrefs",
   payloadType: "prefs",
-  validateResponse: function(payload) {
+  validateResponse(payload) {
     return checkSubmissionValue(payload, false);
   },
 },
 {
   info: "Verifying that we can get the current ping data while submission is disabled",
   event: "RequestCurrentPingData",
   payloadType: "telemetry-current-ping-data",
-  validateResponse: function(payload) {
+  validateResponse(payload) {
     return validateCurrentTelemetryPingData(payload);
   },
 },
 {
   info: "Verifying enabling works",
   event: "EnableDataSubmission",
   payloadType: "prefs",
-  validateResponse: function(payload) {
+  validateResponse(payload) {
     return checkSubmissionValue(payload, true);
   },
 },
 {
   info: "Verifying we're still re-enabled",
   event: "RequestCurrentPrefs",
   payloadType: "prefs",
-  validateResponse: function(payload) {
+  validateResponse(payload) {
     return checkSubmissionValue(payload, true);
   },
 },
 {
   info: "Verifying that we can get the current Telemetry environment data",
   event: "RequestCurrentEnvironment",
   payloadType: "telemetry-current-environment-data",
-  validateResponse: function(payload) {
+  validateResponse(payload) {
     return validateCurrentTelemetryEnvironment(payload);
   },
 },
 {
   info: "Verifying that we can get the current Telemetry ping data",
   event: "RequestCurrentPingData",
   payloadType: "telemetry-current-ping-data",
-  validateResponse: function(payload) {
+  validateResponse(payload) {
     return validateCurrentTelemetryPingData(payload);
   },
 },
 {
   info: "Verifying that we get the proper Telemetry ping list",
   event: "RequestTelemetryPingList",
   payloadType: "telemetry-ping-list",
-  validateResponse: function(payload) {
+  validateResponse(payload) {
     // Validate the ping list
     if (!validateTelemetryPingList(payload)) {
       return false;
     }
 
     // Now that we received the ping ids, set up additional test tasks
     // that check loading the individual pings.
-    for (let i=0; i<TEST_PINGS.length; ++i) {
+    for (let i = 0; i < TEST_PINGS.length; ++i) {
       TEST_PINGS[i].id = payload[i].id;
       tests.push({
         info: "Verifying that we can get the proper Telemetry ping data #" + (i + 1),
         event: "RequestTelemetryPingData",
         eventData: { id: TEST_PINGS[i].id },
         payloadType: "telemetry-ping-data",
-        validateResponse: function(payload) {
-          return validateTelemetryPingData(TEST_PINGS[i], payload.pingData);
+        validateResponse(payload2) {
+          return validateTelemetryPingData(TEST_PINGS[i], payload2.pingData);
         },
       });
     }
 
     return true;
   },
 },
 ];
@@ -209,35 +209,35 @@ function doTest(evt) {
   // start the next test if there are any left
   if (tests[++currentTest])
     sendToBrowser(tests[currentTest].event, tests[currentTest].eventData);
   else
     reportFinished();
 }
 
 function reportResult(info, pass, error) {
-  var data = {type: "testResult", info: info, pass: pass, error: error};
-  var event = new CustomEvent("FirefoxHealthReportTestResponse", {detail: {data: data}, bubbles: true});
+  var data = {type: "testResult", info, pass, error};
+  var event = new CustomEvent("FirefoxHealthReportTestResponse", {detail: {data}, bubbles: true});
   document.dispatchEvent(event);
 }
 
 function reportFinished(cmd) {
   var data = {type: "testsComplete", count: tests.length};
-  var event = new CustomEvent("FirefoxHealthReportTestResponse", {detail: {data: data}, bubbles: true});
+  var event = new CustomEvent("FirefoxHealthReportTestResponse", {detail: {data}, bubbles: true});
   document.dispatchEvent(event);
 }
 
 function sendToBrowser(type, eventData) {
   eventData = eventData || {};
   let detail = {command: type};
   for (let key of Object.keys(eventData)) {
     detail[key] = eventData[key];
   }
 
-  var event = new CustomEvent("RemoteHealthReportCommand", {detail: detail, bubbles: true});
+  var event = new CustomEvent("RemoteHealthReportCommand", {detail, bubbles: true});
   document.dispatchEvent(event);
 }
 
 </script>
   </head>
   <body onload="init()">
   </body>
 </html>
--- a/browser/components/originattributes/test/browser/file_broadcastChannel.html
+++ b/browser/components/originattributes/test/browser/file_broadcastChannel.html
@@ -4,13 +4,13 @@
   <meta http-equiv="content-type" content="text/html; charset=utf-8">
   <title>Page broadcast channel creator for first party isolation</title>
 </head>
 <body>
   <div id="display" style="white-space:pre; font-family:monospace; display:inline;"></div>
   <iframe id="iframe" src="file_broadcastChanneliFrame.html"></iframe>>
 <script type="text/javascript">
 let bc = new BroadcastChannel("testBroadcastChannel");
-bc.onmessage = function (e) {
+bc.onmessage = function(e) {
   document.getElementById("display").innerHTML = e.data;
 };
 </script>
 </body>
--- a/browser/components/originattributes/test/browser/file_broadcastChanneliFrame.html
+++ b/browser/components/originattributes/test/browser/file_broadcastChanneliFrame.html
@@ -3,13 +3,13 @@
 <head>
   <meta http-equiv="content-type" content="text/html; charset=utf-8">
   <title>Page broadcast channel responder for first party isolation</title>
 </head>
 <body>
   <div id="display" style="white-space:pre; font-family:monospace; display:inline;"></div>
 <script type="text/javascript">
 let bc = new BroadcastChannel("testBroadcastChannel");
-bc.onmessage = function (e) {
+bc.onmessage = function(e) {
   window.parent.postMessage(e.data, "*");
 };
 </script>
 </body>
--- a/browser/components/originattributes/test/mochitest/test_permissions_api.html
+++ b/browser/components/originattributes/test/mochitest/test_permissions_api.html
@@ -10,82 +10,82 @@
   <title>Test for Permissions API</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" href="/tests/SimpleTest/test.css">
 </head>
 
 <body>
   <pre id="test"></pre>
   <script type="application/javascript">
-  /*globals SpecialPowers, SimpleTest, is, ok, */
-  'use strict';
+  /* globals SpecialPowers, SimpleTest, is, ok, */
+  "use strict";
 
   const {
     UNKNOWN_ACTION,
     PROMPT_ACTION,
     ALLOW_ACTION,
     DENY_ACTION
   } = SpecialPowers.Ci.nsIPermissionManager;
 
   SimpleTest.waitForExplicitFinish();
 
   const PERMISSIONS = [{
-    name: 'geolocation',
-    type: 'geo'
+    name: "geolocation",
+    type: "geo"
   }, {
-    name: 'notifications',
-    type: 'desktop-notification'
+    name: "notifications",
+    type: "desktop-notification"
   }, {
-    name: 'push',
-    type: 'desktop-notification'
+    name: "push",
+    type: "desktop-notification"
   }, {
-    name: 'persistent-storage',
-    type: 'persistent-storage'
+    name: "persistent-storage",
+    type: "persistent-storage"
   }, ];
 
   const UNSUPPORTED_PERMISSIONS = [
-    'foobarbaz', // Not in spec, for testing only.
-    'midi',
+    "foobarbaz", // Not in spec, for testing only.
+    "midi",
   ];
 
   // Create a closure, so that tests are run on the correct window object.
   function createPermissionTester(aWindow) {
     return {
       setPermissions(allow) {
         const permissions = PERMISSIONS.map(({ type }) => {
           return {
             type,
             allow,
-            'context': aWindow.document
+            "context": aWindow.document
           };
         });
         return new Promise((resolve) => {
           SpecialPowers.popPermissions(() => {
             SpecialPowers.pushPermissions(permissions, resolve);
           });
         });
       },
       revokePermissions() {
-        const promisesToRevoke = PERMISSIONS.map(({ name })  => {
+        const promisesToRevoke = PERMISSIONS.map(({ name }) => {
           return aWindow.navigator.permissions
             .revoke({ name })
             .then(
-              ({ state }) => is(state, 'prompt', `correct state for '${name}'`),
+              ({ state }) => is(state, "prompt", `correct state for '${name}'`),
               () => ok(false, `revoke should not have rejected for '${name}'`)
             );
         });
         return Promise.all(promisesToRevoke);
       },
       revokeUnsupportedPermissions() {
         const promisesToRevoke = UNSUPPORTED_PERMISSIONS.map(({ name }) => {
           return aWindow.navigator.permissions
             .revoke({ name })
             .then(
               () => ok(false, `revoke should not have resolved for '${name}'`),
-              error => is(error.name, 'TypeError', `revoke should have thrown TypeError for '${name}'`)
+              error => is(error.name, "TypeError", `revoke should have thrown TypeError for '${name}'`)
             );
         });
         return Promise.all(promisesToRevoke);
       },
       checkPermissions(state) {
         const promisesToQuery = PERMISSIONS.map(({ name }) => {
           return aWindow.navigator.permissions
             .query({ name })
@@ -98,17 +98,17 @@
       },
       checkUnsupportedPermissions() {
         const promisesToQuery = UNSUPPORTED_PERMISSIONS.map(({ name }) => {
           return aWindow.navigator.permissions
             .query({ name })
             .then(
               () => ok(false, `query should not have resolved for '${name}'`),
               error => {
-                is(error.name, 'TypeError',
+                is(error.name, "TypeError",
                   `query should have thrown TypeError for '${name}'`);
               }
             );
           });
         return Promise.all(promisesToQuery);
       },
       promiseStateChanged(name, state) {
         return aWindow.navigator.permissions
@@ -122,85 +122,85 @@
               };
             });
           },
           () => ok(false, `query should not have rejected for '${name}'`));
       },
       testStatusOnChange() {
         return new Promise((resolve) => {
           SpecialPowers.popPermissions(() => {
-            const permission = 'geolocation';
-            const promiseGranted = this.promiseStateChanged(permission, 'granted');
+            const permission = "geolocation";
+            const promiseGranted = this.promiseStateChanged(permission, "granted");
             this.setPermissions(ALLOW_ACTION);
             promiseGranted.then(() => {
-              const promisePrompt = this.promiseStateChanged(permission, 'prompt');
+              const promisePrompt = this.promiseStateChanged(permission, "prompt");
               SpecialPowers.popPermissions();
               return promisePrompt;
             }).then(resolve);
           });
         });
       },
       testInvalidQuery() {
         return aWindow.navigator.permissions
-          .query({ name: 'invalid' })
+          .query({ name: "invalid" })
           .then(
-            () => ok(false, 'invalid query should not have resolved'),
-            () => ok(true, 'invalid query should have rejected')
+            () => ok(false, "invalid query should not have resolved"),
+            () => ok(true, "invalid query should have rejected")
           );
       },
       testInvalidRevoke() {
         return aWindow.navigator.permissions
-          .revoke({ name: 'invalid' })
+          .revoke({ name: "invalid" })
           .then(
-            () => ok(false, 'invalid revoke should not have resolved'),
-            () => ok(true, 'invalid revoke should have rejected')
+            () => ok(false, "invalid revoke should not have resolved"),
+            () => ok(true, "invalid revoke should have rejected")
           );
       },
     };
   }
 
   function enablePrefs() {
     const ops = {
-      'set': [
-        ['dom.permissions.revoke.enable', true],
-        ['privacy.firstparty.isolate', true],
+      "set": [
+        ["dom.permissions.revoke.enable", true],
+        ["privacy.firstparty.isolate", true],
       ],
     };
     return SpecialPowers.pushPrefEnv(ops);
   }
 
   function createIframe() {
     return new Promise((resolve) => {
-      const iframe = document.createElement('iframe');
-      iframe.src = 'file_empty.html';
+      const iframe = document.createElement("iframe");
+      iframe.src = "file_empty.html";
       iframe.onload = () => resolve(iframe.contentWindow);
       document.body.appendChild(iframe);
     });
   }
-  debugger;
+
   window.onload = () => {
     enablePrefs()
       .then(createIframe)
       .then(createPermissionTester)
       .then((tester) => {
         return tester
           .checkUnsupportedPermissions()
           .then(() => tester.setPermissions(UNKNOWN_ACTION))
-          .then(() => tester.checkPermissions('prompt'))
+          .then(() => tester.checkPermissions("prompt"))
           .then(() => tester.setPermissions(PROMPT_ACTION))
-          .then(() => tester.checkPermissions('prompt'))
+          .then(() => tester.checkPermissions("prompt"))
           .then(() => tester.setPermissions(ALLOW_ACTION))
-          .then(() => tester.checkPermissions('granted'))
+          .then(() => tester.checkPermissions("granted"))
           .then(() => tester.setPermissions(DENY_ACTION))
-          .then(() => tester.checkPermissions('denied'))
+          .then(() => tester.checkPermissions("denied"))
           .then(() => tester.testStatusOnChange())
           .then(() => tester.testInvalidQuery())
           .then(() => tester.revokeUnsupportedPermissions())
           .then(() => tester.revokePermissions())
-          .then(() => tester.checkPermissions('prompt'))
+          .then(() => tester.checkPermissions("prompt"))
           .then(() => tester.testInvalidRevoke());
       })
       .then(SimpleTest.finish)
       .catch((e) => {
         ok(false, `Unexpected error ${e}`);
         SimpleTest.finish();
       });
   };