Backed out changeset 856215476aa4 (bug 1386666) for eslint failures a=backout
authorWes Kocher <wkocher@mozilla.com>
Wed, 02 Aug 2017 11:47:42 -0700
changeset 424451 0e4a8e3983e42b0ef9fb2be2d825582f512026c9
parent 424450 47709bd65292f421d98962293f695d6866e65035
child 424452 26ce8836a4c88c94c68db5f42bb6d914980a1427
push id1567
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 12:36:05 +0000
treeherdermozilla-release@e512c14a0406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1386666
milestone56.0a1
backs out856215476aa45721d2b333e65666b3f2b21f0184
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
Backed out changeset 856215476aa4 (bug 1386666) for eslint failures a=backout MozReview-Commit-ID: FdO8WkzBvfj
.eslintignore
toolkit/components/osfile/.eslintrc.js
toolkit/components/osfile/modules/osfile_shared_front.jsm
toolkit/components/osfile/tests/mochi/main_test_osfile_async.js
toolkit/components/osfile/tests/mochi/worker_test_osfile_unix.js
toolkit/components/osfile/tests/mochi/worker_test_osfile_win.js
toolkit/components/osfile/tests/xpcshell/.eslintrc.js
toolkit/components/osfile/tests/xpcshell/head.js
toolkit/components/osfile/tests/xpcshell/test_exception.js
toolkit/components/osfile/tests/xpcshell/test_open.js
toolkit/components/osfile/tests/xpcshell/test_osfile_async_append.js
toolkit/components/osfile/tests/xpcshell/test_osfile_async_copy.js
toolkit/components/osfile/tests/xpcshell/test_osfile_async_largefiles.js
toolkit/components/osfile/tests/xpcshell/test_read_write.js
toolkit/components/osfile/tests/xpcshell/test_reset.js
toolkit/components/osfile/tests/xpcshell/test_shutdown.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -334,28 +334,28 @@ toolkit/components/help/**
 
 # Intentionally invalid JS
 toolkit/components/workerloader/tests/moduleF-syntax-error.js
 
 # Tests old non-star function generators
 toolkit/modules/tests/xpcshell/test_task.js
 
 # Not yet updated
+toolkit/components/osfile/**
 toolkit/components/url-classifier/**
 
 # External code:
 toolkit/components/microformats/test/**
 toolkit/components/microformats/microformat-shiv.js
 toolkit/components/reader/Readability.js
 toolkit/components/reader/JSDOMParser.js
 
 # Uses preprocessing
 toolkit/content/widgets/wizard.xml
 toolkit/components/jsdownloads/src/DownloadIntegration.jsm
-toolkit/components/osfile/osfile.jsm
 toolkit/components/urlformatter/nsURLFormatter.js
 toolkit/modules/AppConstants.jsm
 toolkit/mozapps/downloads/nsHelperAppDlg.js
 toolkit/mozapps/update/tests/data/xpcshellConstantsPP.js
 
 # Third party
 toolkit/modules/third_party/**
 third_party/**
deleted file mode 100644
--- a/toolkit/components/osfile/.eslintrc.js
+++ /dev/null
@@ -1,32 +0,0 @@
-"use strict";
-
-module.exports = {
-  "rules": {
-    "brace-style": "off",
-    "comma-spacing": "off",
-    "consistent-return": "off",
-    "eol-last": "off",
-    "func-call-spacing": "off",
-    "key-spacing": "off",
-    "keyword-spacing": "off",
-    "no-else-return": "off",
-    "no-extra-semi": "off",
-    "no-irregular-whitespace": "off",
-    "no-lone-blocks": "off",
-    "no-lonely-if": "off",
-    "no-multi-spaces": "off",
-    "no-redeclare": "off",
-    "no-self-assign": "off",
-    "no-shadow": "off",
-    "no-trailing-spaces": "off",
-    "no-undef": "off",
-    "no-unsafe-negation": "off",
-    "no-unused-vars": "off",
-    "no-useless-return": "off",
-    "object-shorthand": "off",
-    "quotes": "off",
-    "space-before-function-paren": "off",
-    "space-infix-ops": "off",
-    "spaced-comment": "off",
-  }
-};
--- a/toolkit/components/osfile/modules/osfile_shared_front.jsm
+++ b/toolkit/components/osfile/modules/osfile_shared_front.jsm
@@ -147,40 +147,34 @@ AbstractFile.openUnique = function openU
   // We produce HEX numbers between 0 and 2^24 - 1.
   const MAX_HEX_NUMBER = 16777215;
 
   try {
     return {
       path: path,
       file: OS.File.open(path, mode)
     };
-  } catch (ex) {
-    if (ex instanceof OS.File.Error && ex.becauseExists) {
-      for (let i = 0; i < maxAttempts; ++i) {
-        try {
-          if (humanReadable) {
-            uniquePath = Path.join(dirName, fileName + "-" + (i + 1) + suffix);
-          } else {
-            let hexNumber = Math.floor(Math.random() * MAX_HEX_NUMBER).toString(HEX_RADIX);
-            uniquePath = Path.join(dirName, fileName + "-" + hexNumber + suffix);
-          }
-          return {
-            path: uniquePath,
-            file: OS.File.open(uniquePath, mode)
-          };
-        } catch (ex) {
-          if (ex instanceof OS.File.Error && ex.becauseExists) {
-            // keep trying ...
-          } else {
-            throw ex;
-          }
+  } catch (ex if ex instanceof OS.File.Error && ex.becauseExists) {
+    for (let i = 0; i < maxAttempts; ++i) {
+      try {
+        if (humanReadable) {
+          uniquePath = Path.join(dirName, fileName + "-" + (i + 1) + suffix);
+        } else {
+          let hexNumber = Math.floor(Math.random() * MAX_HEX_NUMBER).toString(HEX_RADIX);
+          uniquePath = Path.join(dirName, fileName + "-" + hexNumber + suffix);
         }
+        return {
+          path: uniquePath,
+          file: OS.File.open(uniquePath, mode)
+        };
+      } catch (ex if ex instanceof OS.File.Error && ex.becauseExists) {
+        // keep trying ...
       }
-      throw OS.File.Error.exists("could not find an unused file name.", path);
     }
+    throw OS.File.Error.exists("could not find an unused file name.", path);
   }
 };
 
 /**
  * Code shared by iterators.
  */
 AbstractFile.AbstractIterator = function AbstractIterator() {
 };
@@ -340,22 +334,18 @@ AbstractFile.read = function read(path, 
       }
     }
     if (!("encoding" in options)) {
       return buffer;
     }
     let decoder;
     try {
       decoder = new TextDecoder(options.encoding);
-    } catch (ex) {
-      if (ex instanceof RangeError) {
-        throw OS.File.Error.invalidArgument("Decode");
-      } else {
-        throw ex;
-      }
+    } catch (ex if ex instanceof RangeError) {
+      throw OS.File.Error.invalidArgument("Decode");
     }
     return decoder.decode(buffer);
   } finally {
     file.close();
   }
 };
 
 /**
@@ -430,22 +420,18 @@ AbstractFile.writeAtomic =
   }
 
   let bytesWritten = 0;
 
   if (!options.tmpPath) {
     if (options.backupTo) {
       try {
         OS.File.move(path, options.backupTo, {noCopy: true});
-      } catch (ex) {
-        if (ex.becauseNoSuchFile) {
-          // The file doesn't exist, nothing to backup.
-        } else {
-          throw ex;
-        }
+      } catch (ex if ex.becauseNoSuchFile) {
+        // The file doesn't exist, nothing to backup.
       }
     }
     // Just write, without any renaming trick
     let dest = OS.File.open(path, {write: true, truncate: true});
     try {
       bytesWritten = dest.write(buffer, options);
       if (options.flush) {
         dest.flush();
@@ -467,22 +453,18 @@ AbstractFile.writeAtomic =
     throw x;
   } finally {
     tmpFile.close();
   }
 
   if (options.backupTo) {
     try {
       OS.File.move(path, options.backupTo, {noCopy: true});
-    } catch (ex) {
-     if (ex.becauseNoSuchFile) {
-        // The file doesn't exist, nothing to backup.
-      } else {
-        throw ex;
-      }
+    } catch (ex if ex.becauseNoSuchFile) {
+      // The file doesn't exist, nothing to backup.
     }
   }
 
   OS.File.move(options.tmpPath, path, {noCopy: true});
   return bytesWritten;
 };
 
 /**
--- a/toolkit/components/osfile/tests/mochi/main_test_osfile_async.js
+++ b/toolkit/components/osfile/tests/mochi/main_test_osfile_async.js
@@ -339,24 +339,20 @@ var test_iter = maketest("iter", functio
     try {
       iterator = null;
       iterator = new OS.File.DirectoryIterator("/I do not exist");
       let exists = await iterator.exists();
       test.ok(!exists, "Before any iteration, iterator detects that the directory doesn't exist");
       let exn = null;
       try {
         await iterator.next();
-      } catch (ex) {
-        if (ex instanceof OS.File.Error && ex.becauseNoSuchFile) {
-          exn = ex;
-          let exists = await iterator.exists();
-          test.ok(!exists, "After one iteration, iterator detects that the directory doesn't exist");
-        } else {
-          throw ex;
-        }
+      } catch (ex if ex instanceof OS.File.Error && ex.becauseNoSuchFile) {
+        exn = ex;
+        let exists = await iterator.exists();
+        test.ok(!exists, "After one iteration, iterator detects that the directory doesn't exist");
       }
       test.ok(exn, "Iterating through a directory that does not exist has failed with becauseNoSuchFile");
     } finally {
       if (iterator) {
         iterator.close();
       }
     }
     test.ok(!!iterator, "The directory iterator for a non-existing directory was correctly created");
@@ -419,8 +415,10 @@ var test_debug_test = maketest("debug_te
       }
     };
     toggleDebugTest(true, consoleListener);
     // Execution of OS.File.exist method will trigger OS.File.LOG several times.
     let fileExists = await OS.File.exists(EXISTING_FILE);
     toggleDebugTest(false, consoleListener);
   })();
 });
+
+
--- a/toolkit/components/osfile/tests/mochi/worker_test_osfile_unix.js
+++ b/toolkit/components/osfile/tests/mochi/worker_test_osfile_unix.js
@@ -187,18 +187,15 @@ function test_passing_undefined()
   info("Testing that an exception gets thrown when an FFI function is passed undefined");
   let exceptionRaised = false;
 
   try {
     let file = OS.Unix.File.open(undefined, OS.Constants.libc.O_RDWR
                                             | OS.Constants.libc.O_CREAT
                                             | OS.Constants.libc.O_TRUNC,
                                             OS.Constants.libc.S_IRWXU);
-  } catch(e) {
-    if (e instanceof TypeError && e.message.indexOf("open") > -1) {
-      exceptionRaised = true;
-    } else {
-      throw e;
-    }
+  } catch(e if e instanceof TypeError && e.message.indexOf("open") > -1) {
+    exceptionRaised = true;
   }
 
   ok(exceptionRaised, "test_passing_undefined: exception gets thrown")
 }
+
--- a/toolkit/components/osfile/tests/mochi/worker_test_osfile_win.js
+++ b/toolkit/components/osfile/tests/mochi/worker_test_osfile_win.js
@@ -198,18 +198,14 @@ function test_passing_undefined()
     let file = OS.Win.File.CreateFile(
       undefined,
       OS.Constants.Win.GENERIC_READ,
       0,
       null,
       OS.Constants.Win.OPEN_EXISTING,
       0,
       null);
-  } catch(e) {
-    if (e instanceof TypeError && e.message.indexOf("CreateFile") > -1) {
-      exceptionRaised = true;
-    } else {
-      throw e;
-    }
+  } catch(e if e instanceof TypeError && e.message.indexOf("CreateFile") > -1) {
+    exceptionRaised = true;
   }
 
   ok(exceptionRaised, "test_passing_undefined: exception gets thrown")
 }
--- a/toolkit/components/osfile/tests/xpcshell/.eslintrc.js
+++ b/toolkit/components/osfile/tests/xpcshell/.eslintrc.js
@@ -1,11 +1,7 @@
 "use strict";
 
 module.exports = {
   "extends": [
     "plugin:mozilla/xpcshell-test"
-  ],
-
-  "rules": {
-    "no-shadow": "off",
-  }
+  ]
 };
--- a/toolkit/components/osfile/tests/xpcshell/head.js
+++ b/toolkit/components/osfile/tests/xpcshell/head.js
@@ -90,18 +90,8 @@ function reference_fetch_file(path, test
 function reference_compare_files(a, b, test) {
   return (async function() {
     do_print("Comparing files " + a + " and " + b);
     let a_contents = await reference_fetch_file(a, test);
     let b_contents = await reference_fetch_file(b, test);
     do_check_eq(a_contents, b_contents);
   })();
 };
-
-async function removeTestFile(filePath, ignoreNoSuchFile = true) {
-  try {
-    await OS.File.remove(filePath);
-  } catch (ex) {
-    if (!ignoreNoSuchFile || !ex.becauseNoSuchFile) {
-      do_throw(ex);
-    }
-  }
-}
--- a/toolkit/components/osfile/tests/xpcshell/test_exception.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_exception.js
@@ -26,88 +26,64 @@ add_test_pair(async function test_typeer
 
 // Tests on |read|
 
 add_test_pair(async function test_bad_encoding() {
   do_print("Testing with a wrong encoding");
   try {
     await OS.File.read(EXISTING_FILE, { encoding: "baby-speak-encoded" });
     do_throw("Should have thrown with an ex.becauseInvalidArgument");
-  } catch (ex) {
-    if (ex.becauseInvalidArgument) {
-      do_print("Wrong encoding caused the correct exception");
-    } else {
-      throw ex;
-    }
+  } catch (ex if ex.becauseInvalidArgument) {
+    do_print("Wrong encoding caused the correct exception");
   }
 
   try {
     await OS.File.read(EXISTING_FILE, { encoding: 4 });
     do_throw("Should have thrown a TypeError");
-  } catch (ex) {
-    if (ex.constructor.name == "TypeError") {
-      // Note that TypeError doesn't carry across compartments
-      do_print("Non-string encoding caused the correct exception");
-    } else {
-      throw ex;
-    }
+  } catch (ex if ex.constructor.name == "TypeError") {
+    // Note that TypeError doesn't carry across compartments
+    do_print("Non-string encoding caused the correct exception");
   }
-});
+ });
 
 add_test_pair(async function test_bad_compression() {
   do_print("Testing with a non-existing compression");
   try {
     await OS.File.read(EXISTING_FILE, { compression: "mmmh-crunchy" });
     do_throw("Should have thrown with an ex.becauseInvalidArgument");
-  } catch (ex) {
-    if (ex.becauseInvalidArgument) {
-      do_print("Wrong encoding caused the correct exception");
-    } else {
-      throw ex;
-    }
+  } catch (ex if ex.becauseInvalidArgument) {
+    do_print("Wrong encoding caused the correct exception");
   }
 
   do_print("Testing with a bad type for option compression");
   try {
     await OS.File.read(EXISTING_FILE, { compression: 5 });
     do_throw("Should have thrown a TypeError");
-  } catch (ex) {
-    if (ex.constructor.name == "TypeError") {
-      // Note that TypeError doesn't carry across compartments
-      do_print("Non-string encoding caused the correct exception");
-    } else {
-      throw ex;
-    }
+  } catch (ex if ex.constructor.name == "TypeError") {
+    // Note that TypeError doesn't carry across compartments
+    do_print("Non-string encoding caused the correct exception");
   }
 });
 
 add_test_pair(async function test_bad_bytes() {
   do_print("Testing with a bad type for option bytes");
   try {
     await OS.File.read(EXISTING_FILE, { bytes: "five" });
     do_throw("Should have thrown a TypeError");
-  } catch (ex) {
-    if (ex.constructor.name == "TypeError") {
-      // Note that TypeError doesn't carry across compartments
-      do_print("Non-number bytes caused the correct exception");
-    } else {
-      throw ex;
-    }
+  } catch (ex if ex.constructor.name == "TypeError") {
+    // Note that TypeError doesn't carry across compartments
+    do_print("Non-number bytes caused the correct exception");
   }
 });
 
 add_test_pair(async function read_non_existent() {
   do_print("Testing with a non-existent file");
   try {
     await OS.File.read("I/do/not/exist");
     do_throw("Should have thrown with an ex.becauseNoSuchFile");
-  } catch (ex) {
-    if (ex.becauseNoSuchFile) {
-      do_print("Correct exceptions");
-    } else {
-      throw ex;
-    }
+  } catch (ex if ex.becauseNoSuchFile) {
+    do_print("Correct exceptions");
   }
 });
 
 function run_test() {
   run_next_test();
 }
--- a/toolkit/components/osfile/tests/xpcshell/test_open.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_open.js
@@ -14,25 +14,22 @@ function run_test() {
  * - with an existing file (should succeed);
  * - with a non-existing file (should fail);
  * - with inconsistent arguments (should fail).
  */
 add_task(async function() {
   // Attempt to open a file that does not exist, ensure that it yields the
   // appropriate error.
   try {
-    await OS.File.open(OS.Path.join(".", "This file does not exist"));
+    let fd = await OS.File.open(OS.Path.join(".", "This file does not exist"));
     do_check_true(false, "File opening 1 succeeded (it should fail)");
-  } catch (err) {
-    if (err instanceof OS.File.Error && err.becauseNoSuchFile) {
-      do_print("File opening 1 failed " + err);
-    } else {
-      throw err;
-    }
+  } catch (err if err instanceof OS.File.Error && err.becauseNoSuchFile) {
+    do_print("File opening 1 failed " + err);
   }
+
   // Attempt to open a file with the wrong args, so that it fails before
   // serialization, ensure that it yields the appropriate error.
   do_print("Attempting to open a file with wrong arguments");
   try {
     let fd = await OS.File.open(1, 2, 3);
     do_check_true(false, "File opening 2 succeeded (it should fail)" + fd);
   } catch (err) {
     do_print("File opening 2 failed " + err);
--- a/toolkit/components/osfile/tests/xpcshell/test_osfile_async_append.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_osfile_async_append.js
@@ -22,17 +22,21 @@ function setup_mode(mode) {
 }
 
 // Test append mode.
 async function test_append(mode) {
   let path = OS.Path.join(OS.Constants.Path.tmpDir,
                           "test_osfile_async_append.tmp");
 
   // Clear any left-over files from previous runs.
-  await removeTestFile(path)
+  try {
+    await OS.File.remove(path);
+  } catch (ex if ex.becauseNoSuchFile) {
+    // ignore
+  }
 
   try {
     mode = setup_mode(mode);
     mode.append = true;
     if (mode.trunc) {
       // Pre-fill file with some data to see if |trunc| actually works.
       await OS.File.writeAtomic(path, new Uint8Array(500));
     }
@@ -44,28 +48,36 @@ async function test_append(mode) {
       // Should be at offset 100, length 1000 now.
       await file.write(new Uint8Array(100));
       // Should be at offset 1100, length 1100 now.
       let stat = await file.stat();
       do_check_eq(1100, stat.size);
     } finally {
       await file.close();
     }
-  } catch (ex) {
-    await removeTestFile(path)
+  } catch(ex) {
+    try {
+      await OS.File.remove(path);
+    } catch (ex if ex.becauseNoSuchFile) {
+      // ignore.
+    }
   }
 }
 
 // Test no-append mode.
 async function test_no_append(mode) {
   let path = OS.Path.join(OS.Constants.Path.tmpDir,
                           "test_osfile_async_noappend.tmp");
 
   // Clear any left-over files from previous runs.
-  await removeTestFile(path)
+  try {
+    await OS.File.remove(path);
+  } catch (ex if ex.becauseNoSuchFile) {
+    // ignore
+  }
 
   try {
     mode = setup_mode(mode);
     mode.append = false;
     if (mode.trunc) {
       // Pre-fill file with some data to see if |trunc| actually works.
       await OS.File.writeAtomic(path, new Uint8Array(500));
     }
@@ -78,24 +90,28 @@ async function test_no_append(mode) {
       await file.write(new Uint8Array(100));
       // Should be at offset 200, length 1000 now.
       let stat = await file.stat();
       do_check_eq(1000, stat.size);
     } finally {
       await file.close();
     }
   } finally {
-    await removeTestFile(path)
+    try {
+      await OS.File.remove(path);
+    } catch (ex if ex.becauseNoSuchFile) {
+      // ignore.
+    }
   }
 }
 
 var test_flags = [
   {},
-  {create: true},
-  {trunc: true}
+  {create:true},
+  {trunc:true}
 ];
 function run_test() {
   do_test_pending();
 
   for (let t of test_flags) {
     add_task(test_append.bind(null, t));
     add_task(test_no_append.bind(null, t));
   }
--- a/toolkit/components/osfile/tests/xpcshell/test_osfile_async_copy.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_osfile_async_copy.js
@@ -85,18 +85,26 @@ async function test_copymove(options = {
     await OS.File.copy(source, dest, options);
     await reference_compare_files(source, dest);
     // 2. Test subsequent move.
     await OS.File.move(dest, dest2);
     await reference_compare_files(source, dest2);
     // 3. Check that the moved file was really moved.
     do_check_eq((await OS.File.exists(dest)), false);
   } finally {
-    await removeTestFile(dest);
-    await removeTestFile(dest2);
+    try {
+      await OS.File.remove(dest);
+    } catch (ex if ex.becauseNoSuchFile) {
+      // ignore
+    }
+    try {
+      await OS.File.remove(dest2);
+    } catch (ex if ex.becauseNoSuchFile) {
+      // ignore
+    }
   }
 }
 
 // Regular copy test.
 add_task(test_copymove);
 // Userland copy test.
 add_task(test_copymove.bind(null, {unixUserland: true}));
 
--- a/toolkit/components/osfile/tests/xpcshell/test_osfile_async_largefiles.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_osfile_async_largefiles.js
@@ -12,17 +12,21 @@ Components.utils.import("resource://gre/
  */
 
 // Test setPosition/getPosition.
 async function test_setPosition(forward, current, backward) {
   let path = OS.Path.join(OS.Constants.Path.tmpDir,
                           "test_osfile_async_largefiles.tmp");
 
   // Clear any left-over files from previous runs.
-  await removeTestFile(path);
+  try {
+    await OS.File.remove(path);
+  } catch (ex if ex.becauseNoSuchFile) {
+    // ignore
+  }
 
   try {
     let file = await OS.File.open(path, {write:true, append:false});
     try {
       let pos = 0;
 
       // 1. seek forward from start
       do_print("Moving forward: " + forward);
@@ -42,27 +46,36 @@ async function test_setPosition(forward,
       pos -= backward;
       do_check_eq((await file.getPosition()), pos);
 
     } finally {
       await file.setPosition(0, OS.File.POS_START);
       await file.close();
     }
   } catch(ex) {
-    await removeTestFile(path);
+    try {
+      await OS.File.remove(path);
+    } catch (ex if ex.becauseNoSuchFile) {
+      // ignore.
+    }
+    do_throw(ex);
   }
 }
 
 // Test setPosition/getPosition expected failures.
 async function test_setPosition_failures() {
   let path = OS.Path.join(OS.Constants.Path.tmpDir,
                           "test_osfile_async_largefiles.tmp");
 
   // Clear any left-over files from previous runs.
-  await removeTestFile(path);
+  try {
+    await OS.File.remove(path);
+  } catch (ex if ex.becauseNoSuchFile) {
+    // ignore
+  }
 
   try {
     let file = await OS.File.open(path, {write:true, append:false});
     try {
       let pos = 0;
 
       // 1. Use an invalid position value
       try {
@@ -96,17 +109,21 @@ async function test_setPosition_failures
       } catch (ex) {
         do_print(ex.toString());
         do_check_true(!!ex);
       }
 
     } finally {
       await file.setPosition(0, OS.File.POS_START);
       await file.close();
-      await removeTestFile(path);
+      try {
+        await OS.File.remove(path);
+      } catch (ex if ex.becauseNoSuchFile) {
+        // ignore.
+      }
     }
   } catch(ex) {
     do_throw(ex);
   }
 }
 
 function run_test() {
   // First verify stuff works for small values.
--- a/toolkit/components/osfile/tests/xpcshell/test_read_write.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_read_write.js
@@ -57,22 +57,18 @@ add_test_pair(async function read_write_
       // file already exists!
       contents = new Uint8Array(300);
       let view = new Uint8Array(contents.buffer, 10, 200);
       try {
         let opt = JSON.parse(JSON.stringify(options));
         opt.noOverwrite = true;
         await OS.File.writeAtomic(DEST_PATH, view, opt);
         do_throw("With noOverwrite, writeAtomic should have refused to overwrite file (" + suffix + ")");
-      } catch (err) {
-        if (err instanceof OS.File.Error && err.becauseExists) {
-          do_print("With noOverwrite, writeAtomic correctly failed (" + suffix + ")");
-        } else {
-          throw err;
-        }
+      } catch (err if err instanceof OS.File.Error && err.becauseExists) {
+        do_print("With noOverwrite, writeAtomic correctly failed (" + suffix + ")");
       }
       await reference_compare_files(pathSource, DEST_PATH, TEST);
 
       // Check that temporary file was removed or never created
       do_check_false(new FileUtils.File(TMP_PATH).exists());
 
       // Now write a subset
       let START = 10;
@@ -88,17 +84,17 @@ add_test_pair(async function read_write_
       do_check_eq(LENGTH, array2.length);
       for (var i = 0; i < LENGTH; i++)
         do_check_eq(array2[i], (i + START) % 256);
 
       // Cleanup.
       await OS.File.remove(DEST_PATH);
       await OS.File.remove(TMP_PATH);
     })();
-  }
+  };
 
   await test_with_options({tmpPath: TMP_PATH}, "Renaming, not flushing");
   await test_with_options({tmpPath: TMP_PATH, flush: true}, "Renaming, flushing");
   await test_with_options({}, "Not renaming, not flushing");
   await test_with_options({flush: true}, "Not renaming, flushing");
 });
 
 
--- a/toolkit/components/osfile/tests/xpcshell/test_reset.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_reset.js
@@ -30,43 +30,35 @@ add_task(async function transparent_rese
 
 add_task(async function file_open_cannot_reset() {
   let TEST_FILE = OS.Path.join(Path.profileDir, "tmp-" + Math.random());
   do_print("Leaking file descriptor " + TEST_FILE + ", we shouldn't be able to reset");
   let openedFile = await OS.File.open(TEST_FILE, { create: true} );
   let thrown = false;
   try {
     await OS.File.resetWorker();
-  } catch (ex) {
-    if (ex.message.indexOf(OS.Path.basename(TEST_FILE)) != -1 ) {
-      thrown = true;
-    } else {
-      throw ex;
-    }
+  } catch (ex if ex.message.indexOf(OS.Path.basename(TEST_FILE)) != -1 ) {
+    thrown = true;
   }
   do_check_true(thrown);
 
   do_print("Closing the file, we should now be able to reset");
   await openedFile.close();
   await OS.File.resetWorker();
 });
 
 add_task(async function dir_open_cannot_reset() {
   let TEST_DIR = await OS.File.getCurrentDirectory();
   do_print("Leaking directory " + TEST_DIR + ", we shouldn't be able to reset");
   let iterator = new OS.File.DirectoryIterator(TEST_DIR);
   let thrown = false;
   try {
     await OS.File.resetWorker();
-  } catch (ex) {
-    if (ex.message.indexOf(OS.Path.basename(TEST_DIR)) != -1 ) {
-      thrown = true;
-    } else {
-      throw ex;
-    }
+  } catch (ex if ex.message.indexOf(OS.Path.basename(TEST_DIR)) != -1 ) {
+    thrown = true;
   }
   do_check_true(thrown);
 
   do_print("Closing the directory, we should now be able to reset");
   await iterator.close();
   await OS.File.resetWorker();
 });
 
@@ -90,14 +82,14 @@ add_task(async function race_against_its
 add_task(async function finish_with_a_reset() {
   do_print("Reset without waiting for the result");
   // Arbitrary operation, just to wake up the worker
   try {
     await OS.File.read("/foo");
   } catch (ex) {
   }
   // Now reset
-  /* don't yield*/ OS.File.resetWorker();
+  /*don't yield*/ OS.File.resetWorker();
 });
 
 function run_test() {
   run_next_test();
 }
--- a/toolkit/components/osfile/tests/xpcshell/test_shutdown.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_shutdown.js
@@ -54,22 +54,18 @@ add_task(async function system_shutdown(
         do_print("Timeout while waiting for resource: " + resource);
         deferred.reject("timeout");
       });
 
       let resolved = false;
       try {
         await deferred.promise;
         resolved = true;
-      } catch (ex) {
-        if (ex == "timeout") {
-          resolved = false;
-        } else {
-          throw ex;
-        }
+      } catch (ex if ex == "timeout") {
+        resolved = false;
       }
       Services.console.unregisterListener(observer);
       Services.prefs.clearUserPref("toolkit.osfile.log");
       Services.prefs.clearUserPref("toolkit.osfile.log.redirect");
       Services.prefs.clearUserPref("toolkit.osfile.test.shutdown.observer");
       Services.prefs.clearUserPref("toolkit.async_shutdown.testing");
 
       return resolved;