Bug 766799 - Notify hidden visits to history observers.

Redirect sources and framed visits are considered hidden and thus not shown in
common UI history queries.  So far were not even notified, but the right thing
to do is to let the observer handle them based on its needs.
r=Mano sr=Mossop
This commit is contained in:
Marco Bonardo 2012-12-20 23:45:00 +01:00
Родитель f882bcd20b
Коммит 81c076fba4
12 изменённых файлов: 141 добавлений и 70 удалений

Просмотреть файл

@ -2327,7 +2327,7 @@ NS_IMETHODIMP
nsDownloadManager::OnVisit(nsIURI *aURI, int64_t aVisitID, PRTime aTime,
int64_t aSessionID, int64_t aReferringID,
uint32_t aTransitionType, const nsACString& aGUID,
uint32_t *aAdded)
bool aHidden)
{
return NS_OK;
}

Просмотреть файл

@ -458,14 +458,13 @@ public:
nsCOMPtr<nsIURI> uri;
(void)NS_NewURI(getter_AddRefs(uri), mPlace.spec);
// Notify nsNavHistory observers of visit, but only for certain types of
// visits to maintain consistency with nsNavHistory::GetQueryResults.
if (!mPlace.hidden &&
mPlace.transitionType != nsINavHistoryService::TRANSITION_EMBED &&
mPlace.transitionType != nsINavHistoryService::TRANSITION_FRAMED_LINK) {
// Notify the visit. Note that TRANSITION_EMBED visits are never added
// to the database, thus cannot be queried and we don't notify them.
if (mPlace.transitionType != nsINavHistoryService::TRANSITION_EMBED) {
navHistory->NotifyOnVisit(uri, mPlace.visitId, mPlace.visitTime,
mPlace.sessionId, mReferrer.visitId,
mPlace.transitionType, mPlace.guid);
mPlace.transitionType, mPlace.guid,
mPlace.hidden);
}
nsCOMPtr<nsIObserverService> obsService =

Просмотреть файл

@ -650,7 +650,7 @@ interface nsINavHistoryResult : nsISupports
* DANGER! If you are in the middle of a batch transaction, there may be a
* database transaction active. You can still access the DB, but be careful.
*/
[scriptable, uuid(c837f6ba-6ad7-4810-a425-8ce29e05d17e)]
[scriptable, uuid(eb264079-8766-4e66-b9bf-2c8b586c74d3)]
interface nsINavHistoryObserver : nsISupports
{
/**
@ -680,10 +680,7 @@ interface nsINavHistoryObserver : nsISupports
* @param aReferringID The ID of the visit the user came from. 0 if empty.
* @param aTransitionType One of nsINavHistory.TRANSITION_*
* @param aGUID The unique ID associated with the page.
* @param aAdded Incremented by query nodes when the visited uri
* belongs to them. If no such query exists, the
* history result creates a new query node dynamically.
* It is used in places views only and can be ignored.
* @param aHidden Whether the visited page is marked as hidden.
*/
void onVisit(in nsIURI aURI,
in long long aVisitID,
@ -692,7 +689,7 @@ interface nsINavHistoryObserver : nsISupports
in long long aReferringID,
in unsigned long aTransitionType,
in ACString aGUID,
out unsigned long aAdded);
in boolean aHidden);
/**
* Called whenever either the "real" title or the custom title of the page

Просмотреть файл

@ -50,10 +50,10 @@
using namespace mozilla;
// These columns sit to the right of the kGetInfoIndex_* columns.
const int32_t nsNavBookmarks::kGetChildrenIndex_Position = 14;
const int32_t nsNavBookmarks::kGetChildrenIndex_Type = 15;
const int32_t nsNavBookmarks::kGetChildrenIndex_PlaceID = 16;
const int32_t nsNavBookmarks::kGetChildrenIndex_Guid = 17;
const int32_t nsNavBookmarks::kGetChildrenIndex_Position = 15;
const int32_t nsNavBookmarks::kGetChildrenIndex_Type = 16;
const int32_t nsNavBookmarks::kGetChildrenIndex_PlaceID = 17;
const int32_t nsNavBookmarks::kGetChildrenIndex_Guid = 18;
using namespace mozilla::places;
@ -1070,7 +1070,8 @@ nsNavBookmarks::GetDescendantChildren(int64_t aFolderId,
nsCOMPtr<mozIStorageStatement> stmt = mDB->GetStatement(
"SELECT h.id, h.url, IFNULL(b.title, h.title), h.rev_host, h.visit_count, "
"h.last_visit_date, f.url, null, b.id, b.dateAdded, b.lastModified, "
"b.parent, null, h.frecency, b.position, b.type, b.fk, b.guid "
"b.parent, null, h.frecency, h.hidden, b.position, b.type, b.fk, "
"b.guid "
"FROM moz_bookmarks b "
"LEFT JOIN moz_places h ON b.fk = h.id "
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
@ -1782,7 +1783,7 @@ nsNavBookmarks::QueryFolderChildren(
nsCOMPtr<mozIStorageStatement> stmt = mDB->GetStatement(
"SELECT h.id, h.url, IFNULL(b.title, h.title), h.rev_host, h.visit_count, "
"h.last_visit_date, f.url, null, b.id, b.dateAdded, b.lastModified, "
"b.parent, null, h.frecency, b.position, b.type, b.fk, "
"b.parent, null, h.frecency, h.hidden, b.position, b.type, b.fk, "
"b.guid "
"FROM moz_bookmarks b "
"LEFT JOIN moz_places h ON b.fk = h.id "
@ -1916,7 +1917,7 @@ nsNavBookmarks::QueryFolderChildrenAsync(
nsCOMPtr<mozIStorageAsyncStatement> stmt = mDB->GetAsyncStatement(
"SELECT h.id, h.url, IFNULL(b.title, h.title), h.rev_host, h.visit_count, "
"h.last_visit_date, f.url, null, b.id, b.dateAdded, b.lastModified, "
"b.parent, null, h.frecency, b.position, b.type, b.fk, "
"b.parent, null, h.frecency, h.hidden, b.position, b.type, b.fk, "
"b.guid "
"FROM moz_bookmarks b "
"LEFT JOIN moz_places h ON b.fk = h.id "
@ -2775,7 +2776,7 @@ NS_IMETHODIMP
nsNavBookmarks::OnVisit(nsIURI* aURI, int64_t aVisitId, PRTime aTime,
int64_t aSessionID, int64_t aReferringID,
uint32_t aTransitionType, const nsACString& aGUID,
uint32_t* aAdded)
bool aHidden)
{
// If the page is bookmarked, notify observers for each associated bookmark.
ItemVisitData visitData;

Просмотреть файл

@ -101,7 +101,7 @@ using namespace mozilla::places;
// for repeating stuff. These are milliseconds between "now" cache refreshes.
#define RENEW_CACHED_NOW_TIMEOUT ((int32_t)3 * PR_MSEC_PER_SEC)
static const int64_t USECS_PER_DAY = PR_USEC_PER_SEC * 60 * 60 * 24;
static const int64_t USECS_PER_DAY = (int64_t)PR_USEC_PER_SEC * 60 * 60 * 24;
// character-set annotation
#define CHARSET_ANNO NS_LITERAL_CSTRING("URIProperties/characterSet")
@ -251,6 +251,7 @@ const int32_t nsNavHistory::kGetInfoIndex_ItemLastModified = 10;
const int32_t nsNavHistory::kGetInfoIndex_ItemParentId = 11;
const int32_t nsNavHistory::kGetInfoIndex_ItemTags = 12;
const int32_t nsNavHistory::kGetInfoIndex_Frecency = 13;
const int32_t nsNavHistory::kGetInfoIndex_Hidden = 14;
PLACES_FACTORY_SINGLETON_IMPLEMENTATION(nsNavHistory, gHistoryService)
@ -731,15 +732,15 @@ nsNavHistory::NotifyOnVisit(nsIURI* aURI,
int64_t aSessionID,
int64_t referringVisitID,
int32_t aTransitionType,
const nsACString& aGUID)
const nsACString& aGUID,
bool aHidden)
{
uint32_t added = 0;
MOZ_ASSERT(!aGUID.IsEmpty());
mHasHistoryEntries = 1;
NOTIFY_OBSERVERS(mCanNotify, mCacheObservers, mObservers,
nsINavHistoryObserver,
OnVisit(aURI, aVisitID, aTime, aSessionID,
referringVisitID, aTransitionType, aGUID, &added));
referringVisitID, aTransitionType, aGUID, aHidden));
}
void
@ -962,6 +963,10 @@ nsNavHistory::EvaluateQueryForNode(const nsCOMArray<nsNavHistoryQuery>& aQueries
// lazily created from the node's string when we need to match URIs
nsCOMPtr<nsIURI> nodeUri;
// --- hidden ---
if (aNode->mHidden && !aOptions->IncludeHidden())
return false;
for (int32_t i = 0; i < aQueries.Count(); i ++) {
bool hasIt;
nsCOMPtr<nsNavHistoryQuery> query = aQueries[i];
@ -1392,11 +1397,7 @@ nsNavHistory::AddVisit(nsIURI* aURI, PRTime aTime, nsIURI* aReferringURI,
scoper.Abandon();
// Hide only embedded links and redirects
// See the hidden computation code above for a little more explanation.
hidden = (int32_t)(aTransitionType == TRANSITION_EMBED ||
aTransitionType == TRANSITION_FRAMED_LINK ||
aIsRedirect);
hidden = (int32_t)GetHiddenState(aIsRedirect, aTransitionType);
typed = (int32_t)(aTransitionType == TRANSITION_TYPED);
// set as visited once, no title
@ -1433,13 +1434,10 @@ nsNavHistory::AddVisit(nsIURI* aURI, PRTime aTime, nsIURI* aReferringURI,
// important to notify the observers below.
(void)UpdateFrecency(pageID);
// Notify observers: The hidden detection code must match that in
// GetQueryResults to maintain consistency.
// FIXME bug 325241: make a way to observe hidden URLs
if (!hidden) {
NotifyOnVisit(aURI, *aVisitID, aTime, aSessionID, referringVisitID,
aTransitionType, guid);
}
// Notify the visit. Note that TRANSITION_EMBED visits are never added
// to the database, thus cannot be queried and we don't notify them.
NotifyOnVisit(aURI, *aVisitID, aTime, aSessionID, referringVisitID,
aTransitionType, guid, hidden);
// Normally docshell sends the link visited observer notification for us (this
// will tell all the documents to update their visited link coloring).
@ -1804,7 +1802,7 @@ PlacesSQLQueryBuilder::SelectAsURI()
mQueryString = NS_LITERAL_CSTRING(
"SELECT h.id, h.url, h.title AS page_title, h.rev_host, h.visit_count, "
"h.last_visit_date, f.url, null, null, null, null, null, ") +
tagsSqlFragment + NS_LITERAL_CSTRING(", h.frecency "
tagsSqlFragment + NS_LITERAL_CSTRING(", h.frecency, h.hidden "
"FROM moz_places h "
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
// WHERE 1 is a no-op since additonal conditions will start with AND.
@ -1830,7 +1828,7 @@ PlacesSQLQueryBuilder::SelectAsURI()
"SELECT b2.fk, h.url, COALESCE(b2.title, h.title) AS page_title, "
"h.rev_host, h.visit_count, h.last_visit_date, f.url, null, b2.id, "
"b2.dateAdded, b2.lastModified, b2.parent, ") +
tagsSqlFragment + NS_LITERAL_CSTRING(", h.frecency "
tagsSqlFragment + NS_LITERAL_CSTRING(", h.frecency, h.hidden "
"FROM moz_bookmarks b2 "
"JOIN (SELECT b.fk "
"FROM moz_bookmarks b "
@ -1854,7 +1852,7 @@ PlacesSQLQueryBuilder::SelectAsURI()
"SELECT b.fk, h.url, COALESCE(b.title, h.title) AS page_title, "
"h.rev_host, h.visit_count, h.last_visit_date, f.url, null, b.id, "
"b.dateAdded, b.lastModified, b.parent, ") +
tagsSqlFragment + NS_LITERAL_CSTRING(", h.frecency "
tagsSqlFragment + NS_LITERAL_CSTRING(", h.frecency, h.hidden "
"FROM moz_bookmarks b "
"JOIN moz_places h ON b.fk = h.id "
"LEFT OUTER JOIN moz_favicons f ON h.favicon_id = f.id "
@ -1886,7 +1884,7 @@ PlacesSQLQueryBuilder::SelectAsVisit()
mQueryString = NS_LITERAL_CSTRING(
"SELECT h.id, h.url, h.title AS page_title, h.rev_host, h.visit_count, "
"v.visit_date, f.url, v.session, null, null, null, null, ") +
tagsSqlFragment + NS_LITERAL_CSTRING(", h.frecency "
tagsSqlFragment + NS_LITERAL_CSTRING(", h.frecency, h.hidden "
"FROM moz_places h "
"JOIN moz_historyvisits v ON h.id = v.place_id "
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
@ -1921,7 +1919,7 @@ PlacesSQLQueryBuilder::SelectAsDay()
mQueryString = nsPrintfCString(
"SELECT null, "
"'place:type=%ld&sort=%ld&beginTime='||beginTime||'&endTime='||endTime, "
"dayTitle, null, null, beginTime, null, null, null, null, null, null "
"dayTitle, null, null, beginTime, null, null, null, null, null, null, null "
"FROM (", // TOUTER BEGIN
resultType,
sortingMode);
@ -2124,7 +2122,7 @@ PlacesSQLQueryBuilder::SelectAsSite()
mQueryString = nsPrintfCString(
"SELECT null, 'place:type=%ld&sort=%ld&domain=&domainIsHost=true'%s, "
":localhost, :localhost, null, null, null, null, null, null, null "
":localhost, :localhost, null, null, null, null, null, null, null, null "
"WHERE EXISTS ( "
"SELECT h.id FROM moz_places h "
"%s "
@ -2137,7 +2135,7 @@ PlacesSQLQueryBuilder::SelectAsSite()
"UNION ALL "
"SELECT null, "
"'place:type=%ld&sort=%ld&domain='||host||'&domainIsHost=true'%s, "
"host, host, null, null, null, null, null, null, null "
"host, host, null, null, null, null, null, null, null, null "
"FROM ( "
"SELECT get_unreversed_host(h.rev_host) AS host "
"FROM moz_places h "
@ -2177,7 +2175,7 @@ PlacesSQLQueryBuilder::SelectAsTag()
mQueryString = nsPrintfCString(
"SELECT null, 'place:folder=' || id || '&queryType=%d&type=%ld', "
"title, null, null, null, null, null, null, dateAdded, "
"lastModified, null, null "
"lastModified, null, null, null "
"FROM moz_bookmarks "
"WHERE parent = %lld",
nsINavHistoryQueryOptions::QUERY_TYPE_BOOKMARKS,
@ -2411,7 +2409,7 @@ nsNavHistory::ConstructQueryString(
queryString = NS_LITERAL_CSTRING(
"SELECT h.id, h.url, h.title AS page_title, h.rev_host, h.visit_count, h.last_visit_date, "
"f.url, null, null, null, null, null, ") +
tagsSqlFragment + NS_LITERAL_CSTRING(", h.frecency "
tagsSqlFragment + NS_LITERAL_CSTRING(", h.frecency, h.hidden "
"FROM moz_places h "
"LEFT OUTER JOIN moz_favicons f ON h.favicon_id = f.id "
"WHERE h.hidden = 0 "
@ -4478,6 +4476,9 @@ nsNavHistory::RowToResult(mozIStorageValueArray* aRow,
(*aResult)->mLastModified = aRow->AsInt64(kGetInfoIndex_ItemLastModified);
}
(*aResult)->mFrecency = aRow->AsInt32(kGetInfoIndex_Frecency);
(*aResult)->mHidden = !!aRow->AsInt32(kGetInfoIndex_Hidden);
nsAutoString tags;
rv = aRow->GetString(kGetInfoIndex_ItemTags, tags);
NS_ENSURE_SUCCESS(rv, rv);
@ -4600,7 +4601,7 @@ nsNavHistory::VisitIdToResultNode(int64_t visitId,
statement = mDB->GetStatement(NS_LITERAL_CSTRING(
"SELECT h.id, h.url, h.title, h.rev_host, h.visit_count, "
"v.visit_date, f.url, v.session, null, null, null, null, "
) + tagsFragment + NS_LITERAL_CSTRING(", h.frecency "
) + tagsFragment + NS_LITERAL_CSTRING(", h.frecency, h.hidden "
"FROM moz_places h "
"JOIN moz_historyvisits v ON h.id = v.place_id "
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
@ -4614,7 +4615,7 @@ nsNavHistory::VisitIdToResultNode(int64_t visitId,
statement = mDB->GetStatement(NS_LITERAL_CSTRING(
"SELECT h.id, h.url, h.title, h.rev_host, h.visit_count, "
"h.last_visit_date, f.url, null, null, null, null, null, "
) + tagsFragment + NS_LITERAL_CSTRING(", h.frecency "
) + tagsFragment + NS_LITERAL_CSTRING(", h.frecency, h.hidden "
"FROM moz_places h "
"JOIN moz_historyvisits v ON h.id = v.place_id "
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
@ -4660,7 +4661,7 @@ nsNavHistory::BookmarkIdToResultNode(int64_t aBookmarkId, nsNavHistoryQueryOptio
"SELECT b.fk, h.url, COALESCE(b.title, h.title), "
"h.rev_host, h.visit_count, h.last_visit_date, f.url, null, b.id, "
"b.dateAdded, b.lastModified, b.parent, "
) + tagsFragment + NS_LITERAL_CSTRING(", h.frecency "
) + tagsFragment + NS_LITERAL_CSTRING(", h.frecency, h.hidden "
"FROM moz_bookmarks b "
"JOIN moz_places h ON b.fk = h.id "
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
@ -4699,7 +4700,7 @@ nsNavHistory::URIToResultNode(nsIURI* aURI,
nsCOMPtr<mozIStorageStatement> stmt = mDB->GetStatement(NS_LITERAL_CSTRING(
"SELECT h.id, :page_url, h.title, h.rev_host, h.visit_count, "
"h.last_visit_date, f.url, null, null, null, null, null, "
) + tagsFragment + NS_LITERAL_CSTRING(", h.frecency "
) + tagsFragment + NS_LITERAL_CSTRING(", h.frecency, h.hidden "
"FROM moz_places h "
"LEFT JOIN moz_favicons f ON h.favicon_id = f.id "
"WHERE h.url = :page_url ")

Просмотреть файл

@ -217,6 +217,7 @@ public:
static const int32_t kGetInfoIndex_ItemParentId;
static const int32_t kGetInfoIndex_ItemTags;
static const int32_t kGetInfoIndex_Frecency;
static const int32_t kGetInfoIndex_Hidden;
int64_t GetTagsFolder();
@ -411,7 +412,8 @@ public:
int64_t aSessionID,
int64_t referringVisitID,
int32_t aTransitionType,
const nsACString& aGUID);
const nsACString& aGUID,
bool aHidden);
/**
* Fires onTitleChanged event to nsINavHistoryService observers

Просмотреть файл

@ -105,7 +105,8 @@ nsNavHistoryResultNode::nsNavHistoryResultNode(
mDateAdded(0),
mLastModified(0),
mIndentLevel(-1),
mFrecency(0)
mFrecency(0),
mHidden(false)
{
mTags.SetIsVoid(true);
}
@ -2529,8 +2530,12 @@ nsNavHistoryQueryResultNode::OnVisit(nsIURI* aURI, int64_t aVisitId,
int64_t aReferringId,
uint32_t aTransitionType,
const nsACString& aGUID,
bool aHidden,
uint32_t* aAdded)
{
if (aHidden && !mOptions->IncludeHidden())
return NS_OK;
nsNavHistoryResult* result = GetResult();
NS_ENSURE_STATE(result);
if (result->mBatchInProgress &&
@ -4719,13 +4724,13 @@ NS_IMETHODIMP
nsNavHistoryResult::OnVisit(nsIURI* aURI, int64_t aVisitId, PRTime aTime,
int64_t aSessionId, int64_t aReferringId,
uint32_t aTransitionType, const nsACString& aGUID,
uint32_t* aAdded)
bool aHidden)
{
uint32_t added = 0;
ENUMERATE_HISTORY_OBSERVERS(OnVisit(aURI, aVisitId, aTime, aSessionId,
aReferringId, aTransitionType, aGUID,
&added));
aHidden, &added));
if (!mRootNode->mExpanded)
return NS_OK;

Просмотреть файл

@ -61,12 +61,8 @@ private:
// Declare methods for implementing nsINavBookmarkObserver
// and nsINavHistoryObserver (some methods, such as BeginUpdateBatch overlap)
#define NS_DECL_BOOKMARK_HISTORY_OBSERVER \
#define NS_DECL_BOOKMARK_HISTORY_OBSERVER_BASE \
NS_DECL_NSINAVBOOKMARKOBSERVER \
NS_IMETHOD OnVisit(nsIURI* aURI, int64_t aVisitId, PRTime aTime, \
int64_t aSessionId, int64_t aReferringId, \
uint32_t aTransitionType, const nsACString& aGUID, \
uint32_t* aAdded); \
NS_IMETHOD OnTitleChanged(nsIURI* aURI, const nsAString& aPageTitle, \
const nsACString& aGUID); \
NS_IMETHOD OnBeforeDeleteURI(nsIURI *aURI, const nsACString& aGUID, \
@ -80,6 +76,24 @@ private:
NS_IMETHOD OnDeleteVisits(nsIURI* aURI, PRTime aVisitTime, \
const nsACString& aGUID, uint16_t aReason);
// The internal version has an output aAdded parameter, it is incremented by
// query nodes when the visited uri belongs to them. If no such query exists,
// the history result creates a new query node dynamically.
#define NS_DECL_BOOKMARK_HISTORY_OBSERVER_INTERNAL \
NS_DECL_BOOKMARK_HISTORY_OBSERVER_BASE \
NS_IMETHOD OnVisit(nsIURI* aURI, int64_t aVisitId, PRTime aTime, \
int64_t aSessionId, int64_t aReferringId, \
uint32_t aTransitionType, const nsACString& aGUID, \
bool aHidden, uint32_t* aAdded);
// The external version is used by results.
#define NS_DECL_BOOKMARK_HISTORY_OBSERVER_EXTERNAL \
NS_DECL_BOOKMARK_HISTORY_OBSERVER_BASE \
NS_IMETHOD OnVisit(nsIURI* aURI, int64_t aVisitId, PRTime aTime, \
int64_t aSessionId, int64_t aReferringId, \
uint32_t aTransitionType, const nsACString& aGUID, \
bool aHidden);
// nsNavHistoryResult
//
// nsNavHistory creates this object and fills in mChildren (by getting
@ -106,7 +120,7 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSINAVHISTORYRESULT
NS_DECL_BOOKMARK_HISTORY_OBSERVER
NS_DECL_BOOKMARK_HISTORY_OBSERVER_EXTERNAL
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsNavHistoryResult, nsINavHistoryResult)
void AddHistoryObserver(nsNavHistoryQueryResultNode* aNode);
@ -362,7 +376,11 @@ public:
// root's children will have a value of 0, and so on.
int32_t mIndentLevel;
int32_t mFrecency; // Containers have 0 frecency.
// Frecency of the page. Valid only for URI nodes.
int32_t mFrecency;
// Hidden status of the page. Valid only for URI nodes.
bool mHidden;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryResultNode, NS_NAVHISTORYRESULTNODE_IID)
@ -695,7 +713,7 @@ public:
virtual nsresult OpenContainer();
NS_DECL_BOOKMARK_HISTORY_OBSERVER
NS_DECL_BOOKMARK_HISTORY_OBSERVER_INTERNAL
virtual void OnRemoving();
public:

Просмотреть файл

@ -16,12 +16,20 @@ function test() {
// Create and add history observer.
let historyObserver = {
_redirectNotified: false,
onVisit: function (aURI, aVisitID, aTime, aSessionID, aReferringID,
aTransitionType) {
info("Received onVisit: " + aURI.spec);
if (aURI.equals(REDIRECT_URI)) {
this._redirectNotified = true;
// Wait for the target page notification.
return;
}
PlacesUtils.history.removeObserver(historyObserver);
ok(aURI.equals(TARGET_URI), "The redirect source should not be notified");
ok(this._redirectNotified, "The redirect should have been notified");
fieldForUrl(REDIRECT_URI, "frecency", function (aFrecency) {
ok(aFrecency != 0, "Frecency or the redirecting page should not be 0");

Просмотреть файл

@ -24,6 +24,15 @@ const VISITS = [
}
];
const HIDDEN_VISITS = [
{ isVisit: true,
transType: TRANSITION_FRAMED_LINK,
uri: "http://hidden.example.com/",
title: "red",
lastVisit: timeInMicroseconds--
},
];
const TEST_DATA = [
{ searchTerms: "example",
includeHidden: true,
@ -33,7 +42,7 @@ const TEST_DATA = [
includeHidden: false,
expectedResults: 1
},
{ searchTerms: "redir",
{ searchTerms: "red",
includeHidden: true,
expectedResults: 1
}
@ -59,8 +68,17 @@ add_task(function test_searchTerms_includeHidden()
let root = PlacesUtils.history.executeQuery(query, options).root;
root.containerOpen = true;
let cc = root.childCount;
// Live update with hidden visits.
yield task_populateDB(HIDDEN_VISITS);
let cc_update = root.childCount;
root.containerOpen = false;
do_check_eq(cc, data.expectedResults);
do_check_eq(cc_update, data.expectedResults + (data.includeHidden ? 1 : 0));
PlacesUtils.bhistory.removePage(uri("http://hidden.example.com/"));
}
});

Просмотреть файл

@ -1228,9 +1228,9 @@ tests.push({
];
this._sortedData = [
this._unsortedData[2],
this._unsortedData[3],
this._unsortedData[5],
this._unsortedData[2],
];
// This function in head_queries.js creates our database with the above data

Просмотреть файл

@ -38,14 +38,14 @@ function onNotify(callback) {
}
/**
* Asynchronous task that adds a TRANSITION_TYPED visit to the history database.
* Asynchronous task that adds a visit to the history database.
*/
function task_add_visit(uri, timestamp) {
function task_add_visit(uri, timestamp, transition) {
uri = uri || NetUtil.newURI("http://firefox.com/");
timestamp = timestamp || Date.now() * 1000;
yield promiseAddVisits({
uri: uri,
transition: TRANSITION_TYPED,
transition: transition || TRANSITION_TYPED,
visitDate: timestamp
});
throw new Task.Result([uri, timestamp]);
@ -58,14 +58,16 @@ function run_test() {
add_task(function test_onVisit() {
let promiseNotify = onNotify(function onVisit(aURI, aVisitID, aTime,
aSessionID, aReferringID,
aTransitionType, aGUID) {
aTransitionType, aGUID,
aHidden) {
do_check_true(aURI.equals(testuri));
do_check_true(aVisitID > 0);
do_check_eq(aTime, testtime);
do_check_true(aSessionID > 0);
do_check_eq(aReferringID, 0);
do_check_eq(aTransitionType, Ci.nsINavHistoryService.TRANSITION_TYPED);
do_check_eq(aTransitionType, TRANSITION_TYPED);
do_check_guid_for_uri(aURI, aGUID);
do_check_false(aHidden);
});
let testuri = NetUtil.newURI("http://firefox.com/");
let testtime = Date.now() * 1000;
@ -73,6 +75,26 @@ add_task(function test_onVisit() {
yield promiseNotify;
});
add_task(function test_onVisit() {
let promiseNotify = onNotify(function onVisit(aURI, aVisitID, aTime,
aSessionID, aReferringID,
aTransitionType, aGUID,
aHidden) {
do_check_true(aURI.equals(testuri));
do_check_true(aVisitID > 0);
do_check_eq(aTime, testtime);
do_check_true(aSessionID > 0);
do_check_eq(aReferringID, 0);
do_check_eq(aTransitionType, TRANSITION_FRAMED_LINK);
do_check_guid_for_uri(aURI, aGUID);
do_check_true(aHidden);
});
let testuri = NetUtil.newURI("http://hidden.firefox.com/");
let testtime = Date.now() * 1000;
yield task_add_visit(testuri, testtime, TRANSITION_FRAMED_LINK);
yield promiseNotify;
});
add_task(function test_onBeforeDeleteURI() {
let promiseNotify = onNotify(function onBeforeDeleteURI(aURI, aGUID,
aReason) {