Bug 1508989 - Enable ESLint for dom/filesystem / (manual changes) r=Standard8
authorAdam Pucciano <aspucciano@myseneca.ca>
Wed, 05 Dec 2018 02:25:02 +0000
changeset 449369 bd4e540b0801acb2dddeaab2e7d63d7a14f0cbc5
parent 449368 3930f1e2fc9e26f09c9722a941cb77bb28956d0d
child 449370 2f48c5afbe570e3ce027c45b03fc88a6d0fe1312
push id74249
push usermbanner@mozilla.com
push dateWed, 05 Dec 2018 02:25:44 +0000
treeherderautoland@bd4e540b0801 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8
bugs1508989
milestone65.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 1508989 - Enable ESLint for dom/filesystem / (manual changes) r=Standard8 Differential Revision: https://phabricator.services.mozilla.com/D13632
dom/filesystem/compat/tests/.eslintrc.js
dom/filesystem/compat/tests/script_entries.js
dom/filesystem/compat/tests/test_basic.html
dom/filesystem/compat/tests/test_formSubmission.html
dom/filesystem/compat/tests/test_no_dnd.html
dom/filesystem/tests/script_fileList.js
dom/filesystem/tests/worker_basic.js
new file mode 100644
--- /dev/null
+++ b/dom/filesystem/compat/tests/.eslintrc.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = {
+  "extends": [
+    "plugin:mozilla/mochitest-test",
+  ]
+};
--- a/dom/filesystem/compat/tests/script_entries.js
+++ b/dom/filesystem/compat/tests/script_entries.js
@@ -1,24 +1,19 @@
+/* eslint-env mozilla/frame-script */
 Cu.importGlobalProperties(["File", "Directory"]);
-
+ChromeUtils.import("resource://gre/modules/Services.jsm");
 var tmpFile, tmpDir;
 
 addMessageListener("entries.open", function(e) {
-  tmpFile = Cc["@mozilla.org/file/directory_service;1"]
-              .getService(Ci.nsIDirectoryService)
-              .QueryInterface(Ci.nsIProperties)
-              .get("TmpD", Ci.nsIFile);
+  tmpFile = Services.dirsvc.QueryInterface(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
   tmpFile.append("file.txt");
   tmpFile.createUnique(Ci.nsIFile.FILE_TYPE, 0o600);
 
-  tmpDir = Cc["@mozilla.org/file/directory_service;1"]
-              .getService(Ci.nsIDirectoryService)
-              .QueryInterface(Ci.nsIProperties)
-              .get("TmpD", Ci.nsIFile);
+  tmpDir = Services.dirsvc.QueryInterface(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
 
   tmpDir.append("dir-test");
   tmpDir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0o700);
 
   var file1 = tmpDir.clone();
   file1.append("foo.txt");
   file1.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
 
--- a/dom/filesystem/compat/tests/test_basic.html
+++ b/dom/filesystem/compat/tests/test_basic.html
@@ -4,17 +4,16 @@
   <title>Test for Blink FileSystem API - subset</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 
 <body>
 <input id="entries" type="file"></input>
 <script type="application/javascript">
-
 var fileEntry;
 var directoryEntry;
 var script;
 
 function setup_tests() {
   SpecialPowers.pushPrefEnv({"set": [["dom.webkitBlink.dirPicker.enabled", true],
                                      ["dom.filesystem.pathcheck.disabled", true],
                                      ["dom.webkitBlink.filesystem.enabled", true]]}, next);
@@ -98,19 +97,19 @@ function test_directoryEntry_createReade
     is(a.length, 2, "reader.readyEntries returns 2 elements.");
 
     for (var i = 0; i < 2; ++i) {
       ok(a[i].name == "subdir" || a[i].name == "foo.txt", "Correct names");
       is(a[i].fullPath, directoryEntry.fullPath + "/" + a[i].name, "FullPath is correct");
     }
 
     // Called twice:
-    reader.readEntries(function(a) {
-      ok(Array.isArray(a), "We want an array.");
-      is(a.length, 0, "reader.readyEntries returns 0 elements.");
+    reader.readEntries(function(a1) {
+      ok(Array.isArray(a1), "We want an array.");
+      is(a1.length, 0, "reader.readyEntries returns 0 elements.");
       next();
     }, function() {
       ok(false, "Something when wrong!");
     });
 
   }, function() {
     ok(false, "Something when wrong!");
   });
@@ -250,17 +249,17 @@ function test_filesystem() {
 
   var fs = fileEntry.filesystem;
   ok(fs.name, "FileSystem.name exists.");
   ok(fs.root, "FileSystem has a root.");
 
   is(fs.root.name, "", "FileSystem.root.name must be an empty string.");
   is(fs.root.fullPath, "/", "FileSystem.root.fullPath must be '/'");
 
-  reader = fs.root.createReader();
+  var reader = fs.root.createReader();
   reader.readEntries(function(a) {
     ok(Array.isArray(a), "We want an array.");
     is(a.length, 2, "reader.readyEntries returns 2 elements.");
     next();
   }, function() {
     ok(false, "Something when wrong!");
   });
 }
--- a/dom/filesystem/compat/tests/test_formSubmission.html
+++ b/dom/filesystem/compat/tests/test_formSubmission.html
@@ -10,17 +10,16 @@
 
 <iframe name="target_iframe" id="target_iframe"></iframe>
 
 <form action="../../../html/test/form_submit_server.sjs" target="target_iframe" id="form"
       method="POST" enctype="multipart/form-data">
 </form>
 
 <script class="testbody" type="text/javascript">
-
 var form;
 var iframe;
 var input;
 var script;
 var xhr;
 
 function setup_tests() {
   form = document.getElementById("form");
--- a/dom/filesystem/compat/tests/test_no_dnd.html
+++ b/dom/filesystem/compat/tests/test_no_dnd.html
@@ -3,17 +3,16 @@
 <head>
   <title>Test for Blink FileSystem API - no DND == no webkitEntries</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 
 <body>
 <script type="application/javascript">
-
 var fileEntry;
 var directoryEntry;
 var script;
 var entries;
 
 function setup_tests() {
   SpecialPowers.pushPrefEnv({"set": [["dom.webkitBlink.dirPicker.enabled", true],
                                      ["dom.filesystem.pathcheck.disabled", true],
--- a/dom/filesystem/tests/script_fileList.js
+++ b/dom/filesystem/tests/script_fileList.js
@@ -1,15 +1,13 @@
+/* eslint-env mozilla/frame-script */
 Cu.importGlobalProperties(["File"]);
-
+ChromeUtils.import("resource://gre/modules/Services.jsm");
 function createProfDFile() {
-  return Cc["@mozilla.org/file/directory_service;1"]
-           .getService(Ci.nsIDirectoryService)
-           .QueryInterface(Ci.nsIProperties)
-           .get("ProfD", Ci.nsIFile);
+  return Services.dirsvc.QueryInterface(Ci.nsIProperties).get("ProfD", Ci.nsIFile);
 }
 
 // Creates a parametric arity directory hierarchy as a function of depth.
 // Each directory contains one leaf file, and subdirectories of depth [1, depth).
 // e.g. for depth 3:
 //
 // subdir3
 // - file.txt
@@ -18,33 +16,30 @@ function createProfDFile() {
 //   - subdir1
 //     - file.txt
 // - subdir1
 //   - file.txt
 //
 // Returns the parent directory of the subtree.
 function createTreeFile(depth, parent) {
   if (!parent) {
-    parent = Cc["@mozilla.org/file/directory_service;1"]
-                .getService(Ci.nsIDirectoryService)
-                .QueryInterface(Ci.nsIProperties)
-                .get("TmpD", Ci.nsIFile);
+    parent = Services.dirsvc.QueryInterface(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
     parent.append("dir-tree-test");
     parent.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0o700);
   }
 
   var nextFile = parent.clone();
   if (depth == 0) {
     nextFile.append("file.txt");
     nextFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
   } else {
     nextFile.append("subdir" + depth);
     nextFile.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0o700);
     // Decrement the maximal depth by one for each level of nesting.
-    for (i = 0; i < depth; i++) {
+    for (var i = 0; i < depth; i++) {
       createTreeFile(i, nextFile);
     }
   }
 
   return parent;
 }
 
 function createRootFile() {
@@ -59,20 +54,17 @@ function createRootFile() {
 
     testFile = parent;
   }
 
   return testFile;
 }
 
 function createTestFile() {
-  var tmpFile = Cc["@mozilla.org/file/directory_service;1"]
-                  .getService(Ci.nsIDirectoryService)
-                  .QueryInterface(Ci.nsIProperties)
-                  .get("TmpD", Ci.nsIFile);
+  var tmpFile = Services.dirsvc.QueryInterface(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
   tmpFile.append("dir-test");
   tmpFile.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0o700);
 
   var file1 = tmpFile.clone();
   file1.append("foo.txt");
   file1.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
 
   var dir = tmpFile.clone();
@@ -111,18 +103,15 @@ addMessageListener("dir.open", function(
 
   sendAsyncMessage("dir.opened", {
     dir: testFile.path,
     name: testFile.leafName,
   });
 });
 
 addMessageListener("file.open", function(e) {
-  var testFile = Cc["@mozilla.org/file/directory_service;1"]
-                   .getService(Ci.nsIDirectoryService)
-                   .QueryInterface(Ci.nsIProperties)
-                   .get("ProfD", Ci.nsIFile);
+  var testFile = Services.dirsvc.QueryInterface(Ci.nsIProperties).get("ProfD", Ci.nsIFile);
   testFile.append("prefs.js");
 
   File.createFromNsIFile(testFile).then(function(file) {
     sendAsyncMessage("file.opened", { file });
   });
 });
--- a/dom/filesystem/tests/worker_basic.js
+++ b/dom/filesystem/tests/worker_basic.js
@@ -1,8 +1,9 @@
+/* eslint-env worker */
 importScripts("filesystem_commons.js");
 
 function finish() {
   postMessage({ type: "finish" });
 }
 
 function ok(a, msg) {
   postMessage({ type: "test", test: !!a, message: msg });