Bug 614222 - Try to use waitForAsyncUpdates in test_frecency.js
authorMarco Bonardo <mbonardo@mozilla.com>
Wed, 24 Nov 2010 10:44:03 +0100
changeset 59353 0e86c9d9a9946c6a3bdf80c043320550d6a20bae
parent 59352 952cedf2302e4422a5ff1796ec35faef48bb4505
child 59354 d9d0d771be991f3f522454b9f6f3a17fe5022f58
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
bugs614222
milestone2.0b8pre
Bug 614222 - Try to use waitForAsyncUpdates in test_frecency.js a=tests-only
toolkit/components/places/tests/head_common.js
toolkit/components/places/tests/unit/test_frecency.js
--- a/toolkit/components/places/tests/head_common.js
+++ b/toolkit/components/places/tests/head_common.js
@@ -547,20 +547,20 @@ function is_time_ordered(before, after) 
  *       a write lock.  Since all statements on the same connection are
  *       serialized, the end of this write operation means that all writes are
  *       complete.  Note that WAL makes so that writers don't block readers, but
  *       this is a problem only across different connections.
  */
 function waitForAsyncUpdates(aCallback, aScope, aArguments)
 {
   let scope = aScope || this;
-  let argument = aArguments || [];
+  let args = aArguments || [];
   let db = DBConn();
   db.createAsyncStatement("BEGIN EXCLUSIVE").executeAsync();
   db.createAsyncStatement("COMMIT").executeAsync({
     handleResult: function() {},
     handleError: function() {},
     handleCompletion: function(aReason)
     {
-      aCallback.apply(scope, arguments);
+      aCallback.apply(scope, args);
     }
   });
 }
--- a/toolkit/components/places/tests/unit/test_frecency.js
+++ b/toolkit/components/places/tests/unit/test_frecency.js
@@ -103,21 +103,17 @@ AutoCompleteInput.prototype = {
       return this;
 
     throw Components.results.NS_ERROR_NO_INTERFACE;
   }
 }
 
 function ensure_results(uris, searchTerm)
 {
-  waitForFrecency(uris[0].spec, function () {
-    return uris.every(function (aURI) {
-      return frecencyForUrl(aURI.spec) > 0;
-    });
-  }, ensure_results_internal, this, arguments);
+  waitForAsyncUpdates(ensure_results_internal, this, arguments);
 }
 
 function ensure_results_internal(uris, searchTerm)
 {
   var controller = Components.classes["@mozilla.org/autocomplete/controller;1"].
                    getService(Components.interfaces.nsIAutoCompleteController);
 
   // Make an AutoCompleteInput that uses our searches