backing out due to unit test failures
authorDietrich Ayala <dietrich@mozilla.com>
Wed, 18 Mar 2009 19:13:10 -0700
changeset 26334 4e1a4c23041c9705fc456c27d4da96839ba25629
parent 26333 254a4231d50384fb17057413c4176cbb8d7b1e88
child 26336 b215e2744584e453b74cb2b68227f996d189d8df
push idunknown
push userunknown
push dateunknown
milestone1.9.2a1pre
backing out due to unit test failures
browser/components/places/content/controller.js
toolkit/components/places/src/nsNavHistory.cpp
toolkit/components/places/src/nsNavHistory.h
toolkit/components/places/src/nsNavHistoryResult.cpp
toolkit/components/places/tests/unit/test_history_sidebar.js
toolkit/locales/en-US/chrome/global/dateFormat.properties
toolkit/locales/en-US/chrome/places/places.properties
toolkit/locales/jar.mn
--- a/browser/components/places/content/controller.js
+++ b/browser/components/places/content/controller.js
@@ -968,23 +968,36 @@ PlacesController.prototype = {
       else if (PlacesUtils.nodeIsURI(node)) {
         var uri = PlacesUtils._uri(node.uri);
         // avoid trying to delete the same url twice
         if (URIs.indexOf(uri) < 0) {
           URIs.push(uri);
         }
       }
       else if (PlacesUtils.nodeIsDay(node)) {
-        var query = node.getQueries({})[0];
-        var beginTime = query.beginTime;
-        var endTime = query.endTime;
-        NS_ASSERT(query && beginTime && endTime,
-                  "A valid date container query should exist!");
-        // We want to exclude beginTime from the removal
-        bhist.removePagesByTimeframe(beginTime+1, endTime);
+        // this is the oldest date
+        // for the last node endDate is end of epoch
+        var beginDate = 0;
+        // this is the newest date
+        // day nodes have time property set to the last day in the interval
+        var endDate = node.time;
+
+        var nodeIdx = 0;
+        var cc = root.childCount;
+
+        // Find index of current day node
+        while (nodeIdx < cc && root.getChild(nodeIdx) != node)
+          ++nodeIdx;
+
+        // We have an older day
+        if (nodeIdx+1 < cc)
+          beginDate = root.getChild(nodeIdx+1).time;
+
+        // we want to exclude beginDate from the removal
+        bhist.removePagesByTimeframe(beginDate+1, endDate);
       }
     }
 
     // if we have to delete a lot of urls RemovePage will be slow, it's better
     // to delete them in bunch and rebuild the full treeView
     if (URIs.length > REMOVE_PAGES_MAX_SINGLEREMOVES) {
       // do removal in chunks to avoid passing a too big array to removePages
       for (var i = 0; i < URIs.length; i += REMOVE_PAGES_CHUNKLEN) {
--- a/toolkit/components/places/src/nsNavHistory.cpp
+++ b/toolkit/components/places/src/nsNavHistory.cpp
@@ -49,16 +49,17 @@
 #include "nsPlacesTables.h"
 
 #include "nsIArray.h"
 #include "nsTArray.h"
 #include "nsArrayEnumerator.h"
 #include "nsCollationCID.h"
 #include "nsCOMPtr.h"
 #include "nsCRT.h"
+#include "nsDateTimeFormatCID.h"
 #include "nsDebug.h"
 #include "nsEnumeratorUtils.h"
 #include "nsFaviconService.h"
 #include "nsIChannelEventSink.h"
 #include "nsIComponentManager.h"
 #include "nsILocaleService.h"
 #include "nsILocalFile.h"
 #include "nsIPrefBranch2.h"
@@ -2997,16 +2998,18 @@ PRBool NeedToFilterResultSet(const nsCOM
         return PR_TRUE;
     }
   }
   return PR_FALSE;
 }
 
 // ** Helper class for ConstructQueryString **/
 
+static const PRInt32 MAX_HISTORY_DAYS = 6;
+
 class PlacesSQLQueryBuilder
 {
 public:
   PlacesSQLQueryBuilder(const nsCString& aConditions,
                         nsNavHistoryQueryOptions* aOptions,
                         PRBool aUseLimit,
                         nsNavHistory::StringHash& aAddParams);
 
@@ -3471,174 +3474,151 @@ PlacesSQLQueryBuilder::SelectAsVisit()
 
   return NS_OK;
 }
 
 nsresult
 PlacesSQLQueryBuilder::SelectAsDay()
 {
   mSkipOrderBy = PR_TRUE;
-
-  PRUint16 resultType =
-    mResultType == nsINavHistoryQueryOptions::RESULTS_AS_DATE_QUERY ?
-    nsINavHistoryQueryOptions::RESULTS_AS_URI :
-    nsINavHistoryQueryOptions::RESULTS_AS_SITE_QUERY;
-
-  // beginTime will become the node's time property, we don't use endTime
-  // because it could overlap, and we use time to sort containers and find
-  // insert position in a result.
-  mQueryString = nsPrintfCString(1024,
-     "SELECT null, "
-       "'place:type=%ld&sort=%ld&beginTime='||beginTime||'&endTime='||endTime, "
-      "dayTitle, null, null, beginTime, null, null, null, null "
-     "FROM (", // TOUTER BEGIN
-     resultType,
-      nsINavHistoryQueryOptions::SORT_BY_TITLE_ASCENDING);
- 
-   nsNavHistory* history = nsNavHistory::GetHistoryService();
-   NS_ENSURE_STATE(history);
-
-  // These are the day containers and catch-all final container.
-  PRInt32 additionalContainers = 3;
-  // We use a guess of the number of months considering all of them 30 days
-  // long, but we split only the last 6 months.
-  PRInt32 monthContainers = PR_MIN(6, (history->mExpireDaysMax/30));
-  PRInt32 numContainers = monthContainers + additionalContainers;
-  for (PRInt32 i = 0; i <= numContainers; i++) {
-    nsCAutoString dateName;
-    // Timeframes are calculated as BeginTime <= container < EndTime.
-    // Notice times can't be relative to now, since to recognize a query we
-    // must ensure it won't change based on the time it is built.
-    // So, to select till now, we really select till start of tomorrow, that is
-    // a fixed timestamp.
-    nsCAutoString sqlFragmentBeginTime;
-    nsCAutoString sqlFragmentEndTime;
-    switch(i) {
-       case 0:
-        // Today
-         history->GetStringFromName(
-          NS_LITERAL_STRING("finduri-AgeInDays-is-0").get(), dateName);
-        // From start of today
-        sqlFragmentBeginTime = NS_LITERAL_CSTRING(
-          "(strftime('%s','now','start of day','utc')*1000000)");
-        // To now (tomorrow)
-        sqlFragmentEndTime = NS_LITERAL_CSTRING(
-          "(strftime('%s','now','start of day','+1 day','utc')*1000000)");
-         break;
-       case 1:
-        // Yesterday
-         history->GetStringFromName(
-          NS_LITERAL_STRING("finduri-AgeInDays-is-1").get(), dateName);
-        // From start of yesterday
-        sqlFragmentBeginTime = NS_LITERAL_CSTRING(
-          "(strftime('%s','now','start of day','-1 day','utc')*1000000)");
-        // To start of today
-        sqlFragmentEndTime = NS_LITERAL_CSTRING(
-          "(strftime('%s','now','start of day','utc')*1000000)");
+  PRBool asDayQuery = 
+    mResultType == nsINavHistoryQueryOptions::RESULTS_AS_DATE_QUERY;
+
+  mQueryString = nsPrintfCString(255,
+    "SELECT null, "
+      "'place:type=%ld&sort=%ld&beginTime='||beginTime||'&endTime='||endTime, "
+      "dayTitle, null, null, endTime, null, null, null, null "
+    "FROM (", // TOUTER BEGIN
+    (asDayQuery
+       ?nsINavHistoryQueryOptions::RESULTS_AS_URI
+       :nsINavHistoryQueryOptions::RESULTS_AS_SITE_QUERY),
+     nsINavHistoryQueryOptions::SORT_BY_TITLE_ASCENDING);
+
+  nsNavHistory* history = nsNavHistory::GetHistoryService();
+  NS_ENSURE_STATE(history);
+
+  struct Midnight
+  {
+    Midnight() {
+      mNow = NormalizeTimeRelativeToday(PR_Now());  
+    }
+    PRTime Get(PRInt32 aDayOffset) {
+      PRTime result;
+      LL_MUL(result, aDayOffset, USECS_PER_DAY);
+      LL_ADD(result, result, mNow);
+      return result;
+    }
+    PRTime mNow;
+  } midnight;
+
+  nsCAutoString dateParam;
+  nsCAutoString dateName;
+
+  for (PRInt32 i = 0; i <= MAX_HISTORY_DAYS; i++) {
+    dateParam = nsPrintfCString(":dayTitle%d", i);
+    switch (i)
+    {
+      case 0:
+        history->GetStringFromName(
+            NS_LITERAL_STRING("finduri-AgeInDays-is-0").get(), dateName);
         break;
-      case 2:
-        // Last 7 days
-        history->GetAgeInDaysString(7,
-          NS_LITERAL_STRING("finduri-AgeInDays-last-is").get(), dateName);
-        // From start of 7 days ago
-        sqlFragmentBeginTime = NS_LITERAL_CSTRING(
-          "(strftime('%s','now','start of day','-7 days','utc')*1000000)");
-        // To now (tomorrow)
-        sqlFragmentEndTime = NS_LITERAL_CSTRING(
-          "(strftime('%s','now','start of day','+1 day','utc')*1000000)");
-        break;
-      case 3:
-        // This month
+      case 1:
         history->GetStringFromName(
-          NS_LITERAL_STRING("finduri-AgeInMonths-is-0").get(), dateName);
-        // From start of this month
-        sqlFragmentBeginTime = NS_LITERAL_CSTRING(
-          "(strftime('%s','now','start of month','utc')*1000000)");
-        // To now (tomorrow)
-        sqlFragmentEndTime = NS_LITERAL_CSTRING(
-          "(strftime('%s','now','start of day','+1 day','utc')*1000000)");
-         break;
-       default:
-        if (i == additionalContainers + 6) {
-          // Older than 6 months
-          history->GetAgeInDaysString(6,
-            NS_LITERAL_STRING("finduri-AgeInMonths-isgreater").get(), dateName);
-          // From start of epoch
-          sqlFragmentBeginTime = NS_LITERAL_CSTRING(
-            "(datetime(0, 'unixepoch')*1000000)");
-          // To start of 6 months ago
-          sqlFragmentEndTime = NS_LITERAL_CSTRING(
-            "(strftime('%s','now','start of day','-6 months','utc')*1000000)");
-          break;
-        }
-        PRInt32 MonthIndex = i - additionalContainers;
-        // Previous months' titles are month's name if inside this year,
-        // month's name and year for previous years.
-        PRExplodedTime tm;
-        PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &tm);
-        PRUint16 currentYear = tm.tm_year;
-        tm.tm_month -= MonthIndex;
-        PR_NormalizeTime(&tm, PR_LocalTimeParameters);
-        // tm_month starts from 0 while GetMonthName expects a 1-based index.
-        history->GetMonthName(tm.tm_month+1, dateName);
-
-        // If the container is for a past year, add the year as suffix.
-        if (tm.tm_year < currentYear)
-          dateName.Append(nsPrintfCString(" %d", tm.tm_year));
-
-        // From start of MonthIndex + 1 months ago
-        sqlFragmentBeginTime = NS_LITERAL_CSTRING(
-          "(strftime('%s','now','start of month','-");
-        sqlFragmentBeginTime.AppendInt(MonthIndex);
-        sqlFragmentBeginTime.Append(NS_LITERAL_CSTRING(
-            " months','utc')*1000000)"));
-        // To start of MonthIndex months ago
-        sqlFragmentEndTime = NS_LITERAL_CSTRING(
-          "(strftime('%s','now','start of month','-");
-        sqlFragmentEndTime.AppendInt(MonthIndex - 1);
-        sqlFragmentEndTime.Append(NS_LITERAL_CSTRING(
-            " months','utc')*1000000)"));
+            NS_LITERAL_STRING("finduri-AgeInDays-is-1").get(), dateName);
+        break;
+      default:
+        history->GetAgeInDaysString(i, 
+            NS_LITERAL_STRING("finduri-AgeInDays-is").get(), dateName);
         break;
     }
- 
-     nsPrintfCString dayRange(1024,
-        "SELECT '%s' AS dayTitle, "
-               "%s AS beginTime, "
-               "%s AS endTime "
-         "WHERE EXISTS ( "
-           "SELECT id FROM moz_historyvisits_temp "
-          "WHERE visit_date >= %s "
-            "AND visit_date < %s "
+
+    mAddParams.Put(dateParam, dateName);
+
+    PRInt32 fromDayAgo = -i;
+    PRInt32 toDayAgo = -i + 1;
+
+    nsPrintfCString dayRange(1024,
+      "SELECT * "
+      "FROM ( "
+        "SELECT %d dayOrder, "
+               "'%d' dayRange, "
+               "%s dayTitle, " // This will be bound
+               "%llu beginTime, "
+               "%llu endTime "
+        "WHERE EXISTS ( "
+          "SELECT id FROM moz_historyvisits_temp "
+          "WHERE visit_date >= %llu "
+            "AND visit_date < %llu "
+            "AND visit_type NOT IN (0,%d) "
+            "{QUERY_OPTIONS} "
+          "LIMIT 1 "
+        ") "
+        "OR EXISTS ( "
+          "SELECT * FROM moz_historyvisits "
+          "WHERE visit_date >= %llu "
+            "AND visit_date < %llu "
             "AND visit_type NOT IN (0,%d) "
             "{QUERY_OPTIONS} "
-          "UNION ALL "
-          "SELECT id FROM moz_historyvisits "
-          "WHERE visit_date >= %s "
-            "AND visit_date < %s "
-             "AND visit_type NOT IN (0,%d) "
-             "{QUERY_OPTIONS} "
-           "LIMIT 1 "
-        ") ",
-      dateName.get(),
-      sqlFragmentBeginTime.get(),
-      sqlFragmentEndTime.get(),
-      sqlFragmentBeginTime.get(),
-      sqlFragmentEndTime.get(),
-       nsINavHistoryService::TRANSITION_EMBED,
-      sqlFragmentBeginTime.get(),
-      sqlFragmentEndTime.get(),
-      nsINavHistoryService::TRANSITION_EMBED);
-
-    mQueryString.Append(dayRange);
-
-    if (i < numContainers)
-        mQueryString.Append(NS_LITERAL_CSTRING(" UNION ALL "));
-  }
-
-  mQueryString.Append(NS_LITERAL_CSTRING(") ")); // TOUTER END
+          "LIMIT 1 "
+        ") "
+      "LIMIT 1) TUNION%d UNION ", 
+      i, i, dateParam.get(), 
+      midnight.Get(fromDayAgo),
+      midnight.Get(toDayAgo), 
+      midnight.Get(fromDayAgo),
+      midnight.Get(toDayAgo),
+      nsINavHistoryService::TRANSITION_EMBED,
+      midnight.Get(fromDayAgo),
+      midnight.Get(toDayAgo),
+      nsINavHistoryService::TRANSITION_EMBED,
+      i);
+
+    mQueryString.Append( dayRange );
+  }
+
+  dateParam = nsPrintfCString(":dayTitle%d", MAX_HISTORY_DAYS+1);
+  history->GetAgeInDaysString(MAX_HISTORY_DAYS, 
+    NS_LITERAL_STRING("finduri-AgeInDays-isgreater").get(), dateName);
+
+  mAddParams.Put(dateParam, dateName);
+
+  mQueryString.Append(nsPrintfCString(1024,
+    "SELECT * "
+    "FROM ("
+      "SELECT %d dayOrder, "
+            "'%d+' dayRange, "
+            "%s dayTitle, " // This will be bound
+            "1 beginTime, "
+            "%llu endTime "
+      "WHERE EXISTS ( "
+        "SELECT id FROM moz_historyvisits_temp "
+        "WHERE visit_date < %llu "
+          "AND visit_type NOT IN (0,%d) "
+          "{QUERY_OPTIONS} "
+        "LIMIT 1 "
+      ") "
+      "OR EXISTS ( "
+        "SELECT id FROM moz_historyvisits "
+        "WHERE visit_date < %llu "
+          "AND visit_type NOT IN (0,%d) "
+          "{QUERY_OPTIONS} "
+        "LIMIT 1 "
+      ") "
+      "LIMIT 1) TUNIONLAST "
+    ") TOUTER " // TOUTER END
+    "ORDER BY dayOrder ASC",
+    MAX_HISTORY_DAYS+1,
+    MAX_HISTORY_DAYS+1,
+    dateParam.get(),
+    midnight.Get(-MAX_HISTORY_DAYS),
+    midnight.Get(-MAX_HISTORY_DAYS),
+    nsINavHistoryService::TRANSITION_EMBED,
+    midnight.Get(-MAX_HISTORY_DAYS),
+    nsINavHistoryService::TRANSITION_EMBED
+    ));
 
   return NS_OK;
 }
 
 nsresult
 PlacesSQLQueryBuilder::SelectAsSite()
 {
   nsCAutoString localFiles;
@@ -4193,25 +4173,30 @@ nsNavHistory::GetQueryResults(nsNavHisto
   NS_ENSURE_ARG_POINTER(aOptions);
   NS_ASSERTION(aResults->Count() == 0, "Initial result array must be empty");
   if (! aQueries.Count())
     return NS_ERROR_INVALID_ARG;
 
   nsCString queryString;
   PRBool paramsPresent = PR_FALSE;
   nsNavHistory::StringHash addParams;
-  addParams.Init(1);
+  addParams.Init(MAX_HISTORY_DAYS+1);
   nsresult rv = ConstructQueryString(aQueries, aOptions, queryString, 
                                      paramsPresent, addParams);
   NS_ENSURE_SUCCESS(rv,rv);
 
 #ifdef DEBUG_FRECENCY
   printf("Constructed the query: %s\n", PromiseFlatCString(queryString).get());
 #endif
 
+  // Put this in a transaction. Even though we are only reading, this will
+  // speed up the grouped queries to the annotation service for titles and
+  // full text searching.
+  mozStorageTransaction transaction(mDBConn, PR_FALSE);
+
   // create statement
   nsCOMPtr<mozIStorageStatement> statement;
   rv = mDBConn->CreateStatement(queryString, getter_AddRefs(statement));
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (paramsPresent) {
     // bind parameters
     PRInt32 i;
@@ -6264,17 +6249,17 @@ nsNavHistory::FilterResultSet(nsNavHisto
       // Unescape the URL for search term matching
       nsCAutoString cNodeURL(aSet[nodeIndex]->mURI);
       NS_ConvertUTF8toUTF16 nodeURL(NS_UnescapeURL(cNodeURL));
 
       // Fetch the tags
       mozStorageStatementScoper scoper(mDBGetTags);
       rv = mDBGetTags->BindStringParameter(0, NS_LITERAL_STRING(" "));
       NS_ENSURE_SUCCESS(rv, rv);
-      rv = mDBGetTags->BindInt64Parameter(1, GetTagsFolder());
+      rv = mDBGetTags->BindInt32Parameter(1, GetTagsFolder());
       NS_ENSURE_SUCCESS(rv, rv);
       rv = mDBGetTags->BindUTF8StringParameter(2, aSet[nodeIndex]->mURI);
       NS_ENSURE_SUCCESS(rv, rv);
 
       nsAutoString nodeTags;
       PRBool hasTag = PR_FALSE;
       if (NS_SUCCEEDED(mDBGetTags->ExecuteStep(&hasTag)) && hasTag) {
         rv = mDBGetTags->GetString(0, nodeTags);
@@ -6307,22 +6292,22 @@ nsNavHistory::FilterResultSet(nsNavHisto
         nodeIndex > 0 && aSet[nodeIndex]->mURI == aSet[nodeIndex-1]->mURI)
       continue;
 
     if (appendNode)
       aFiltered->AppendObject(aSet[nodeIndex]);
       
     // stop once we've seen max results
     if (aOptions->MaxResults() > 0 && 
-        (PRUint32)aFiltered->Count() >= aOptions->MaxResults())
+        aFiltered->Count() >= aOptions->MaxResults())
       break;
   }
 
   // de-allocate the matrixes
-  for (PRInt32 i = 0; i < aQueries.Count(); i++) {
+  for (PRUint32 i=0; i < aQueries.Count(); i++) {
     delete terms[i];
     delete includeFolders[i];
     delete excludeFolders[i];
   }
 
   return NS_OK;
 }
 
@@ -6688,34 +6673,32 @@ nsNavHistory::TitleForDomain(const nsCSt
     return;
   }
 
   // use the localized one instead
   GetStringFromName(NS_LITERAL_STRING("localhost").get(), aTitle);
 }
 
 void
-nsNavHistory::GetAgeInDaysString(PRInt32 aInt, const PRUnichar *aName,
-                                 nsACString& aResult)
+nsNavHistory::GetAgeInDaysString(PRInt32 aInt, const PRUnichar *aName, nsACString& aResult)
 {
   nsIStringBundle *bundle = GetBundle();
   if (!bundle)
     aResult.Truncate(0);
-  else {
-    nsAutoString intString;
-    intString.AppendInt(aInt);
-    const PRUnichar* strings[1] = { intString.get() };
-    nsXPIDLString value;
-    nsresult rv = bundle->FormatStringFromName(aName, strings,
-                                               1, getter_Copies(value));
-    if (NS_SUCCEEDED(rv))
-      CopyUTF16toUTF8(value, aResult);
-    else
-      aResult.Truncate(0);
-  }
+
+  nsAutoString intString;
+  intString.AppendInt(aInt);
+  const PRUnichar* strings[1] = { intString.get() };
+  nsXPIDLString value;
+  nsresult rv = bundle->FormatStringFromName(aName, strings,
+                                             1, getter_Copies(value));
+  if (NS_SUCCEEDED(rv))
+    CopyUTF16toUTF8(value, aResult);
+  else
+    aResult.Truncate(0);
 }
 
 void
 nsNavHistory::GetStringFromName(const PRUnichar *aName, nsACString& aResult)
 {
   nsIStringBundle *bundle = GetBundle();
   if (!bundle)
     aResult.Truncate(0);
@@ -6723,34 +6706,16 @@ nsNavHistory::GetStringFromName(const PR
   nsXPIDLString value;
   nsresult rv = bundle->GetStringFromName(aName, getter_Copies(value));
   if (NS_SUCCEEDED(rv))
     CopyUTF16toUTF8(value, aResult);
   else
     aResult.Truncate(0);
 }
 
-void
-nsNavHistory::GetMonthName(PRInt32 aIndex, nsACString& aResult)
-{
-  nsIStringBundle *bundle = GetDateFormatBundle();
-  if (!bundle)
-    aResult.Truncate(0);
-  else {
-    nsCString name = nsPrintfCString("month.%d.name", aIndex);
-    nsXPIDLString value;
-    nsresult rv = bundle->GetStringFromName(NS_ConvertUTF8toUTF16(name).get(),
-                                            getter_Copies(value));
-    if (NS_SUCCEEDED(rv))
-      CopyUTF16toUTF8(value, aResult);
-    else
-      aResult.Truncate(0);
-  }
-}
-
 // nsNavHistory::SetPageTitleInternal
 //
 //    Called to set the title for the given URI. Used as a
 //    backend for SetTitle.
 //
 //    Will fail for pages that are not in the DB. To clear the corresponding
 //    title, use aTitle.SetIsVoid(). Sending an empty string will save an
 //    empty string instead of clearing it.
@@ -7128,17 +7093,17 @@ inline PRBool isQueryWhitespace(PRUnicha
 {
   return ch == ' ';
 }
 
 void ParseSearchTermsFromQueries(const nsCOMArray<nsNavHistoryQuery>& aQueries,
                                  nsTArray<nsTArray<nsString>*>* aTerms)
 {
   PRInt32 lastBegin = -1;
-  for (PRInt32 i = 0; i < aQueries.Count(); i++) {
+  for (PRUint32 i=0; i < aQueries.Count(); i++) {
     nsTArray<nsString> *queryTerms = new nsTArray<nsString>();
     PRBool hasSearchTerms;
     if (NS_SUCCEEDED(aQueries[i]->GetHasSearchTerms(&hasSearchTerms)) &&
         hasSearchTerms) {
       const nsString& searchTerms = aQueries[i]->SearchTerms();
       for (PRUint32 j = 0; j < searchTerms.Length(); j++) {
         if (isQueryWhitespace(searchTerms[j]) ||
             searchTerms[j] == '"') {
@@ -7364,17 +7329,17 @@ nsNavHistory::CalculateFrecencyInternal(
           weight = mSecondBucketWeight;
         else if (ageInDays <= mThirdBucketCutoffInDays)
           weight = mThirdBucketWeight;
         else if (ageInDays <= mFourthBucketCutoffInDays) 
           weight = mFourthBucketWeight;
         else
           weight = mDefaultWeight;
 
-        pointsForSampledVisits += (float)(weight * (bonus / 100.0));
+        pointsForSampledVisits += weight * (bonus / 100.0);
       }
     }
 
     if (numSampledVisits) {
       // fix for bug #412219
       if (!pointsForSampledVisits) {
         // For URIs with zero points in the sampled recent visits
         // but "browsing" type visits outside the sampling range, set
@@ -7562,43 +7527,30 @@ nsNavHistory::GetCollation()
   NS_ENSURE_SUCCESS(rv, nsnull);
 
   return mCollation;
 }
 
 nsIStringBundle *
 nsNavHistory::GetBundle()
 {
-  if (!mBundle) {
-    nsCOMPtr<nsIStringBundleService> bundleService =
-      do_GetService(NS_STRINGBUNDLE_CONTRACTID);
-    NS_ENSURE_TRUE(bundleService, nsnull);
-    nsresult rv = bundleService->CreateBundle(
-        "chrome://places/locale/places.properties",
-        getter_AddRefs(mBundle));
-    NS_ENSURE_SUCCESS(rv, nsnull);
-  }
+  if (mBundle)
+    return mBundle;
+
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    do_GetService(NS_STRINGBUNDLE_CONTRACTID);
+  NS_ENSURE_TRUE(bundleService, nsnull);
+  nsresult rv = bundleService->CreateBundle(
+      "chrome://places/locale/places.properties",
+      getter_AddRefs(mBundle));
+  NS_ENSURE_SUCCESS(rv, nsnull);
+
   return mBundle;
 }
 
-nsIStringBundle *
-nsNavHistory::GetDateFormatBundle()
-{
-  if (!mDateFormatBundle) {
-    nsCOMPtr<nsIStringBundleService> bundleService =
-      do_GetService(NS_STRINGBUNDLE_CONTRACTID);
-    NS_ENSURE_TRUE(bundleService, nsnull);
-    nsresult rv = bundleService->CreateBundle(
-        "chrome://global/locale/dateFormat.properties",
-        getter_AddRefs(mDateFormatBundle));
-    NS_ENSURE_SUCCESS(rv, nsnull);
-  }
-  return mDateFormatBundle;
-}
-
 mozIStorageStatement *
 nsNavHistory::GetDBVisitToVisitResult()
 {
   if (mDBVisitToVisitResult)
     return mDBVisitToVisitResult;
 
   // mDBVisitToVisitResult, should match kGetInfoIndex_* (see GetQueryResults)
   // We are not checking for duplicated ids into the unified table
--- a/toolkit/components/places/src/nsNavHistory.h
+++ b/toolkit/components/places/src/nsNavHistory.h
@@ -57,16 +57,17 @@
 #include "nsIAutoCompleteInput.h"
 #include "nsIAutoCompletePopup.h"
 #include "nsIAutoCompleteSearch.h"
 #include "nsIAutoCompleteResult.h"
 #include "nsIAutoCompleteSimpleResult.h"
 #endif
 #include "nsIBrowserHistory.h"
 #include "nsICollation.h"
+#include "nsIDateTimeFormat.h"
 #include "nsIGlobalHistory.h"
 #include "nsIGlobalHistory3.h"
 #include "nsIDownloadHistory.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsServiceManagerUtils.h"
@@ -236,22 +237,20 @@ public:
     return mDBConn;
   }
 
   /**
    * These functions return non-owning references to the locale-specific
    * objects for places components.
    */
   nsIStringBundle* GetBundle();
-  nsIStringBundle* GetDateFormatBundle();
   nsICollation* GetCollation();
   void GetStringFromName(const PRUnichar* aName, nsACString& aResult);
   void GetAgeInDaysString(PRInt32 aInt, const PRUnichar *aName,
                           nsACString& aResult);
-  void GetMonthName(PRInt32 aIndex, nsACString& aResult);
 
   // returns true if history has been disabled
   PRBool IsHistoryDisabled() { return mExpireDaysMax == 0 || InPrivateBrowsingMode(); }
 
   // get the statement for selecting a history row by URL
   mozIStorageStatement* DBGetURLPageInfo() { return mDBGetURLPageInfo; }
 
   // Constants for the columns returned by the above statement.
@@ -628,17 +627,16 @@ protected:
   nsMaybeWeakPtrArray<nsINavHistoryObserver> mObservers;
 
   // effective tld service
   nsCOMPtr<nsIEffectiveTLDService> mTLDService;
   nsCOMPtr<nsIIDNService>          mIDNService;
 
   // localization
   nsCOMPtr<nsIStringBundle> mBundle;
-  nsCOMPtr<nsIStringBundle> mDateFormatBundle;
   nsCOMPtr<nsICollation> mCollation;
 
   // annotation service : MAY BE NULL!
   //nsCOMPtr<mozIAnnotationService> mAnnotationService;
 
   // recent events
   typedef nsDataHashtable<nsCStringHashKey, PRInt64> RecentEventHash;
   RecentEventHash mRecentTyped;
--- a/toolkit/components/places/src/nsNavHistoryResult.cpp
+++ b/toolkit/components/places/src/nsNavHistoryResult.cpp
@@ -4278,23 +4278,117 @@ nsNavHistoryResult::OnVisit(nsIURI* aURI
                             PRUint32 aTransitionType, PRUint32* aAdded)
 {
   PRUint32 added = 0;
 
   ENUMERATE_HISTORY_OBSERVERS(OnVisit(aURI, aVisitId, aTime, aSessionId,
                                       aReferringId, aTransitionType, &added));
 
   if (!added && mRootNode->mExpanded) {
+    nsresult rv;
+
     // None of registered query observers has accepted our URI, this means,
     // that a matching query either was not expanded or it does not exist.
+    // If it just was not expanded, we can ignore it, but if it did not
+    // exist, we have to add the query to the right place.
     PRUint32 resultType = mRootNode->mOptions->ResultType();
+    nsNavHistoryResultNode * siteRoot = mRootNode;
+    nsCAutoString dateRange;
+
+    // For day based queries we just check whether the first item is Today,
     if (resultType == nsINavHistoryQueryOptions::RESULTS_AS_DATE_QUERY ||
-        resultType == nsINavHistoryQueryOptions::RESULTS_AS_DATE_SITE_QUERY ||
-        resultType == nsINavHistoryQueryOptions::RESULTS_AS_SITE_QUERY)
-      mRootNode->GetAsQuery()->Refresh();
+        resultType == nsINavHistoryQueryOptions::RESULTS_AS_DATE_SITE_QUERY) {
+      nsNavHistory* history = nsNavHistory::GetHistoryService();
+      NS_ENSURE_TRUE(history, 0);
+
+      // code borrowed from xpfe/components/history/src/nsGlobalHistory.cpp
+      // pass in a pre-normalized now and a date, and we'll find
+      // the difference since midnight on each of the days.
+      //
+      // USECS_PER_DAY == PR_USEC_PER_SEC * 60 * 60 * 24;
+      static const PRInt64 USECS_PER_DAY = LL_INIT(20, 500654080);
+
+      dateRange = nsPrintfCString(255,
+        "&beginTime=%lld&endTime=%lld",
+        history->NormalizeTime(
+          nsINavHistoryQuery::TIME_RELATIVE_TODAY, 0),
+        history->NormalizeTime(
+          nsINavHistoryQuery::TIME_RELATIVE_TODAY, USECS_PER_DAY));
+
+      PRBool todayIsMissing = PR_FALSE;
+      PRUint32 childCount;
+      rv = mRootNode->GetChildCount(&childCount);
+      NS_ENSURE_SUCCESS(rv, rv);
+
+      nsCAutoString todayLabel;
+      history->GetStringFromName(
+        NS_LITERAL_STRING("finduri-AgeInDays-is-0").get(), todayLabel);
+
+      if (!childCount) {
+        todayIsMissing = PR_TRUE;
+      } else {
+        nsCOMPtr<nsINavHistoryResultNode> firstChild;
+        rv = mRootNode->GetChild(0, getter_AddRefs(firstChild));
+        NS_ENSURE_SUCCESS(rv, rv);
+
+        nsCAutoString title;
+        rv = firstChild->GetTitle( title);
+        NS_ENSURE_SUCCESS(rv, rv);
+
+        if (todayLabel.Equals(title)) {
+          siteRoot = static_cast<nsNavHistoryResultNode *>(firstChild.get());
+        } else {
+          todayIsMissing = PR_TRUE;
+        }
+      }
+
+      if (todayIsMissing) { // Add "Today"
+        nsCAutoString queryUri;
+        queryUri = nsPrintfCString(255,
+          "place:type=%ld&sort=%ld%s",
+          resultType == nsINavHistoryQueryOptions::RESULTS_AS_DATE_QUERY
+            ?nsINavHistoryQueryOptions::RESULTS_AS_URI
+            :nsINavHistoryQueryOptions::RESULTS_AS_SITE_QUERY,
+          nsINavHistoryQueryOptions::SORT_BY_TITLE_ASCENDING,
+          dateRange.get());
+
+        nsRefPtr<nsNavHistoryQueryResultNode> todayNode;
+        todayNode = new nsNavHistoryQueryResultNode(todayLabel, 
+                                                    EmptyCString(), queryUri);
+        rv = mRootNode->InsertChildAt( todayNode, 0);
+        NS_ENSURE_SUCCESS(rv, rv);
+      }
+
+      // "Today" was missing or we had day query
+      if (resultType == nsINavHistoryQueryOptions::RESULTS_AS_DATE_QUERY || 
+          todayIsMissing)
+        return NS_OK; // No more processing necessary
+    }
+
+    if (siteRoot->IsQuery() && siteRoot->GetAsQuery()->mContentsValid &&
+         (resultType == nsINavHistoryQueryOptions::RESULTS_AS_DATE_SITE_QUERY ||
+          resultType == nsINavHistoryQueryOptions::RESULTS_AS_SITE_QUERY)) {
+      nsCAutoString host;
+      rv = aURI->GetAsciiHost(host);
+      NS_ENSURE_SUCCESS(rv, rv);
+
+      nsCAutoString queryUri;
+      queryUri = nsPrintfCString(255,
+        "place:type=%ld&sort=%ld&domain=%s&domainIsHost=true%s",
+        nsINavHistoryQueryOptions::RESULTS_AS_URI,
+        nsINavHistoryQueryOptions::SORT_BY_TITLE_ASCENDING,
+        host.get(),
+        dateRange.get());
+
+      nsRefPtr<nsNavHistoryQueryResultNode> siteNode;
+      siteNode = new nsNavHistoryQueryResultNode(host, EmptyCString(), queryUri);
+      rv = siteRoot->GetAsContainer()->InsertSortedChild(
+               siteNode, PR_FALSE, PR_TRUE/*Ignore duplicates*/);
+      NS_ENSURE_SUCCESS(rv, rv);
+    }
   }
 
   return NS_OK;
 }
 
 
 // nsNavHistoryResult::OnTitleChanged (nsINavHistoryObserver)
 
--- a/toolkit/components/places/tests/unit/test_history_sidebar.js
+++ b/toolkit/components/places/tests/unit/test_history_sidebar.js
@@ -32,241 +32,237 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 // Get history service
-var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
-         getService(Ci.nsINavHistoryService);
-var bh = hs.QueryInterface(Ci.nsIBrowserHistory);
-var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
-         getService(Ci.nsINavBookmarksService);
-var ps = Cc["@mozilla.org/preferences-service;1"].
-         getService(Ci.nsIPrefBranch);
+try {
+  var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsINavHistoryService);
+} catch(ex) {
+  do_throw("Could not get history service\n");
+} 
 
 /**
  * Adds a test URI visit to the database, and checks for a valid place ID.
  *
  * @param aURI
  *        The URI to add a visit for.
  * @param aReferrer
  *        The referring URI for the given URI.  This can be null.
  * @returns the place id for aURI.
  */
-function add_normalized_visit(aURI, aTime, aDayOffset) {
-  var dateObj = new Date(aTime);
-  // Normalize to midnight
-  dateObj.setHours(0);
-  dateObj.setMinutes(0);
-  dateObj.setSeconds(0);
-  dateObj.setMilliseconds(0);
-  // Substract aDayOffset
-  var PRTimeWithOffset = (dateObj.getTime() + aDayOffset * 86400000) * 1000;
-  print("Adding visit to " + aURI.spec + " at " + new Date(PRTimeWithOffset/1000));
-  var visitId = hs.addVisit(aURI,
-                            PRTimeWithOffset,
-                            null,
-                            hs.TRANSITION_TYPED, // user typed in URL bar
-                            false, // not redirect
-                            0);
-  do_check_true(visitId > 0);
-  return visitId;
+function add_visit(aURI, aDayOffset) {
+  var placeID = histsvc.addVisit(aURI,
+                                 (Date.now() + aDayOffset*86400000) * 1000,
+                                 null,
+                                 histsvc.TRANSITION_TYPED, // user typed in URL bar
+                                 false, // not redirect
+                                 0);
+  do_check_true(placeID > 0);
+  return placeID;
 }
 
-var nowObj = new Date();
-// This test relies on en-US locale
-// Offset is number of days
-var containers = [
-  { label: "Today",               offset: 0                     },
-  { label: "Yesterday",           offset: -1                    },
-  { label: "Last 7 days",         offset: -3                    },
-  { label: "This month",          offset: -8                    },
-  { label: "",                    offset: -nowObj.getDate()-1   },
-  { label: "Older than 6 months", offset: -nowObj.getDate()-186 },
+// Can I rely on en-US locales during units tests?
+var dayLabels = 
+[ 
+  "Today", 
+  "Yesterday", 
+  "2 days ago", 
+  "3 days ago",
+  "4 days ago",
+  "5 days ago",
+  "6 days ago",
+  "Older than 6 days"
 ];
 
-/**
- * Fills history and checks containers' labels.
- */
+// Fills history and checks if date labels are correct for partially filled history
 function fill_history() {
-  print("\n\n*** TEST Fill History\n");
-  // We can't use "now" because our hardcoded offsets would be invalid for some
-  // date.  So we hardcode a date.
-  for (var i = 0; i < containers.length; i++) {
-    var container = containers[i];
+  const checkOlderOffset = 4;
+
+  // add visits for the older days
+  for (var i=checkOlderOffset; i<dayLabels.length; i++)
+  {
     var testURI = uri("http://mirror"+i+".mozilla.com/b");
-    add_normalized_visit(testURI, nowObj.getTime(), container.offset);
+    add_visit(testURI, -i);
     var testURI = uri("http://mirror"+i+".mozilla.com/a");
-    add_normalized_visit(testURI, nowObj.getTime(), container.offset);
+    add_visit(testURI, -i);
     var testURI = uri("http://mirror"+i+".google.com/b");
-    add_normalized_visit(testURI, nowObj.getTime(), container.offset);
+    add_visit(testURI, -i);
     var testURI = uri("http://mirror"+i+".google.com/a");
-    add_normalized_visit(testURI, nowObj.getTime(), container.offset);
+    add_visit(testURI, -i);
   }
 
-  var options = hs.getNewQueryOptions();
+  var options = histsvc.getNewQueryOptions();
   options.resultType = options.RESULTS_AS_DATE_SITE_QUERY;
-  var query = hs.getNewQuery();
-
-  var result = hs.executeQuery(query, options);
+  var query = histsvc.getNewQuery();
+  var result = histsvc.executeQuery(query, options);
   var root = result.root;
   root.containerOpen = true;
+  do_check_eq(root.childCount, dayLabels.length - checkOlderOffset);
 
-  var cc = root.childCount;
-  print("Found containers:");
-  for (var i = 0; i < cc; i++) {
-    var container = containers[i];
-    var node = root.getChild(i);
-    print(node.title);
-    if (container.label)
-      do_check_eq(node.title, container.label);
+  for (var i=checkOlderOffset; i<dayLabels.length; i++)
+  {
+    var node = root.getChild(i-checkOlderOffset);
+    do_check_eq(node.title, dayLabels[i]);
   }
-  do_check_eq(cc, containers.length);
+
+
+  // When I close the root container here, it would generate a warning
+  // on next call to addVisit.
+  root.containerOpen = false;
+  
+  // add visits for the most recent days
+  for (var i=0; i<checkOlderOffset; i++)
+  {
+    var testURI = uri("http://mirror"+i+".mozilla.com/d");
+    add_visit(testURI, -i);
+    var testURI = uri("http://mirror"+i+".mozilla.com/c");
+    add_visit(testURI, -i);
+    var testURI = uri("http://mirror"+i+".google.com/d");
+    add_visit(testURI, -i);
+    var testURI = uri("http://mirror"+i+".google.com/c");
+    add_visit(testURI, -i);
+  }
+
   root.containerOpen = false;
 }
 
-/**
- * Queries history grouped by date and site, checking containers' labels and
- * children.
- */
 function test_RESULTS_AS_DATE_SITE_QUERY() {
-  print("\n\n*** TEST RESULTS_AS_DATE_SITE_QUERY\n");
-  var options = hs.getNewQueryOptions();
+
+  var options = histsvc.getNewQueryOptions();
   options.resultType = options.RESULTS_AS_DATE_SITE_QUERY;
-  var query = hs.getNewQuery();
-  var result = hs.executeQuery(query, options);
+  var query = histsvc.getNewQuery();
+  var result = histsvc.executeQuery(query, options);
   var root = result.root;
   root.containerOpen = true;
+  do_check_eq(root.childCount, dayLabels.length);
+
+  // Now we check whether we have all the labels
+  for (var i=0; i<dayLabels.length; i++)
+  {
+    var node = root.getChild(i);
+    do_check_eq(node.title, dayLabels[i]);
+  }
 
   // Check one of the days
-  var dayNode = root.getChild(0)
-                    .QueryInterface(Ci.nsINavHistoryContainerResultNode);
+  var dayNode = root.getChild(4).QueryInterface(Ci.nsINavHistoryContainerResultNode);
   dayNode.containerOpen = true;
   do_check_eq(dayNode.childCount, 2);
 
   // Items should be sorted by host
-  var site1 = dayNode.getChild(0)
-                     .QueryInterface(Ci.nsINavHistoryContainerResultNode);
-  do_check_eq(site1.title, "mirror0.google.com");
+  var site1 = dayNode.getChild(0).QueryInterface(Ci.nsINavHistoryContainerResultNode);
+  do_check_eq(site1.title, "mirror4.google.com");
 
-  var site2 = dayNode.getChild(1)
-                     .QueryInterface(Ci.nsINavHistoryContainerResultNode);
-  do_check_eq(site2.title, "mirror0.mozilla.com");
+  var site2 = dayNode.getChild(1).QueryInterface(Ci.nsINavHistoryContainerResultNode);
+  do_check_eq(site2.title, "mirror4.mozilla.com");
 
   site1.containerOpen = true;
   do_check_eq(site1.childCount, 2);
 
   // Inside of host sites are sorted by title
   var site1visit = site1.getChild(0);
-  do_check_eq(site1visit.uri, "http://mirror0.google.com/a");
+  do_check_eq(site1visit.uri, "http://mirror4.google.com/a");
 
   site1.containerOpen = false;
   dayNode.containerOpen = false;
   root.containerOpen = false;
+
 }
 
-/**
- * Queries history grouped by date, checking containers' labels and children.
- */
 function test_RESULTS_AS_DATE_QUERY() {
-  print("\n\n*** TEST RESULTS_AS_DATE_QUERY\n");
-  var options = hs.getNewQueryOptions();
+
+  var options = histsvc.getNewQueryOptions();
   options.resultType = options.RESULTS_AS_DATE_QUERY;
-  var query = hs.getNewQuery();
-  var result = hs.executeQuery(query, options);
+  var query = histsvc.getNewQuery();
+  var result = histsvc.executeQuery(query, options);
   var root = result.root;
   root.containerOpen = true;
+  do_check_eq(root.childCount, dayLabels.length);
 
-  var cc = root.childCount;
-  do_check_eq(cc, containers.length);
-  print("Found containers:");
-  for (var i = 0; i < cc; i++) {
-    var container = containers[i];
+  // Now we check whether we have all the labels
+  for (var i=0; i<dayLabels.length; i++)
+  {
     var node = root.getChild(i);
-    print(node.title);
-    if (container.label)
-      do_check_eq(node.title, container.label);
+    do_check_eq(node.title, dayLabels[i]);
   }
 
   // Check one of the days
-  var dayNode = root.getChild(0)
-                    .QueryInterface(Ci.nsINavHistoryContainerResultNode);
+  var dayNode = root.getChild(3).QueryInterface(Ci.nsINavHistoryContainerResultNode);
   dayNode.containerOpen = true;
   do_check_eq(dayNode.childCount, 4);
+  do_check_eq(dayNode.title, "3 days ago");
 
-  // Items should be sorted by title
+  // Items should be sorted title
   var visit1 = dayNode.getChild(0);
-  do_check_eq(visit1.uri, "http://mirror0.google.com/a");
+  do_check_eq(visit1.uri, "http://mirror3.google.com/c");
 
   var visit2 = dayNode.getChild(3);
-  do_check_eq(visit2.uri, "http://mirror0.mozilla.com/b");
+  do_check_eq(visit2.uri, "http://mirror3.mozilla.com/d");
 
   dayNode.containerOpen = false;
   root.containerOpen = false;
 }
 
-/**
- * Queries history grouped by site, checking containers' labels and children.
- */
 function test_RESULTS_AS_SITE_QUERY() {
-  print("\n\n*** TEST RESULTS_AS_SITE_QUERY\n");
+
   // add a bookmark with a domain not in the set of visits in the db
-  bs.insertBookmark(bs.toolbarFolder, uri("http://foobar"),
-                    bs.DEFAULT_INDEX, "");
+  var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
+              getService(Ci.nsINavBookmarksService);
+  bmsvc.insertBookmark(bmsvc.toolbarFolder, uri("http://foobar"),
+                       bmsvc.DEFAULT_INDEX, "");
 
-  var options = hs.getNewQueryOptions();
+  var options = histsvc.getNewQueryOptions();
   options.resultType = options.RESULTS_AS_SITE_QUERY;
-  var query = hs.getNewQuery();
-  var result = hs.executeQuery(query, options);
+  var query = histsvc.getNewQuery();
+  var result = histsvc.executeQuery(query, options);
   var root = result.root;
   root.containerOpen = true;
-  do_check_eq(root.childCount, containers.length * 2);
+  do_check_eq(root.childCount, dayLabels.length*2);
 
-/* Expected results:
+  // We include this here, so that maintainer knows what is the expected result
+  var expectedResult = 
+  [
     "mirror0.google.com",
     "mirror0.mozilla.com",
     "mirror1.google.com",
     "mirror1.mozilla.com",
     "mirror2.google.com",
     "mirror2.mozilla.com",
-    "mirror3.google.com",  <== We check for this site (index 6)
+    "mirror3.google.com",
     "mirror3.mozilla.com",
     "mirror4.google.com",
     "mirror4.mozilla.com",
-    "mirror5.google.com",
+    "mirror5.google.com",   // We check for this site
     "mirror5.mozilla.com",
-    ...
-*/
+    "mirror6.google.com",
+    "mirror6.mozilla.com",
+    "mirror7.google.com",
+    "mirror7.mozilla.com"
+  ];
 
   // Items should be sorted by host
-  var siteNode = root.getChild(6)
-                     .QueryInterface(Ci.nsINavHistoryContainerResultNode);
-  do_check_eq(siteNode.title, "mirror3.google.com");
+  var siteNode = root.getChild(dayLabels.length+2).QueryInterface(Ci.nsINavHistoryContainerResultNode);
+  do_check_eq(siteNode.title,  expectedResult[dayLabels.length+2] );
 
   siteNode.containerOpen = true;
   do_check_eq(siteNode.childCount, 2);
 
   // Inside of host sites are sorted by title
-  var visitNode = siteNode.getChild(0);
-  do_check_eq(visitNode.uri, "http://mirror3.google.com/a");
+  var visit = siteNode.getChild(0);
+  do_check_eq(visit.uri, "http://mirror5.google.com/a");
 
   siteNode.containerOpen = false;
   root.containerOpen = false;
 }
 
 // main
 function run_test() {
-  // Increase history limit to 1 year
-  ps.setIntPref("browser.history_expire_days", 365);
-
-  // Cleanup.
-  bh.removeAllPages();
 
   fill_history();
   test_RESULTS_AS_DATE_SITE_QUERY();
   test_RESULTS_AS_DATE_QUERY();
   test_RESULTS_AS_SITE_QUERY();
 
   // The remaining views are
   //   RESULTS_AS_URI + SORT_BY_VISITCOUNT_DESCENDING 
deleted file mode 100644
--- a/toolkit/locales/en-US/chrome/global/dateFormat.properties
+++ /dev/null
@@ -1,92 +0,0 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is OEone Calendar Code, released October 31st, 2001.
-#
-# The Initial Developer of the Original Code is
-# OEone Corporation.
-# Portions created by OEone Corporation are Copyright (C) 2001
-# OEone Corporation. All Rights Reserved.
-#
-# Contributor(s):
-#   Garth Smedley <garths@oeone.com>
-#   Martin Schroeder <mschroeder@mozilla.x-home.org>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-month.1.Mmm=Jan
-month.2.Mmm=Feb
-month.3.Mmm=Mar
-month.4.Mmm=Apr
-month.5.Mmm=May
-month.6.Mmm=Jun
-month.7.Mmm=Jul
-month.8.Mmm=Aug
-month.9.Mmm=Sep
-month.10.Mmm=Oct
-month.11.Mmm=Nov
-month.12.Mmm=Dec
-
-month.1.name=January
-month.2.name=February
-month.3.name=March
-month.4.name=April
-month.5.name=May
-month.6.name=June
-month.7.name=July
-month.8.name=August
-month.9.name=September
-month.10.name=October
-month.11.name=November
-month.12.name=December
-
-day.1.name=Sunday
-day.2.name=Monday
-day.3.name=Tuesday
-day.4.name=Wednesday
-day.5.name=Thursday
-day.6.name=Friday
-day.7.name=Saturday
-
-day.1.Mmm=Sun
-day.2.Mmm=Mon
-day.3.Mmm=Tue
-day.4.Mmm=Wed
-day.5.Mmm=Thu
-day.6.Mmm=Fri
-day.7.Mmm=Sat
-
-day.1.short=Su
-day.2.short=Mo
-day.3.short=Tu
-day.4.short=We
-day.5.short=Th
-day.6.short=Fr
-day.7.short=Sa
-
-noon=Noon
-midnight=Midnight
-
-AllDay=All Day
--- a/toolkit/locales/en-US/chrome/places/places.properties
+++ b/toolkit/locales/en-US/chrome/places/places.properties
@@ -1,25 +1,18 @@
 BookmarksMenuFolderTitle=Bookmarks Menu
 BookmarksToolbarFolderTitle=Bookmarks Toolbar
 UnsortedBookmarksFolderTitle=Unsorted Bookmarks
 TagsFolderTitle=Tags
 
-# LOCALIZATION NOTE (dateName):
-# These are used to generate history containers when history is grouped by date
 finduri-AgeInDays-is-0=Today
 finduri-AgeInDays-is-1=Yesterday
 finduri-AgeInDays-is=%S days ago
-finduri-AgeInDays-last-is=Last %S days
 finduri-AgeInDays-isgreater=Older than %S days
-finduri-AgeInMonths-is-0=This month
-finduri-AgeInMonths-isgreater=Older than %S months
 
-# LOCALIZATION NOTE (localFiles):
-# This is used to generate local files container when history is grouped by site
 localhost=(local files)
 
 # LOCALIZATION NOTE (bookmarksArchiveFilename):
 # Do not change this string! It's used only to
 # detect older localized bookmark archives from
 # before bug 445704 was fixed. It will be removed
 # in a subsequent release.
 bookmarksArchiveFilename=bookmarks-%S.json
--- a/toolkit/locales/jar.mn
+++ b/toolkit/locales/jar.mn
@@ -13,17 +13,16 @@
 + locale/@AB_CD@/global/config.properties               (%chrome/global/config.properties)
 * locale/@AB_CD@/global/console.dtd                     (%chrome/global/console.dtd)
 + locale/@AB_CD@/global/console.properties              (%chrome/global/console.properties)
 * locale/@AB_CD@/global/contentAreaCommands.properties  (%chrome/global/contentAreaCommands.properties)
 * locale/@AB_CD@/global/customizeCharset.dtd            (%chrome/global/customizeCharset.dtd)
 + locale/@AB_CD@/global/customizeToolbar.dtd            (%chrome/global/customizeToolbar.dtd)
 + locale/@AB_CD@/global/customizeToolbar.properties     (%chrome/global/customizeToolbar.properties)
 + locale/@AB_CD@/global/datetimepicker.dtd              (%chrome/global/datetimepicker.dtd)
-  locale/@AB_CD@/global/dateFormat.properties           (%chrome/global/dateFormat.properties)
 * locale/@AB_CD@/global/dialogOverlay.dtd               (%chrome/global/dialogOverlay.dtd)
   locale/@AB_CD@/global/downloadProgress.properties     (%chrome/global/downloadProgress.properties)
 + locale/@AB_CD@/global/editMenuOverlay.dtd             (%chrome/global/editMenuOverlay.dtd)
   locale/@AB_CD@/global/filefield.properties            (%chrome/global/filefield.properties)
   locale/@AB_CD@/global/filepicker.dtd                  (%chrome/global/filepicker.dtd)
   locale/@AB_CD@/global/filepicker.properties           (%chrome/global/filepicker.properties)
   locale/@AB_CD@/global/findbar.dtd                     (%chrome/global/findbar.dtd)
   locale/@AB_CD@/global/findbar.properties              (%chrome/global/findbar.properties)