Bug 801855 - Tests for MAR downloads will not be accepted if manifest size is different. r=rstrong
authorBrian R. Bondy <netzen@gmail.com>
Fri, 19 Oct 2012 12:43:51 -0400
changeset 110918 7e8a1440a598c5e61717d7a9ba611409f2a71bcf
parent 110917 fb33f8e799c8d3ccb0db558054623ed415c084dd
child 110919 3a20b8a911dc5ede0f77a8d323a5ec85f7be7617
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersrstrong
bugs801855
milestone19.0a1
Bug 801855 - Tests for MAR downloads will not be accepted if manifest size is different. r=rstrong
toolkit/mozapps/update/test/unit/test_0030_general.js
--- a/toolkit/mozapps/update/test/unit/test_0030_general.js
+++ b/toolkit/mozapps/update/test/unit/test_0030_general.js
@@ -72,98 +72,107 @@ function check_test_helper_pt1_1() {
 }
 
 function check_test_helper_pt1_2() {
   do_check_eq(gStatusResult, gExpectedStatusResult);
   gAUS.removeDownloadListener(downloadListener);
   gNextRunFunc();
 }
 
-function setResponseBody(aHashFunction, aHashValue) {
-  var patches = getRemotePatchString(null, null, aHashFunction, aHashValue);
+function setResponseBody(aHashFunction, aHashValue, aSize) {
+  var patches = getRemotePatchString(null, null,
+                                     aHashFunction, aHashValue, aSize);
   var updates = getRemoteUpdateString(patches);
   gResponseBody = getRemoteUpdatesXMLString(updates);
 }
 
 // mar download with a valid MD5 hash
 function run_test_pt1() {
   setResponseBody("MD5", MD5_HASH_SIMPLE_MAR);
   run_test_helper_pt1("mar download with a valid MD5 hash",
                       AUS_Cr.NS_OK, run_test_pt2);
 }
 
 // mar download with an invalid MD5 hash
 function run_test_pt2() {
   setResponseBody("MD5", MD5_HASH_SIMPLE_MAR + "0");
   run_test_helper_pt1("mar download with an invalid MD5 hash",
-                      AUS_Cr.NS_ERROR_UNEXPECTED, run_test_pt3);
+                      AUS_Cr.NS_ERROR_CORRUPTED_CONTENT, run_test_pt3);
 }
 
 // mar download with a valid SHA1 hash
 function run_test_pt3() {
   setResponseBody("SHA1", SHA1_HASH_SIMPLE_MAR);
   run_test_helper_pt1("mar download with a valid SHA1 hash",
                       AUS_Cr.NS_OK, run_test_pt4);
 }
 
 // mar download with an invalid SHA1 hash
 function run_test_pt4() {
   setResponseBody("SHA1", SHA1_HASH_SIMPLE_MAR + "0");
   run_test_helper_pt1("mar download with an invalid SHA1 hash",
-                      AUS_Cr.NS_ERROR_UNEXPECTED, run_test_pt5);
+                      AUS_Cr.NS_ERROR_CORRUPTED_CONTENT, run_test_pt5);
 }
 
 // mar download with a valid SHA256 hash
 function run_test_pt5() {
   setResponseBody("SHA256", SHA256_HASH_SIMPLE_MAR);
   run_test_helper_pt1("mar download with a valid SHA256 hash",
                       AUS_Cr.NS_OK, run_test_pt6);
 }
 
 // mar download with an invalid SHA256 hash
 function run_test_pt6() {
   setResponseBody("SHA256", SHA256_HASH_SIMPLE_MAR + "0");
   run_test_helper_pt1("mar download with an invalid SHA256 hash",
-                      AUS_Cr.NS_ERROR_UNEXPECTED, run_test_pt7);
+                      AUS_Cr.NS_ERROR_CORRUPTED_CONTENT, run_test_pt7);
 }
 
 // mar download with a valid SHA384 hash
 function run_test_pt7() {
   setResponseBody("SHA384", SHA384_HASH_SIMPLE_MAR);
   run_test_helper_pt1("mar download with a valid SHA384 hash",
                       AUS_Cr.NS_OK, run_test_pt8);
 }
 
 // mar download with an invalid SHA384 hash
 function run_test_pt8() {
   setResponseBody("SHA384", SHA384_HASH_SIMPLE_MAR + "0");
   run_test_helper_pt1("mar download with an invalid SHA384 hash",
-                      AUS_Cr.NS_ERROR_UNEXPECTED, run_test_pt9);
+                      AUS_Cr.NS_ERROR_CORRUPTED_CONTENT, run_test_pt9);
 }
 
 // mar download with a valid SHA512 hash
 function run_test_pt9() {
   setResponseBody("SHA512", SHA512_HASH_SIMPLE_MAR);
   run_test_helper_pt1("mar download with a valid SHA512 hash",
                       AUS_Cr.NS_OK, run_test_pt10);
 }
 
 // mar download with an invalid SHA384 hash
 function run_test_pt10() {
   setResponseBody("SHA512", SHA512_HASH_SIMPLE_MAR + "0");
   run_test_helper_pt1("mar download with an invalid SHA512 hash",
-                      AUS_Cr.NS_ERROR_UNEXPECTED, run_test_pt11);
+                      AUS_Cr.NS_ERROR_CORRUPTED_CONTENT, run_test_pt11);
 }
 
 // mar download with the mar not found
 function run_test_pt11() {
   var patches = getRemotePatchString(null, URL_HOST + URL_PATH + "/missing.mar");
   var updates = getRemoteUpdateString(patches);
   gResponseBody = getRemoteUpdatesXMLString(updates);
   run_test_helper_pt1("mar download with the mar not found",
+                      AUS_Cr.NS_ERROR_UNEXPECTED, run_test_pt12);
+}
+
+// mar download with a valid MD5 hash but invalid file size
+function run_test_pt12() {
+  const arbitraryFileSize = 1024000;
+  setResponseBody("MD5", MD5_HASH_SIMPLE_MAR ,arbitraryFileSize);
+  run_test_helper_pt1("mar download with a valid MD5 hash but invalid file size",
                       AUS_Cr.NS_ERROR_UNEXPECTED, finish_test);
 }
 
 /* Update download listener - nsIRequestObserver */
 const downloadListener = {
   onStartRequest: function DL_onStartRequest(request, context) {
   },