Bug 1355677 - test cleanup/fixup that relies on bug 1357625 - I'll fold this if that lands. draft
authorMark Hammond <mhammond@skippinet.com.au>
Thu, 20 Apr 2017 18:22:22 +1000
changeset 565699 d17b1abd7d813827e90cbb9410a323c0cd9d0fae
parent 565698 25c3c4d280a292fbb8cdb203c281df53544b8ae0
child 625083 df9945571c1313f241040db8e893b0a4efe23ab4
push id54968
push userbmo:markh@mozilla.com
push dateThu, 20 Apr 2017 08:48:06 +0000
bugs1355677, 1357625
milestone55.0a1
Bug 1355677 - test cleanup/fixup that relies on bug 1357625 - I'll fold this if that lands. MozReview-Commit-ID: DbwnoQTSdax
services/sync/tests/unit/test_resource_async.js
--- a/services/sync/tests/unit/test_resource_async.js
+++ b/services/sync/tests/unit/test_resource_async.js
@@ -533,84 +533,67 @@ add_task(async function test_quota_notic
   let content = await res10.get();
   do_check_eq(content.status, 200);
   do_check_eq(quotaValue, 1048576);
 });
 
 add_task(async function test_preserve_exceptions() {
   _("Error handling in ChannelListener etc. preserves exception information");
   let res11 = new AsyncResource("http://localhost:12345/does/not/exist");
-  try {
-    await res11.get();
-    throw new Error("expected get to fail");
-  } catch (error) {
-    do_check_neq(error, null);
-    do_check_eq(error.result, Cr.NS_ERROR_CONNECTION_REFUSED);
-    do_check_eq(error.message, "NS_ERROR_CONNECTION_REFUSED");
-  };
+  let error = await Assert.rejects(res11.get());
+  do_check_neq(error, null);
+  do_check_eq(error.result, Cr.NS_ERROR_CONNECTION_REFUSED);
+  do_check_eq(error.message, "NS_ERROR_CONNECTION_REFUSED");
 });
 
 add_task(async function test_xpc_exception_handling() {
   _("Exception handling inside fetches.");
   let res14 = new AsyncResource(server.baseURI + "/json");
   res14._onProgress = function(rec) {
     // Provoke an XPC exception without a Javascript wrapper.
     Services.io.newURI("::::::::");
   };
   let warnings = [];
   res14._log.warn = function(msg) { warnings.push(msg); };
 
-  try {
-    await res14.get();
-    throw new Error("expected get to fail");
-  } catch (error) {
-    do_check_eq(error.result, Cr.NS_ERROR_MALFORMED_URI);
-    do_check_eq(error.message, "NS_ERROR_MALFORMED_URI");
-    do_check_eq(warnings.pop(),
-                "${action} request to ${url} failed: ${ex}");
-    do_check_eq(warnings.pop(),
-                "Got exception calling onProgress handler during fetch of " +
-                server.baseURI + "/json");
-
-  };
+  let error = await Assert.rejects(res14.get());
+  do_check_eq(error.result, Cr.NS_ERROR_MALFORMED_URI);
+  do_check_eq(error.message, "NS_ERROR_MALFORMED_URI");
+  do_check_eq(warnings.pop(),
+              "${action} request to ${url} failed: ${ex}");
+  do_check_eq(warnings.pop(),
+              "Got exception calling onProgress handler during fetch of " +
+              server.baseURI + "/json");
 });
 
 add_task(async function test_js_exception_handling() {
   _("JS exception handling inside fetches.");
   let res15 = new AsyncResource(server.baseURI + "/json");
   res15._onProgress = function(rec) {
     throw "BOO!";
   };
   let warnings = [];
   res15._log.warn = function(msg) { warnings.push(msg); };
 
-  try {
-    await res15.get();
-    throw new Error("expected get to fail");
-  } catch (error) {
-    do_check_eq(error.result, Cr.NS_ERROR_XPC_JS_THREW_STRING);
-    do_check_eq(error.message, "NS_ERROR_XPC_JS_THREW_STRING");
-    do_check_eq(warnings.pop(),
-                "${action} request to ${url} failed: ${ex}");
-    do_check_eq(warnings.pop(),
-                "Got exception calling onProgress handler during fetch of " +
-                server.baseURI + "/json");
-  };
+  let error = await Assert.rejects(res15.get());
+  do_check_eq(error.result, Cr.NS_ERROR_XPC_JS_THREW_STRING);
+  do_check_eq(error.message, "NS_ERROR_XPC_JS_THREW_STRING");
+  do_check_eq(warnings.pop(),
+              "${action} request to ${url} failed: ${ex}");
+  do_check_eq(warnings.pop(),
+              "Got exception calling onProgress handler during fetch of " +
+              server.baseURI + "/json");
 });
 
 add_task(async function test_timeout() {
   _("Ensure channel timeouts are thrown appropriately.");
   let res19 = new AsyncResource(server.baseURI + "/json");
   res19.ABORT_TIMEOUT = 0;
-  try {
-    await res19.get();
-    throw new Error("expected get to fail");
-  } catch (error) {
-    do_check_eq(error.result, Cr.NS_ERROR_NET_TIMEOUT);
-  };
+  let error = await Assert.rejects(res19.get());
+  do_check_eq(error.result, Cr.NS_ERROR_NET_TIMEOUT);
 });
 
 add_test(function test_uri_construction() {
   _("Testing URI construction.");
   let args = [];
   args.push("newer=" + 1234);
   args.push("limit=" + 1234);
   args.push("sort=" + 1234);