Bug 1403959, part 1 - Remove non-standard conditional catch clause. r=froydnj
This is non-standard, and eslint can't parse it correctly, so remove
it.
MozReview-Commit-ID: EsfZSyoECB0
--- a/xpcom/tests/unit/test_file_createUnique.js
+++ b/xpcom/tests/unit/test_file_createUnique.js
@@ -17,13 +17,16 @@ function run_test()
getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
tempFile.append(longLeafName);
tempFile.append("test.txt");
try {
tempFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
do_throw("Creating an item in a folder with a very long name should throw");
}
- catch (e if (e instanceof Ci.nsIException &&
- e.result == Cr.NS_ERROR_FILE_UNRECOGNIZED_PATH)) {
+ catch (e) {
+ if (!(e instanceof Ci.nsIException &&
+ e.result == Cr.NS_ERROR_FILE_UNRECOGNIZED_PATH)) {
+ throw e;
+ }
// We expect the function not to crash but to raise this exception.
}
}
--- a/xpcom/tests/unit/test_storagestream.js
+++ b/xpcom/tests/unit/test_storagestream.js
@@ -34,18 +34,22 @@ function test1()
var sis =
Cc["@mozilla.org/scriptableinputstream;1"]
.createInstance(Ci.nsIScriptableInputStream);
sis.init(inp2);
var threw = false;
try {
sis.read(1);
- } catch (ex if ex.result == Cr.NS_BASE_STREAM_WOULD_BLOCK) {
- threw = true;
+ } catch (ex) {
+ if (ex.result == Cr.NS_BASE_STREAM_WOULD_BLOCK) {
+ threw = true;
+ } else {
+ throw ex;
+ }
}
do_check_true(threw);
}
/**
* Checks that getting an input stream from a storage stream to which 0 bytes of
* data have been explicitly written doesn't throw an exception.
*/
--- a/xpcom/tests/unit/test_streams.js
+++ b/xpcom/tests/unit/test_streams.js
@@ -125,33 +125,42 @@ function test_binary_streams() {
// Test for invalid actions.
os.close();
is.close();
try {
os.writeBoolean(false);
do_throw("Not reached!");
- } catch (e if (e instanceof Ci.nsIException &&
- e.result == Cr.NS_BASE_STREAM_CLOSED)) {
+ } catch (e) {
+ if (!(e instanceof Ci.nsIException &&
+ e.result == Cr.NS_BASE_STREAM_CLOSED)) {
+ throw e;
+ }
// do nothing
}
try {
is.available();
do_throw("Not reached!");
- } catch (e if (e instanceof Ci.nsIException &&
- e.result == Cr.NS_BASE_STREAM_CLOSED)) {
+ } catch (e) {
+ if (!(e instanceof Ci.nsIException &&
+ e.result == Cr.NS_BASE_STREAM_CLOSED)) {
+ throw e;
+ }
// do nothing
}
try {
is.readBoolean();
do_throw("Not reached!");
- } catch (e if (e instanceof Ci.nsIException &&
- e.result == Cr.NS_ERROR_FAILURE)) {
+ } catch (e) {
+ if (!(e instanceof Ci.nsIException &&
+ e.result == Cr.NS_ERROR_FAILURE)) {
+ throw e;
+ }
// do nothing
}
}
function run_test() {
test_binary_streams();
}
--- a/xpcom/tests/unit/test_windows_registry.js
+++ b/xpcom/tests/unit/test_windows_registry.js
@@ -47,18 +47,20 @@ function run_test()
function setup_test_run(testKey, keyName)
{
do_print("Setup test run");
try {
testKey.open(nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, keyName, nsIWindowsRegKey.ACCESS_READ);
do_print("Test key exists. Needs cleanup.");
cleanup_test_run(testKey, keyName);
}
- catch (e if (e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE))
- {
+ catch (e) {
+ if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
+ throw e;
+ }
}
testKey.create(nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, keyName, nsIWindowsRegKey.ACCESS_ALL);
}
function test_writing_functions(testKey)
{
strictEqual(testKey.valueCount, 0);
@@ -101,35 +103,47 @@ function test_reading_functions(testKey)
strictEqual( testKey.readBinaryValue(TESTDATA_BINARYNAME), TESTDATA_BINARYVALUE);
}
function test_invalidread_functions(testKey)
{
try {
testKey.readIntValue(TESTDATA_STRNAME);
do_throw("Reading an integer from a string registry value should throw.");
- } catch (e if (e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
+ } catch (e) {
+ if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
+ throw e;
+ }
}
try {
let val = testKey.readStringValue(TESTDATA_INTNAME);
do_throw("Reading an string from an Int registry value should throw." + val);
- } catch (e if (e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
+ } catch (e) {
+ if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
+ throw e;
+ }
}
try {
testKey.readStringValue(TESTDATA_INT64NAME);
do_throw("Reading an string from an Int64 registry value should throw.");
- } catch (e if (e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
+ } catch (e) {
+ if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
+ throw e;
+ }
}
try {
testKey.readStringValue(TESTDATA_BINARYNAME);
do_throw("Reading a string from an Binary registry value should throw.");
- } catch (e if (e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
+ } catch (e) {
+ if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
+ throw e;
+ }
}
}
function test_childkey_functions(testKey)
{
strictEqual(testKey.childCount, 0);
strictEqual(testKey.hasChild(TESTDATA_CHILD_KEY), false);
--- a/xpcom/tests/unit/test_windows_shortcut.js
+++ b/xpcom/tests/unit/test_windows_shortcut.js
@@ -47,20 +47,21 @@ function test_create_noargs(tempDir)
let win = shortcutFile.QueryInterface(Ci.nsILocalFileWin);
try
{
win.setShortcut();
do_throw("Creating a shortcut with no args (no target) should throw");
}
- catch(e if (e instanceof Ci.nsIException
- && e.result == Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST))
- {
-
+ catch(e) {
+ if (!(e instanceof Ci.nsIException
+ && e.result == Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)) {
+ throw e;
+ }
}
}
function test_create_notarget(tempDir)
{
let shortcutFile = tempDir.clone();
shortcutFile.append("shouldNeverExist2.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
@@ -70,20 +71,21 @@ function test_create_notarget(tempDir)
try
{
win.setShortcut(null,
do_get_cwd(),
"arg1 arg2",
"Shortcut with no target");
do_throw("Creating a shortcut with no target should throw");
}
- catch(e if (e instanceof Ci.nsIException
- && e.result == Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST))
- {
-
+ catch(e) {
+ if (!(e instanceof Ci.nsIException
+ && e.result == Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)) {
+ throw e;
+ }
}
}
function test_create_targetonly(tempDir)
{
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);