Bug 994448 - Make test_contacts_blobs.html test the data that comes from the Contacts API. r=gwagner
authorReuben Morais <reuben.morais@gmail.com>
Thu, 17 Apr 2014 00:35:45 -0300
changeset 198554 f69f2fb119386d5b3dc2c581c0c43525c207601c
parent 198553 36e61fd7ed89b7d99fb15fa27dcef4fd8061ea90
child 198555 a06fc50e2bb3336f5ac7c81872db8c2166ff7749
push id486
push userasasaki@mozilla.com
push dateMon, 14 Jul 2014 18:39:42 +0000
treeherdermozilla-release@d33428174ff1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgwagner
bugs994448
milestone31.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 994448 - Make test_contacts_blobs.html test the data that comes from the Contacts API. r=gwagner
dom/contacts/tests/test_contacts_blobs.html
--- a/dom/contacts/tests/test_contacts_blobs.html
+++ b/dom/contacts/tests/test_contacts_blobs.html
@@ -89,22 +89,25 @@ var properties2 = {
 
 var sample_id1;
 var createResult1;
 var findResult1;
 
 function verifyBlob(blob1, blob2, isLast)
 {
   is(blob1 instanceof SpecialPowers.Ci.nsIDOMBlob, true,
-     "Instance of nsIDOMBlob");
-  is(blob1 instanceof SpecialPowers.Ci.nsIDOMFile,
-     blob2 instanceof SpecialPowers.Ci.nsIDOMFile,
-     "Instance of nsIDOMFile");
-  is(blob1.size, blob2.size, "Correct size");
-  is(blob1.type, blob2.type, "Correct type");
+     "blob1 is an instance of nsIDOMBlob");
+  is(blob2 instanceof SpecialPowers.Ci.nsIDOMBlob, true,
+     "blob2 is an instance of nsIDOMBlob");
+  isnot(blob1 instanceof SpecialPowers.Ci.nsIDOMFile, true,
+     "blob1 is an instance of nsIDOMFile");
+  isnot(blob2 instanceof SpecialPowers.Ci.nsIDOMFile, true,
+     "blob2 is an instance of nsIDOMFile");
+  ise(blob1.size, blob2.size, "Same size");
+  ise(blob1.type, blob2.type, "Same type");
 
   var buffer1;
   var buffer2;
 
   var reader1 = new FileReader();
   reader1.readAsArrayBuffer(blob2);
   reader1.onload = function(event) {
     buffer2 = event.target.result;
@@ -120,26 +123,28 @@ function verifyBlob(blob1, blob2, isLast
     if (buffer2) {
       verifyBuffers(buffer1, buffer2, isLast);
     }
   }
 }
 
 function verifyBlobArray(blobs1, blobs2)
 {
-  is(blobs1 instanceof Array, true, "Got an array object");
-  is(blobs1.length, blobs2.length, "Correct length");
+  is(blobs1 instanceof Array, true, "blobs1 is an array object");
+  is(blobs2 instanceof Array, true, "blobs2 is an array object");
+  ise(blobs1.length, blobs2.length, "Same length");
 
   if (!blobs1.length) {
     next();
     return;
   }
 
-  for (var i = 0; i < blobs1.length; i++)
+  for (var i = 0; i < blobs1.length; i++) {
     verifyBlob(blobs1[i], blobs2[i], i == blobs1.length - 1);
+  }
 }
 
 var req;
 
 var steps = [
   function () {
     ok(true, "Deleting database");
     req = mozContacts.clear();
@@ -165,17 +170,17 @@ var steps = [
     var options = {filterBy: ["givenName"],
                    filterOp: "startsWith",
                    filterValue: properties1.givenName[0].substring(0,3)};
     req = mozContacts.find(options);
     req.onsuccess = function () {
       ok(req.result.length == 1, "Found exactly 1 contact.");
       findResult1 = req.result[0];
       ok(findResult1.id == sample_id1, "Same ID");
-      verifyBlobArray(createResult1.photo, properties1.photo);
+      verifyBlobArray(findResult1.photo, properties1.photo);
     };
     req.onerror = onFailure;
   },
   function () {
     ok(true, "Adding contact with 2 photos");
     createResult1 = new mozContact(properties2);
     req = navigator.mozContacts.save(createResult1);
     req.onsuccess = function () {
@@ -190,17 +195,17 @@ var steps = [
     var options = {filterBy: ["givenName"],
                    filterOp: "startsWith",
                    filterValue: properties2.givenName[0].substring(0,3)};
     req = mozContacts.find(options);
     req.onsuccess = function () {
       ok(req.result.length == 1, "Found exactly 1 contact.");
       findResult1 = req.result[0];
       ok(findResult1.id == sample_id1, "Same ID");
-      verifyBlobArray(createResult1.photo, properties2.photo);
+      verifyBlobArray(findResult1.photo, properties2.photo);
     };
     req.onerror = onFailure;
   },
   function () {
     ok(true, "Deleting database");
     req = mozContacts.clear()
     req.onsuccess = function () {
       ok(true, "Deleted the database");