Bug 570905 - intermittent timeout in test_adaptive.js: skip vacuum and use batches. r=dietrich a=test-only
authorMarco Bonardo <mbonardo@mozilla.com>
Sat, 16 Oct 2010 11:06:37 +0200
changeset 55935 397c458b40a4886ebc8a20b91c604f2833f5c60e
parent 55934 4e05764294ec85b60c626140ef56e4433ac0bb53
child 55936 3deaf784de576d71f6e69fca2a1230d0e4716b98
push id16345
push usermak77@bonardo.net
push dateSat, 16 Oct 2010 09:09:28 +0000
treeherdermozilla-central@397c458b40a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdietrich, test-only
bugs570905
milestone2.0b8pre
first release with
nightly linux32
397c458b40a4 / 4.0b8pre / 20101016025826 / files
nightly linux64
397c458b40a4 / 4.0b8pre / 20101016030624 / files
nightly mac
397c458b40a4 / 4.0b8pre / 20101016030347 / files
nightly win32
397c458b40a4 / 4.0b8pre / 20101016041245 / files
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 570905 - intermittent timeout in test_adaptive.js: skip vacuum and use batches. r=dietrich a=test-only
toolkit/components/places/tests/unit/test_adaptive.js
--- a/toolkit/components/places/tests/unit/test_adaptive.js
+++ b/toolkit/components/places/tests/unit/test_adaptive.js
@@ -53,39 +53,36 @@
  */
 
 function AutoCompleteInput(aSearches) {
   this.searches = aSearches;
 }
 AutoCompleteInput.prototype = {
   constructor: AutoCompleteInput,
 
-  minResultsForPopup: 0,
-  timeout: 10,
-  searchParam: "",
-  textValue: "",
-  disableAutoComplete: false,
-  completeDefaultIndex: false,
+  get minResultsForPopup() 0,
+  get timeout() 10,
+  get searchParam() "",
+  get textValue() "",
+  get disableAutoComplete() false,
+  get completeDefaultIndex() false,
 
   get searchCount() this.searches.length,
-
   getSearchAt: function (aIndex) this.searches[aIndex],
 
+  onSearchBegin: function () {},
   onSearchComplete: function() {},
 
-  popupOpen: false,
-
+  get popupOpen() false,
   popup: {
-    setSelectedIndex: function (aIndex) {},
+    set selectedIndex(aIndex) aIndex,
     invalidate: function () {},
     QueryInterface: XPCOMUtils.generateQI([Ci.nsIAutoCompletePopup])
   },
 
-  onSearchBegin: function () {},
-
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIAutoCompleteInput])
 }
 
 /**
  * Checks that autocomplete results are ordered correctly.
  */
 function ensure_results(expected, searchTerm)
 {
@@ -114,22 +111,26 @@ function ensure_results(expected, search
   controller.startSearch(searchTerm);
 }
 
 /**
  * Bump up the rank for an uri.
  */
 function setCountRank(aURI, aCount, aRank, aSearch, aBookmark)
 {
-  // Bump up the visit count for the uri.
-  for (let i = 0; i < aCount; i++) {
-    PlacesUtils.history.addVisit(aURI, d1, null,
-                                 PlacesUtils.history.TRANSITION_TYPED,
-                                 false, 0);
-  }
+  PlacesUtils.history.runInBatchMode({
+    runBatched: function() {
+      // Bump up the visit count for the uri.
+      for (let i = 0; i < aCount; i++) {
+        PlacesUtils.history.addVisit(aURI, d1, null,
+                                     PlacesUtils.history.TRANSITION_TYPED,
+                                     false, 0);
+      }
+    }
+  }, this);
 
   // Make a nsIAutoCompleteController and friends for instrumentation feedback.
   let thing = {
     QueryInterface: XPCOMUtils.generateQI([Ci.nsIAutoCompleteInput,
                                            Ci.nsIAutoCompletePopup,
                                            Ci.nsIAutoCompleteController]),
     get popup() thing,
     get controller() thing,
@@ -158,20 +159,24 @@ function setCountRank(aURI, aCount, aRan
   }
 }
 
 /**
  * Decay the adaptive entries by sending the daily idle topic.
  */
 function doAdaptiveDecay()
 {
-  for (let i = 0; i < 10; i++) {
-    PlacesUtils.history.QueryInterface(Ci.nsIObserver)
-                       .observe(null, "idle-daily", null);
-  }
+  PlacesUtils.history.runInBatchMode({
+    runBatched: function() {
+      for (let i = 0; i < 10; i++) {
+        PlacesUtils.history.QueryInterface(Ci.nsIObserver)
+                           .observe(null, "idle-daily", null);
+      }
+    }
+  }, this);
 }
 
 let uri1 = uri("http://site.tld/1");
 let uri2 = uri("http://site.tld/2");
 
 // d1 is some date for the page visit
 let d1 = new Date(Date.now() - 1000 * 60 * 60) * 1000;
 // c1 is larger (should show up higher) than c2
@@ -375,16 +380,20 @@ let tests = [
     setCountRank(uri2, c1, c2, s2);
   },
 ];
 
 /**
  * Test adaptive autocomplete.
  */
 function run_test() {
+  // doAdaptiveDecay notifies idle-daily to fix frecency.  Unfortunately this
+  // also causes a vacuum at each iteration.  Thus disable vacuum for this test.
+  Services.prefs.setIntPref("places.last_vacuum", parseInt(Date.now()/1000));
+
   do_test_pending();
   next_test();
 }
 
 function next_test() {
   if (tests.length) {
     // Cleanup.
     PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId);