Bug 855556 - Test the cached branch of getAll more extensively. r=gwagner
authorReuben Morais <reuben.morais@gmail.com>
Fri, 26 Apr 2013 15:05:06 -0700
changeset 141114 6e30c424614094feeed3e618682e72c4630c3f8d
parent 141113 a132c4393c174f761ebd0d633697816633a2b857
child 141115 0444a6571cac32487afdfb946bc7c04dd7e1fe67
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgwagner
bugs855556
milestone23.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 855556 - Test the cached branch of getAll more extensively. r=gwagner
dom/contacts/fallback/ContactDB.jsm
dom/contacts/tests/test_contacts_getall.html
--- a/dom/contacts/fallback/ContactDB.jsm
+++ b/dom/contacts/fallback/ContactDB.jsm
@@ -67,17 +67,17 @@ function ContactDispatcher(aContacts, aF
                 aCallback(chunk)
                 aCallback(null);
                 cancelTimeout();
                 aClearDispatcher();
               } else if (chunk.length === CHUNK_SIZE) {
                 aCallback(chunk);
                 chunk.length = 0;
                 nextIndex += CHUNK_SIZE;
-                interval = setTimeout(this.sendChunk, CHUNK_INTERVAL);
+                interval = setTimeout(sendChunk, CHUNK_INTERVAL);
               }
             }
           }
         });
       } catch (e) {
         aClearDispatcher();
       }
     }
--- a/dom/contacts/tests/test_contacts_getall.html
+++ b/dom/contacts/tests/test_contacts_getall.html
@@ -190,51 +190,39 @@ function addContacts() {
 }
 
 let createResult1;
 
 let index = 0;
 let req;
 let mozContacts = window.navigator.mozContacts;
 
-let steps = [
-  clearDatabase,
-  function() {
-    // add a contact
-    createResult1 = new mozContact();
-    createResult1.init({});
-    req = navigator.mozContacts.save(createResult1);
-    req.onsuccess = function() {
-      next();
-    };
-    req.onerror = onFailure;
-  },
-  function() {
-    ok(true, "Retrieving one contact with getAll");
+function getOne(msg) {
+  return function() {
+    ok(true, msg || "Retrieving one contact with getAll");
     req = mozContacts.getAll({});
     let count = 0;
     req.onsuccess = function(event) {
       ok(true, "on success");
       if (req.result) {
         ok(true, "result is valid");
         count++;
         req.continue();
       } else {
         is(count, 1, "last contact - only one contact returned");
         next();
       }
     };
     req.onerror = onFailure;
-  },
+  };
+}
 
-  clearDatabase,
-  addContacts,
-
-  function() {
-    ok(true, "Retrieving 40 contacts with getAll");
+function getAll(msg) {
+  return function() {
+    ok(true, msg || "Retrieving 40 contacts with getAll");
     req = mozContacts.getAll({
       sortBy: "familyName",
       sortOrder: "ascending"
     });
     let count = 0;
     let result;
     let props;
     req.onsuccess = function(event) {
@@ -246,17 +234,41 @@ let steps = [
         count++;
         req.continue();
       } else {
         is(count, 40, "last contact - 40 contacts returned");
         next();
       }
     };
     req.onerror = onFailure;
+  }
+}
+
+let steps = [
+  clearDatabase,
+  function() {
+    // add a contact
+    createResult1 = new mozContact();
+    createResult1.init({});
+    req = navigator.mozContacts.save(createResult1);
+    req.onsuccess = function() {
+      next();
+    };
+    req.onerror = onFailure;
   },
+
+  getOne(),
+  getOne("Retrieving one contact with getAll - cached"),
+
+  clearDatabase,
+  addContacts,
+
+  getAll(),
+  getAll("Retrieving 40 contacts with getAll - cached"),
+
   function() {
     ok(true, "Deleting one contact");
     req = mozContacts.remove(createResult1);
     req.onsuccess = function() {
       next();
     };
     req.onerror = onFailure;
   },