Bug 1363795 - Enable some Mozilla ESLint recommended rules for dom/indexedDB/test - manual fixes. r=bevis
authorMark Banner <standard8@mozilla.com>
Wed, 10 May 2017 17:28:55 +0100
changeset 359171 de859ae644212accb6e706c2a8408df04f816573
parent 359170 ab9b62e22a5d35a99f9f25c9aefaa8e92fb8e1f6
child 359172 616b0a7c3e0f0957aa7f5a86574f4b7d69b6d0f9
push id31849
push userryanvm@gmail.com
push dateFri, 19 May 2017 15:38:10 +0000
treeherdermozilla-central@52b207e50972 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbevis
bugs1363795
milestone55.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 1363795 - Enable some Mozilla ESLint recommended rules for dom/indexedDB/test - manual fixes. r=bevis MozReview-Commit-ID: L79wR0OhqMz
dom/indexedDB/test/.eslintrc.js
dom/indexedDB/test/helpers.js
dom/indexedDB/test/leaving_page_iframe.html
dom/indexedDB/test/test_file_cross_database_copying.html
dom/indexedDB/test/test_file_put_deleted.html
dom/indexedDB/test/test_file_put_get_object.html
dom/indexedDB/test/test_filehandle_disabled_pref.html
dom/indexedDB/test/test_filehandle_lifetimes_nested.html
dom/indexedDB/test/test_filehandle_ordering.html
dom/indexedDB/test/test_filehandle_serialization.html
dom/indexedDB/test/test_filehandle_workers.html
--- a/dom/indexedDB/test/.eslintrc.js
+++ b/dom/indexedDB/test/.eslintrc.js
@@ -7,14 +7,11 @@ module.exports = {
     "plugin:mozilla/chrome-test",
     "plugin:mozilla/mochitest-test",
   ],
   "plugins": [
     "mozilla"
   ],
   "rules": {
     "brace-style": "off",
-    "consistent-return": "off",
-    "no-native-reassign": "off",
     "no-shadow": "off",
-    "no-unused-vars": "off",
   }
 };
--- a/dom/indexedDB/test/helpers.js
+++ b/dom/indexedDB/test/helpers.js
@@ -11,18 +11,20 @@ var testGenerator = testSteps();
 // and content mochitests (where the |Components| object is accessible only as
 // SpecialPowers.Components). Expose Components if necessary here to make things
 // work everywhere.
 //
 // Even if the real |Components| doesn't exist, we might shim in a simple JS
 // placebo for compat. An easy way to differentiate this from the real thing
 // is whether the property is read-only or not.
 var c = Object.getOwnPropertyDescriptor(this, "Components");
-if ((!c.value || c.writable) && typeof SpecialPowers === "object")
+if ((!c.value || c.writable) && typeof SpecialPowers === "object") {
+  // eslint-disable-next-line no-native-reassign
   Components = SpecialPowers.Components;
+}
 
 function executeSoon(aFun)
 {
   let comp = SpecialPowers.wrap(Components);
 
   let thread = comp.classes["@mozilla.org/thread-manager;1"]
                    .getService(comp.interfaces.nsIThreadManager)
                    .mainThread;
@@ -547,17 +549,17 @@ function workerScript() {
     self.postMessage({ op: "clearAllDatabases" });
   }
 
   self.onerror = function(_message_, _file_, _line_) {
     if (self._expectingUncaughtException) {
       self._expectingUncaughtException = false;
       ok(true, "Worker: expected exception [" + _file_ + ":" + _line_ + "]: '" +
          _message_ + "'");
-      return;
+      return false;
     }
     ok(false,
        "Worker: uncaught exception [" + _file_ + ":" + _line_ + "]: '" +
          _message_ + "'");
     self.finishTest();
     self.close();
     return true;
   };
--- a/dom/indexedDB/test/leaving_page_iframe.html
+++ b/dom/indexedDB/test/leaving_page_iframe.html
@@ -1,17 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <script>
 var db;
 function startDBWork() {
   indexedDB.open(parent.location, 1).onupgradeneeded = function(e) {
     db = e.target.result;
-    var trans = e.target.transaction;
     if (db.objectStoreNames.contains("mystore")) {
       db.deleteObjectStore("mystore");
     }
     var store = db.createObjectStore("mystore");
     store.add({ hello: "world" }, 42);
     e.target.onsuccess = madeMod;
   };
 }
--- a/dom/indexedDB/test/test_file_cross_database_copying.html
+++ b/dom/indexedDB/test/test_file_cross_database_copying.html
@@ -52,17 +52,17 @@
       databases.push(db);
     }
 
     let refResult;
     for (let db of databases) {
       let request = db.transaction([objectStoreName])
                       .objectStore(objectStoreName).get(fileData.key);
       request.onsuccess = grabEventAndContinueHandler;
-      event = yield undefined;
+      let event = yield undefined;
 
       let result = event.target.result;
       verifyBlob(result, fileData.file, 1);
       yield undefined;
 
       if (!refResult) {
         refResult = result;
         continue;
@@ -74,17 +74,17 @@
     for (let i = 1; i < databases.length; i++) {
       let db = databases[i];
 
       let objectStore = db.transaction([objectStoreName], READ_WRITE)
                           .objectStore(objectStoreName);
 
       let request = objectStore.add(refResult, 2);
       request.onsuccess = grabEventAndContinueHandler;
-      event = yield undefined;
+      let event = yield undefined;
 
       is(event.target.result, 2, "Got correct key");
 
       request = objectStore.get(2);
       request.onsuccess = grabEventAndContinueHandler;
       event = yield undefined;
 
       let result = event.target.result;
--- a/dom/indexedDB/test/test_file_put_deleted.html
+++ b/dom/indexedDB/test/test_file_put_deleted.html
@@ -66,17 +66,17 @@
     }
 
     // Get a reference to the file-backed File.
     let fileBackedFile;
     for (let db of databases.slice(0, 1)) {
       let request = db.transaction([objectStoreName])
                       .objectStore(objectStoreName).get(fileData.key);
       request.onsuccess = grabEventAndContinueHandler;
-      event = yield undefined;
+      let event = yield undefined;
 
       let result = event.target.result;
       verifyBlob(result, fileData.file, 1);
       yield undefined;
 
       fileBackedFile = result;
     }
 
@@ -113,19 +113,19 @@
 
       let request = objectStore.add(fileBackedFile, 2);
       request.onsuccess = unexpectedSuccessHandler;
       request.onerror = expectedErrorHandler("UnknownError");
       trans.onsuccess = unexpectedSuccessHandler;
       trans.onerror = expectedErrorHandler("UnknownError");
       // the database will also throw an error.
       db.onerror = expectedErrorHandler("UnknownError");
-      event = yield undefined;
-      event = yield undefined;
-      event = yield undefined;
+      yield undefined;
+      yield undefined;
+      yield undefined;
       // the database shouldn't throw any more errors now.
       db.onerror = errorHandler;
     }
 
     // Ensure there's nothing with that key in the target database.
     info("now that the transaction failed, make sure our put got rolled back");
     for (let i = 1; i < databases.length; i++) {
       let db = databases[i];
@@ -133,17 +133,17 @@
       let objectStore = db.transaction([objectStoreName], "readonly")
                           .objectStore(objectStoreName);
 
       // Attempt to fetch the key to verify there's nothing in the DB rather
       // than the value which could return undefined as a misleading error.
       let request = objectStore.getKey(2);
       request.onsuccess = grabEventAndContinueHandler;
       request.onerror = errorHandler;
-      event = yield undefined;
+      let event = yield undefined;
 
       let result = event.target.result;
       is(result, undefined, "no key found"); // (the get returns undefined)
     }
 
     finishTest();
   }
   </script>
--- a/dom/indexedDB/test/test_file_put_get_object.html
+++ b/dom/indexedDB/test/test_file_put_get_object.html
@@ -9,18 +9,16 @@
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 
   <script type="text/javascript">
   /* import-globals-from file.js */
   /* import-globals-from helpers.js */
   function* testSteps()
   {
-    const READ_WRITE = "readwrite";
-
     const name = window.location.pathname;
 
     const objectStoreName = "Blobs";
 
     const blob = getRandomBlob(1000);
     const file = getRandomFile("random.bin", 100000);
 
     const objectData1 = { key: 1, object: { foo: blob, bar: blob } };
--- a/dom/indexedDB/test/test_filehandle_disabled_pref.html
+++ b/dom/indexedDB/test/test_filehandle_disabled_pref.html
@@ -164,16 +164,17 @@
 
         info("getting mutable file");
 
         request = objectStore.get(mutableFileKey);
         request.onsuccess = grabEventAndContinueHandler;
         event = yield undefined;
 
         try {
+          // eslint-disable-next-line no-unused-vars
           let result = request.result;
           ok(false, "Should have thrown!");
         }
         catch (e) {
           ok(e instanceof DOMException, "Got exception.");
           is(e.name, "InvalidStateError", "Good error.");
           is(e.code, DOMException.INVALID_STATE_ERR, "Good error code.");
         }
--- a/dom/indexedDB/test/test_filehandle_lifetimes_nested.html
+++ b/dom/indexedDB/test/test_filehandle_lifetimes_nested.html
@@ -26,17 +26,17 @@
     request = db.createMutableFile("test.txt");
     request.onerror = errorHandler;
     request.onsuccess = grabEventAndContinueHandler;
     event = yield undefined;
 
     let mutableFile = event.target.result;
     mutableFile.onerror = errorHandler;
 
-    let fileHandle = mutableFile.open();
+    mutableFile.open();
 
     let fileHandle2;
 
     let comp = SpecialPowers.wrap(SpecialPowers.Components);
     let thread = comp.classes["@mozilla.org/thread-manager;1"]
                      .getService(comp.interfaces.nsIThreadManager)
                      .currentThread;
 
--- a/dom/indexedDB/test/test_filehandle_ordering.html
+++ b/dom/indexedDB/test/test_filehandle_ordering.html
@@ -29,18 +29,18 @@
     event = yield undefined;
 
     let mutableFile = event.target.result;
     mutableFile.onerror = errorHandler;
 
     let fileHandle1 = mutableFile.open("readwrite");
     let fileHandle2 = mutableFile.open("readwrite");
 
-    let request1 = fileHandle2.write("2");
-    let request2 = fileHandle1.write("1");
+    fileHandle2.write("2");
+    fileHandle1.write("1");
 
     fileHandle1.oncomplete = grabEventAndContinueHandler;
     fileHandle2.oncomplete = grabEventAndContinueHandler;
 
     yield undefined;
     yield undefined;
 
     let fileHandle3 = mutableFile.open("readonly");
--- a/dom/indexedDB/test/test_filehandle_serialization.html
+++ b/dom/indexedDB/test/test_filehandle_serialization.html
@@ -18,18 +18,16 @@
 
     const databaseInfo = [
       { name: window.location.pathname + "1" },
       { name: window.location.pathname + "2" }
     ];
 
     const objectStoreName = "Blobs";
 
-    const testFile = getRandomFile("random.bin", 100000);
-
     let databases = [];
     for (let info of databaseInfo) {
       let request = indexedDB.open(info.name, 1);
       request.onerror = errorHandler;
       request.onupgradeneeded = grabEventAndContinueHandler;
       request.onsuccess = grabEventAndContinueHandler;
       let event = yield undefined;
 
@@ -46,17 +44,17 @@
 
       databases.push(db);
     }
 
     let db1 = databases[0];
 
     let request = db1.createMutableFile("random.bin", "binary/random");
     request.onsuccess = grabEventAndContinueHandler;
-    event = yield undefined;
+    let event = yield undefined;
 
     let mutableFile = event.target.result;
     is(getFileId(mutableFile), 1, "Correct file id");
     is(mutableFile.name, "random.bin", "Correct name");
     is(mutableFile.type, "binary/random", "Correct type");
 
     let trans = db1.transaction([objectStoreName], READ_WRITE);
     let objectStore = trans.objectStore(objectStoreName);
--- a/dom/indexedDB/test/test_filehandle_workers.html
+++ b/dom/indexedDB/test/test_filehandle_workers.html
@@ -103,16 +103,17 @@
         var name = event.data;
         var request = indexedDB.open(name, 1);
         request.onsuccess = function(event) {
           var db = event.target.result;
           let objectStore = db.transaction("Foo").objectStore("Foo");
           request = objectStore.get(42);
           request.onsuccess = function(event) {
             try {
+              // eslint-disable-next-line no-unused-vars
               let result = request.result;
               postMessage("error");
             }
             catch (e) {
               postMessage("success");
             }
           }
           request.onerror = function(event) {