Bug 610442 - TRANSITION_EMBED visits should be session persistent

r=sdwilsh a=blocking
This commit is contained in:
Marco Bonardo 2010-11-12 14:24:25 -08:00
parent 3e1f89f94a
commit c3cb283d6a
19 changed files with 621 additions and 548 deletions

View File

@ -24,8 +24,8 @@ let observer = {
{
let url = aSubject.QueryInterface(Ci.nsIURI).spec;
if (url == LEFT_URL ) {
is(getTransitionForUrl(url), PlacesUtils.history.TRANSITION_EMBED,
"Frames should get a EMBED transition.");
is(getTransitionForUrl(url), null,
"Embed visits should not get a database entry.");
gLeftFrameVisited = true;
maybeClickLink();
}
@ -74,7 +74,9 @@ function getTransitionForUrl(aUrl)
"(SELECT id FROM moz_places WHERE url = :page_url)");
stmt.params.page_url = aUrl;
try {
ok(stmt.executeStep(), "Found the visit in the database");
if (!stmt.executeStep()) {
return null;
}
return stmt.row.visit_type;
}
finally {

View File

@ -1443,7 +1443,7 @@ interface nsINavHistoryService : nsISupports
*
* @param aURI
* URI to retrieve character-set for
* @returns character-set, empty string if not found
* @return character-set, empty string if not found
*/
AString getCharsetForURI(in nsIURI aURI);
@ -1486,8 +1486,9 @@ interface nsINavHistoryService : nsISupports
* unhidden by visiting it with a non-redirect).
* @param aSessionID The session ID that this page belongs to. Use 0 for
* no session.
* @returns The ID of the created visit. This will be 0 if the URI is not
* valid for adding to history (canAddURI = false).
* @return The ID of the created visit. This will be 0 if the URI cannot
* be added to history (canAddURI = false) or the visit is session
* persistent (TRANSITION_EMBED).
*/
long long addVisit(in nsIURI aURI, in PRTime aTime,
in nsIURI aReferringURI, in long aTransitionType,

View File

@ -53,6 +53,10 @@
#include "nsDocShellCID.h"
#include "nsIEventStateManager.h"
#include "mozilla/Services.h"
#include "nsThreadUtils.h"
// Initial size for the cache holding visited status observers.
#define VISIT_OBSERVERS_INITIAL_CACHE_SIZE 128
using namespace mozilla::dom;
@ -92,6 +96,19 @@ public:
}
#endif
nsNavHistory* navHistory = nsNavHistory::GetHistoryService();
NS_ENSURE_STATE(navHistory);
if (navHistory->hasEmbedVisit(aURI)) {
nsRefPtr<VisitedQuery> callback = new VisitedQuery(aURI, true);
NS_ENSURE_TRUE(callback, NS_ERROR_OUT_OF_MEMORY);
// As per IHistory contract, we must notify asynchronously.
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(callback, &VisitedQuery::NotifyVisitedStatus);
NS_DispatchToMainThread(event);
return NS_OK;
}
mozIStorageAsyncStatement* stmt =
History::GetService()->GetIsVisitedStatement();
NS_ENSURE_STATE(stmt);
@ -128,12 +145,17 @@ public:
return NS_OK;
}
nsresult rv = NotifyVisitedStatus();
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
nsresult NotifyVisitedStatus()
{
if (mIsVisited) {
History::GetService()->NotifyVisited(mURI);
}
// Notify any observers about that we have resolved the visited state of
// this URI.
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (observerService) {
@ -151,10 +173,11 @@ public:
return NS_OK;
}
private:
VisitedQuery(nsIURI* aURI)
VisitedQuery(nsIURI* aURI, bool aIsVisited=false)
: mURI(aURI)
, mIsVisited(false)
, mIsVisited(aIsVisited)
{
}
@ -214,14 +237,15 @@ public:
: mPlace(aPlace)
, mReferrer(aReferrer)
{
NS_PRECONDITION(!NS_IsMainThread(),
"This should not be called on the main thread");
}
NS_IMETHOD Run()
{
nsNavHistory* history = nsNavHistory::GetHistoryService();
if (!history) {
NS_PRECONDITION(NS_IsMainThread(),
"This should be called on the main thread");
nsNavHistory* navHistory = nsNavHistory::GetHistoryService();
if (!navHistory) {
NS_WARNING("Trying to notify about a visit but cannot get the history service!");
return NS_OK;
}
@ -231,9 +255,9 @@ public:
if (!mPlace.hidden &&
mPlace.transitionType != nsINavHistoryService::TRANSITION_EMBED &&
mPlace.transitionType != nsINavHistoryService::TRANSITION_FRAMED_LINK) {
history->NotifyOnVisit(mPlace.uri, mPlace.visitId, mPlace.visitTime,
mPlace.sessionId, mReferrer.visitId,
mPlace.transitionType);
navHistory->NotifyOnVisit(mPlace.uri, mPlace.visitId, mPlace.visitTime,
mPlace.sessionId, mReferrer.visitId,
mPlace.transitionType);
}
nsCOMPtr<nsIObserverService> obsService =
@ -289,9 +313,9 @@ public:
// we will use the session id from the referrer if the visit was "recent"
// enough, we cannot call this method off of the main thread, so we have to
// consume an id now.
nsNavHistory* navhistory = nsNavHistory::GetHistoryService();
NS_ENSURE_TRUE(navhistory, NS_ERROR_UNEXPECTED);
event->mPlace.sessionId = navhistory->GetNewSessionID();
nsNavHistory* navHistory = nsNavHistory::GetHistoryService();
NS_ENSURE_TRUE(navHistory, NS_ERROR_UNEXPECTED);
event->mPlace.sessionId = navHistory->GetNewSessionID();
// Get the target thread, and then start the work!
nsCOMPtr<nsIEventTarget> target = do_GetInterface(aConnection);
@ -675,9 +699,9 @@ public:
return NS_OK;
}
nsNavHistory* navhistory = nsNavHistory::GetHistoryService();
NS_ENSURE_TRUE(navhistory, NS_ERROR_OUT_OF_MEMORY);
navhistory->NotifyTitleChange(mURI, mTitle);
nsNavHistory* navHistory = nsNavHistory::GetHistoryService();
NS_ENSURE_TRUE(navHistory, NS_ERROR_OUT_OF_MEMORY);
navHistory->NotifyTitleChange(mURI, mTitle);
// We have to be careful about when we release our URI. The background
// thread could still hold a reference to this event, so relying on the
@ -987,10 +1011,10 @@ History::GetDBConn()
return mDBConn;
}
nsNavHistory* history = nsNavHistory::GetHistoryService();
NS_ENSURE_TRUE(history, nsnull);
nsNavHistory* navHistory = nsNavHistory::GetHistoryService();
NS_ENSURE_TRUE(navHistory, nsnull);
nsresult rv = history->GetDBConnection(getter_AddRefs(mDBConn));
nsresult rv = navHistory->GetDBConnection(getter_AddRefs(mDBConn));
NS_ENSURE_SUCCESS(rv, nsnull);
return mDBConn;
@ -1035,12 +1059,12 @@ History::VisitURI(nsIURI* aURI,
}
#endif /* MOZ_IPC */
nsNavHistory* history = nsNavHistory::GetHistoryService();
NS_ENSURE_TRUE(history, NS_ERROR_OUT_OF_MEMORY);
nsNavHistory* navHistory = nsNavHistory::GetHistoryService();
NS_ENSURE_TRUE(navHistory, NS_ERROR_OUT_OF_MEMORY);
// Silently return if URI is something we shouldn't add to DB.
PRBool canAdd;
nsresult rv = history->CanAddURI(aURI, &canAdd);
nsresult rv = navHistory->CanAddURI(aURI, &canAdd);
NS_ENSURE_SUCCESS(rv, rv);
if (!canAdd) {
return NS_OK;
@ -1062,9 +1086,21 @@ History::VisitURI(nsIURI* aURI,
// Assigns a type to the edge in the visit linked list. Each type will be
// considered differently when weighting the frecency of a location.
PRUint32 recentFlags = history->GetRecentFlags(aURI);
PRUint32 recentFlags = navHistory->GetRecentFlags(aURI);
bool redirected = false;
if (aFlags & IHistory::REDIRECT_TEMPORARY) {
bool isFollowedLink = recentFlags & nsNavHistory::RECENT_ACTIVATED;
// Embed visits should never be added to the database, and the same is valid
// for redirects across frames.
// For the above reasoning non-toplevel transitions are handled at first.
// if the visit is toplevel or a non-toplevel followed link, then it can be
// handled as usual and stored on disk.
if (!(aFlags & IHistory::TOP_LEVEL) && !isFollowedLink) {
// A frame redirected to a new site without user interaction.
place.transitionType = nsINavHistoryService::TRANSITION_EMBED;
}
else if (aFlags & IHistory::REDIRECT_TEMPORARY) {
place.transitionType = nsINavHistoryService::TRANSITION_REDIRECT_TEMPORARY;
redirected = true;
}
@ -1078,17 +1114,13 @@ History::VisitURI(nsIURI* aURI,
else if (recentFlags & nsNavHistory::RECENT_BOOKMARKED) {
place.transitionType = nsINavHistoryService::TRANSITION_BOOKMARK;
}
else if (aFlags & IHistory::TOP_LEVEL) {
// User was redirected or link was clicked in the main window.
place.transitionType = nsINavHistoryService::TRANSITION_LINK;
}
else if (recentFlags & nsNavHistory::RECENT_ACTIVATED) {
else if (!(aFlags & IHistory::TOP_LEVEL) && isFollowedLink) {
// User activated a link in a frame.
place.transitionType = nsINavHistoryService::TRANSITION_FRAMED_LINK;
}
else {
// A frame redirected to a new site without user interaction.
place.transitionType = nsINavHistoryService::TRANSITION_EMBED;
// User was redirected or link was clicked in the main window.
place.transitionType = nsINavHistoryService::TRANSITION_LINK;
}
place.typed = place.transitionType == nsINavHistoryService::TRANSITION_TYPED;
@ -1099,11 +1131,23 @@ History::VisitURI(nsIURI* aURI,
place.visitTime = PR_Now();
place.uri = aURI;
mozIStorageConnection* dbConn = GetDBConn();
NS_ENSURE_STATE(dbConn);
// EMBED visits are session-persistent and should not go through the database.
// They exist only to keep track of isVisited status during the session.
if (place.transitionType == nsINavHistoryService::TRANSITION_EMBED) {
navHistory->registerEmbedVisit(place.uri, place.visitTime);
// Finally, enqueue an event to notify observers.
VisitData noReferrer;
nsCOMPtr<nsIRunnable> event = new NotifyVisitObservers(place, noReferrer);
rv = NS_DispatchToMainThread(event);
NS_ENSURE_SUCCESS(rv, rv);
}
else {
mozIStorageConnection* dbConn = GetDBConn();
NS_ENSURE_STATE(dbConn);
rv = InsertVisitedURI::Start(dbConn, place, aLastVisitedURI);
NS_ENSURE_SUCCESS(rv, rv);
rv = InsertVisitedURI::Start(dbConn, place, aLastVisitedURI);
NS_ENSURE_SUCCESS(rv, rv);
}
// Finally, notify that we've been visited.
nsCOMPtr<nsIObserverService> obsService =
@ -1130,7 +1174,8 @@ History::RegisterVisitedCallback(nsIURI* aURI,
// First, ensure that our hash table is setup.
if (!mObservers.IsInitialized()) {
NS_ENSURE_TRUE(mObservers.Init(), NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_TRUE(mObservers.Init(VISIT_OBSERVERS_INITIAL_CACHE_SIZE),
NS_ERROR_OUT_OF_MEMORY);
}
// Obtain our array of observers for this URI.
@ -1231,7 +1276,7 @@ History::SetURITitle(nsIURI* aURI, const nsAString& aTitle)
}
#endif /* MOZ_IPC */
nsNavHistory* history = nsNavHistory::GetHistoryService();
nsNavHistory* navHistory = nsNavHistory::GetHistoryService();
// At first, it seems like nav history should always be available here, no
// matter what.
@ -1242,15 +1287,20 @@ History::SetURITitle(nsIURI* aURI, const nsAString& aTitle)
// Maybe the correct thing to do is to not register this service if no
// profile has been selected?
//
NS_ENSURE_TRUE(history, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(navHistory, NS_ERROR_FAILURE);
PRBool canAdd;
nsresult rv = history->CanAddURI(aURI, &canAdd);
nsresult rv = navHistory->CanAddURI(aURI, &canAdd);
NS_ENSURE_SUCCESS(rv, rv);
if (!canAdd) {
return NS_OK;
}
// Embed visits don't have a database entry, thus don't set a title on them.
if (navHistory->hasEmbedVisit(aURI)) {
return NS_OK;
}
nsAutoString title;
if (aTitle.IsEmpty()) {
title.SetIsVoid(PR_TRUE);

View File

@ -161,6 +161,12 @@ static const PRInt64 USECS_PER_DAY = LL_INIT(20, 500654080);
// Max number of containers, used to initialize the params hash.
#define HISTORY_DATE_CONT_MAX 10
// Initial size of the embed visits cache.
#define EMBED_VISITS_INITIAL_CACHE_SIZE 128
// Initial size of the recent events caches.
#define RECENT_EVENTS_INITIAL_CACHE_SIZE 128
// Observed topics.
#ifdef MOZ_XUL
#define TOPIC_AUTOCOMPLETE_FEEDBACK_INCOMING "autocomplete-will-enter-text"
@ -488,10 +494,18 @@ nsNavHistory::Init()
NS_ENSURE_SUCCESS(rv, rv);
// recent events hash tables
NS_ENSURE_TRUE(mRecentTyped.Init(128), NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_TRUE(mRecentLink.Init(128), NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_TRUE(mRecentBookmark.Init(128), NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_TRUE(mRecentRedirects.Init(128), NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_TRUE(mRecentTyped.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE),
NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_TRUE(mRecentLink.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE),
NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_TRUE(mRecentBookmark.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE),
NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_TRUE(mRecentRedirects.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE),
NS_ERROR_OUT_OF_MEMORY);
// Rmbed visits hash table.
NS_ENSURE_TRUE(mEmbedVisits.Init(EMBED_VISITS_INITIAL_CACHE_SIZE),
NS_ERROR_OUT_OF_MEMORY);
/*****************************************************************************
*** IMPORTANT NOTICE!
@ -2726,6 +2740,14 @@ nsNavHistory::AddVisit(nsIURI* aURI, PRTime aTime, nsIURI* aReferringURI,
return NS_OK;
}
// Embed visits are not added to database, but registered in a session cache.
// For the above reason they don't have a visit id.
if (aTransitionType == TRANSITION_EMBED) {
registerEmbedVisit(aURI, GetNow());
*aVisitID = 0;
return NS_OK;
}
// This will prevent corruption since we have to do a two-phase add.
// Generally this won't do anything because AddURI has its own transaction.
mozStorageTransaction transaction(mDBConn, PR_FALSE);
@ -4325,6 +4347,9 @@ nsNavHistory::RemovePages(nsIURI **aURIs, PRUint32 aLength, PRBool aDoBatchNotif
rv = RemovePagesInternal(deletePlaceIdsQueryString);
NS_ENSURE_SUCCESS(rv, rv);
// Clear the registered embed visits.
clearEmbedVisits();
// force a full refresh calling onEndUpdateBatch (will call Refresh())
if (aDoBatchNotify)
UpdateBatchScoper batch(*this); // sends Begin/EndUpdateBatch to observers
@ -4438,12 +4463,15 @@ nsNavHistory::RemovePagesFromHost(const nsACString& aHost, PRBool aEntireDomain)
hostPlaceIds.AppendInt(placeId);
}
// force a full refresh calling onEndUpdateBatch (will call Refresh())
UpdateBatchScoper batch(*this); // sends Begin/EndUpdateBatch to observers
rv = RemovePagesInternal(hostPlaceIds);
NS_ENSURE_SUCCESS(rv, rv);
// Clear the registered embed visits.
clearEmbedVisits();
// force a full refresh calling onEndUpdateBatch (will call Refresh())
UpdateBatchScoper batch(*this); // sends Begin/EndUpdateBatch to observers
return NS_OK;
}
@ -4495,6 +4523,9 @@ nsNavHistory::RemovePagesByTimeframe(PRTime aBeginTime, PRTime aEndTime)
rv = RemovePagesInternal(deletePlaceIdsQueryString);
NS_ENSURE_SUCCESS(rv, rv);
// Clear the registered embed visits.
clearEmbedVisits();
// force a full refresh calling onEndUpdateBatch (will call Refresh())
UpdateBatchScoper batch(*this); // sends Begin/EndUpdateBatch to observers
@ -4587,6 +4618,9 @@ nsNavHistory::RemoveVisitsByTimeframe(PRTime aBeginTime, PRTime aEndTime)
rv = transaction.Commit();
NS_ENSURE_SUCCESS(rv, rv);
// Clear the registered embed visits.
clearEmbedVisits();
// Invalidate the cached value for whether there's history or not.
mHasHistoryEntries = -1;
@ -4630,6 +4664,9 @@ nsNavHistory::RemoveAllPages()
rv = transaction.Commit();
NS_ENSURE_SUCCESS(rv, rv);
// Clear the registered embed visits.
clearEmbedVisits();
// Invalidate the cached value for whether there's history or not.
mHasHistoryEntries = -1;
@ -5069,7 +5106,7 @@ nsNavHistory::IsVisited(nsIURI *aURI, PRBool *_retval)
nsresult rv = aURI->GetSpec(utf8URISpec);
NS_ENSURE_SUCCESS(rv, rv);
*_retval = IsURIStringVisited(utf8URISpec);
*_retval = hasEmbedVisit(aURI) ? PR_TRUE : IsURIStringVisited(utf8URISpec);
return NS_OK;
}
@ -6253,6 +6290,33 @@ nsNavHistory::FilterResultSet(nsNavHistoryQueryResultNode* aQueryNode,
return NS_OK;
}
void
nsNavHistory::registerEmbedVisit(nsIURI* aURI,
PRInt64 aTime)
{
NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
VisitHashKey* visit = mEmbedVisits.PutEntry(aURI);
if (!visit) {
NS_WARNING("Unable to register a EMBED visit.");
return;
}
visit->visitTime = aTime;
}
bool
nsNavHistory::hasEmbedVisit(nsIURI* aURI) {
NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
return !!mEmbedVisits.GetEntry(aURI);
}
void
nsNavHistory::clearEmbedVisits() {
NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
mEmbedVisits.Clear();
}
// nsNavHistory::CheckIsRecentEvent
//
@ -6734,8 +6798,12 @@ nsNavHistory::SetPageTitleInternal(nsIURI* aURI, const nsAString& aTitle)
PRBool hasURL = PR_FALSE;
rv = stmt->ExecuteStep(&hasURL);
NS_ENSURE_SUCCESS(rv, rv);
if (! hasURL) {
// we don't have the URL, give up
if (!hasURL) {
// If the url is unknown, either the page had an embed visit, or we have
// never seen it. While the former is fine, the latter is an error.
if (hasEmbedVisit(aURI)) {
return NS_OK;
}
return NS_ERROR_NOT_AVAILABLE;
}

View File

@ -62,6 +62,8 @@
#include "nsNetCID.h"
#include "nsToolkitCompsCID.h"
#include "nsThreadUtils.h"
#include "nsURIHashKey.h"
#include "nsTHashtable.h"
#include "nsINavBookmarksService.h"
#include "nsIPrivateBrowsingService.h"
@ -426,7 +428,7 @@ public:
/**
* Indicates if it is OK to notify history observers or not.
*
* @returns true if it is OK to notify, false otherwise.
* @return true if it is OK to notify, false otherwise.
*/
bool canNotify() { return mCanNotify; }
@ -443,6 +445,30 @@ public:
*/
PRUint32 GetRecentFlags(nsIURI *aURI);
/**
* Registers a TRANSITION_EMBED visit for the session.
*
* @param aURI
* URI of the page.
* @param aTime
* Visit time. Only the last registered visit time is retained.
*/
void registerEmbedVisit(nsIURI* aURI, PRInt64 aTime);
/**
* Returns whether the specified url has a embed visit.
*
* @param aURI
* URI of the page.
* @return whether the page has a embed visit.
*/
bool hasEmbedVisit(nsIURI* aURI);
/**
* Clears all registered embed visits.
*/
void clearEmbedVisits();
mozIStorageStatement* GetStatementById(
enum mozilla::places::HistoryStatementId aStatementId
)
@ -793,6 +819,24 @@ protected:
RecentEventHash mRecentLink;
RecentEventHash mRecentBookmark;
// Embed visits tracking.
class VisitHashKey : public nsURIHashKey
{
public:
VisitHashKey(const nsIURI* aURI)
: nsURIHashKey(aURI)
{
}
VisitHashKey(const VisitHashKey& aOther)
: nsURIHashKey(aOther)
{
NS_NOTREACHED("Do not call me!");
}
PRTime visitTime;
};
nsTHashtable<VisitHashKey> mEmbedVisits;
PRBool CheckIsRecentEvent(RecentEventHash* hashTable,
const nsACString& url);
void ExpireNonrecentEvents(RecentEventHash* hashTable);

View File

@ -204,8 +204,11 @@ do_get_place(nsIURI* aURI, PlaceRecord& result)
PRBool hasResults;
rv = stmt->ExecuteStep(&hasResults);
do_check_true(hasResults);
do_check_success(rv);
if (!hasResults) {
result.id = 0;
return;
}
rv = stmt->GetInt64(0, &result.id);
do_check_success(rv);
@ -241,9 +244,13 @@ do_get_lastVisit(PRInt64 placeId, VisitRecord& result)
PRBool hasResults;
rv = stmt->ExecuteStep(&hasResults);
do_check_true(hasResults);
do_check_success(rv);
if (!hasResults) {
result.id = 0;
return;
}
rv = stmt->GetInt64(0, &result.id);
do_check_success(rv);
rv = stmt->GetInt64(1, &result.lastVisitId);

View File

@ -545,7 +545,8 @@ test_visituri_transition_embed()
do_get_place(visitedURI, place);
do_get_lastVisit(place.id, visit);
do_check_true(visit.transitionType == nsINavHistoryService::TRANSITION_EMBED);
do_check_eq(place.id, 0);
do_check_eq(visit.id, 0);
run_next_test();
}

View File

@ -40,7 +40,7 @@ const NS_APP_PROFILE_DIR_STARTUP = "ProfDS";
const NS_APP_HISTORY_50_FILE = "UHist";
const NS_APP_BOOKMARKS_50_FILE = "BMarks";
// Shortcuts to transactions type.
// Shortcuts to transitions type.
const TRANSITION_LINK = Ci.nsINavHistoryService.TRANSITION_LINK;
const TRANSITION_TYPED = Ci.nsINavHistoryService.TRANSITION_TYPED;
const TRANSITION_BOOKMARK = Ci.nsINavHistoryService.TRANSITION_BOOKMARK;

View File

@ -348,7 +348,7 @@ function compareArrayToResult(aArray, aRoot) {
for (var i = 0; i < aArray.length; i++) {
if (aArray[i].isInQuery) {
var child = aRoot.getChild(inQueryIndex);
LOG("testing testData[" + i + "] vs result[" + inQueryIndex + "]");
//LOG("testing testData[" + i + "] vs result[" + inQueryIndex + "]");
if (!aArray[i].isFolder && !aArray[i].isSeparator) {
LOG("testing testData[" + aArray[i].uri + "] vs result[" + child.uri + "]");
if (aArray[i].uri != child.uri) {

View File

@ -36,32 +36,27 @@
*
* ***** END LICENSE BLOCK ***** */
let histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
let annosvc = Cc["@mozilla.org/browser/annotation-service;1"].
getService(Ci.nsIAnnotationService);
function modHistoryTypes(val){
switch(val % 8) {
case 0:
case 1:
return histsvc.TRANSITION_LINK;
return TRANSITION_LINK;
case 2:
return histsvc.TRANSITION_TYPED;
return TRANSITION_TYPED;
case 3:
return histsvc.TRANSITION_BOOKMARK;
return TRANSITION_BOOKMARK;
case 4:
return histsvc.TRANSITION_EMBED;
return TRANSITION_EMBED;
case 5:
return histsvc.TRANSITION_REDIRECT_PERMANENT;
return TRANSITION_REDIRECT_PERMANENT;
case 6:
return histsvc.TRANSITION_REDIRECT_TEMPORARY;
return TRANSITION_REDIRECT_TEMPORARY;
case 7:
return histsvc.TRANSITION_DOWNLOAD;
return TRANSITION_DOWNLOAD;
case 8:
return histsvc.TRANSITION_FRAMED_LINK;
return TRANSITION_FRAMED_LINK;
}
return histsvc.TRANSITION_TYPED;
return TRANSITION_TYPED;
}
/**
@ -73,27 +68,24 @@ function buildTestDatabase() {
// why we add more visits to the same URIs.
let testURI = uri("http://www.foo.com");
for (let i = 0; i < 12; ++i) {
histsvc.addVisit(testURI,
today,
null,
modHistoryTypes(i), // will work with different values, for ex: histsvc.TRANSITION_TYPED,
false,
0);
}
testURI = uri("http://foo.com/youdontseeme.html");
let testAnnoName = "moz-test-places/testing123";
let testAnnoVal = "test";
for (let i = 0; i < 12; ++i) {
histsvc.addVisit(testURI,
today,
null,
modHistoryTypes(i), // will work with different values, for ex: histsvc.TRANSITION_TYPED,
false,
0);
}
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, 0);
PlacesUtils.history.runInBatchMode({
runBatched: function (aUserData) {
for (let i = 0; i < 12; ++i) {
PlacesUtils.history.addVisit(testURI, today, null, modHistoryTypes(i),
false, 0);
}
testURI = uri("http://foo.com/youdontseeme.html");
let testAnnoName = "moz-test-places/testing123";
let testAnnoVal = "test";
for (let i = 0; i < 12; ++i) {
PlacesUtils.history.addVisit(testURI, today, null, modHistoryTypes(i),
false, 0);
}
PlacesUtils.annotations.setPageAnnotation(testURI, testAnnoName,
testAnnoVal, 0, 0);
}
}, null);
}
/**
@ -107,22 +99,22 @@ function buildTestDatabase() {
*/
function run_test() {
buildTestDatabase();
let query = histsvc.getNewQuery();
let query = PlacesUtils.history.getNewQuery();
query.annotation = "moz-test-places/testing123";
query.beginTime = daybefore * 1000;
query.beginTimeReference = histsvc.TIME_RELATIVE_NOW;
query.beginTimeReference = PlacesUtils.history.TIME_RELATIVE_NOW;
query.endTime = today * 1000;
query.endTimeReference = histsvc.TIME_RELATIVE_NOW;
query.endTimeReference = PlacesUtils.history.TIME_RELATIVE_NOW;
query.minVisits = 2;
query.maxVisits = 10;
// Options
let options = histsvc.getNewQueryOptions();
let options = PlacesUtils.history.getNewQueryOptions();
options.sortingMode = options.SORT_BY_DATE_DESCENDING;
options.resultType = options.RESULTS_AS_VISIT;
// Results
let root = histsvc.executeQuery(query, options).root;
let root = PlacesUtils.history.executeQuery(query, options).root;
root.containerOpen = true;
let cc = root.childCount;
dump("----> cc is: " + cc + "\n");

View File

@ -70,6 +70,7 @@ function check_results_callback(aSequence) {
case Ci.nsINavHistoryService.TRANSITION_DOWNLOAD:
return redirectsMode != Ci.nsINavHistoryQueryOptions.REDIRECTS_MODE_TARGET;
case Ci.nsINavHistoryService.TRANSITION_EMBED:
return false;
case Ci.nsINavHistoryService.TRANSITION_FRAMED_LINK:
return includeHidden && redirectsMode != Ci.nsINavHistoryQueryOptions.REDIRECTS_MODE_TARGET;
case Ci.nsINavHistoryService.TRANSITION_REDIRECT_TEMPORARY:
@ -211,8 +212,6 @@ function cartProd(aSequences, aCallback)
* visit -> redirect_temp -> redirect_perm
*/
function add_visits_to_database() {
// Clean up the database.
PlacesUtils.bhistory.removeAllPages();
remove_all_bookmarks();
// We don't really bother on this, but we need a time to add visits.
@ -224,7 +223,9 @@ function add_visits_to_database() {
Ci.nsINavHistoryService.TRANSITION_LINK,
Ci.nsINavHistoryService.TRANSITION_TYPED,
Ci.nsINavHistoryService.TRANSITION_BOOKMARK,
Ci.nsINavHistoryService.TRANSITION_EMBED,
// Embed visits are not added to the database and we don't want redirects
// to them, thus just avoid addition.
//Ci.nsINavHistoryService.TRANSITION_EMBED,
Ci.nsINavHistoryService.TRANSITION_FRAMED_LINK,
// Would make hard sorting by visit date because last_visit_date is actually
// calculated excluding download transitions, but the query includes

View File

@ -40,19 +40,13 @@
// https://wiki.mozilla.org/Firefox3.1/PrivateBrowsing/TestPlan#History
// http://developer.mozilla.org/en/Using_the_Places_history_service
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var bhist = histsvc.QueryInterface(Ci.nsIBrowserHistory);
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
/**
* Function prohibits an attempt to pop up a confirmation
* dialog box when entering Private Browsing mode.
*
* @returns a reference to the Private Browsing service
* @return a reference to the Private Browsing service
*/
var _PBSvc = null;
let _PBSvc = null;
function get_PBSvc() {
if (_PBSvc)
return _PBSvc;
@ -72,117 +66,91 @@ function get_PBSvc() {
* The URI to add a visit for.
* @param aType
* Transition type for the URI.
* @returns the place id for aURI.
*/
function add_visit(aURI, aType) {
var visitId = histsvc.addVisit(uri(aURI),
Date.now() * 1000,
null, // no referrer
aType,
false, // not redirect
0);
return visitId;
PlacesUtils.history.addVisit(uri(aURI), Date.now() * 1000, null, aType,
false, 0);
}
/**
* Checks to see that a URI is in the database.
*
* @param aURI
* The URI to check.
* @returns true if the URI is in the DB, false otherwise.
*/
function uri_in_db(aURI) {
var options = histsvc.getNewQueryOptions();
options.maxResults = 1;
options.resultType = options.RESULTS_AS_URI;
options.includeHidden = true;
var query = histsvc.getNewQuery();
query.uri = aURI;
var result = histsvc.executeQuery(query, options);
var root = result.root;
root.containerOpen = true;
return (root.childCount == 1);
}
var visited_URIs = ["http://www.test-link.com/",
let visited_URIs = ["http://www.test-link.com/",
"http://www.test-typed.com/",
"http://www.test-bookmark.com/",
"http://www.test-redirect-permanent.com/",
"http://www.test-redirect-temporary.com/",
"http://www.test-embed.com",
"http://www.test-framed.com",
"http://www.test-download.com"];
"http://www.test-embed.com/",
"http://www.test-framed.com/",
"http://www.test-download.com/"];
var nonvisited_URIs = ["http://www.google.ca/",
"http://www.google.com/",
"http://www.google.co.il/",
"http://www.google.fr/",
"http://www.google.es",
"http://www.google.it",
"http://www.google.com.tr",
"http://www.google.de"];
let nonvisited_URIs = ["http://www.google.ca/typed/",
"http://www.google.com/bookmark/",
"http://www.google.co.il/link/",
"http://www.google.fr/download/",
"http://www.google.es/embed/",
"http://www.google.it/framed-link/",
"http://www.google.com.tr/redirect-permanent/",
"http://www.google.de/redirect-temporary/"];
/**
* Function fills history, one for each transition type.
*
* @returns nothing
*/
function fill_history_visitedURI() {
add_visit(visited_URIs[0], histsvc.TRANSITION_LINK);
add_visit(visited_URIs[1], histsvc.TRANSITION_TYPED);
add_visit(visited_URIs[2], histsvc.TRANSITION_BOOKMARK);
add_visit(visited_URIs[3], histsvc.TRANSITION_REDIRECT_PERMANENT);
add_visit(visited_URIs[4], histsvc.TRANSITION_REDIRECT_TEMPORARY);
add_visit(visited_URIs[5], histsvc.TRANSITION_EMBED);
add_visit(visited_URIs[6], histsvc.TRANSITION_FRAMED_LINK);
add_visit(visited_URIs[7], histsvc.TRANSITION_DOWNLOAD);
PlacesUtils.history.runInBatchMode({
runBatched: function (aUserData) {
add_visit(visited_URIs[0], PlacesUtils.history.TRANSITION_LINK);
add_visit(visited_URIs[1], PlacesUtils.history.TRANSITION_TYPED);
add_visit(visited_URIs[2], PlacesUtils.history.TRANSITION_BOOKMARK);
add_visit(visited_URIs[3], PlacesUtils.history.TRANSITION_REDIRECT_PERMANENT);
add_visit(visited_URIs[4], PlacesUtils.history.TRANSITION_REDIRECT_TEMPORARY);
add_visit(visited_URIs[5], PlacesUtils.history.TRANSITION_EMBED);
add_visit(visited_URIs[6], PlacesUtils.history.TRANSITION_FRAMED_LINK);
add_visit(visited_URIs[7], PlacesUtils.history.TRANSITION_DOWNLOAD);
}
}, null);
}
/**
* Function fills history, one for each transition type.
* second batch of history items
*
* @returns nothing
*/
function fill_history_nonvisitedURI() {
add_visit(nonvisited_URIs[0], histsvc.TRANSITION_TYPED);
add_visit(nonvisited_URIs[1], histsvc.TRANSITION_BOOKMARK);
add_visit(nonvisited_URIs[2], histsvc.TRANSITION_LINK);
add_visit(nonvisited_URIs[3], histsvc.TRANSITION_DOWNLOAD);
add_visit(nonvisited_URIs[4], histsvc.TRANSITION_EMBED);
add_visit(nonvisited_URIs[5], histsvc.TRANSITION_FRAMED_LINK);
add_visit(nonvisited_URIs[6], histsvc.TRANSITION_REDIRECT_PERMANENT);
add_visit(nonvisited_URIs[7], histsvc.TRANSITION_REDIRECT_TEMPORARY);
PlacesUtils.history.runInBatchMode({
runBatched: function (aUserData) {
add_visit(nonvisited_URIs[0], PlacesUtils.history.TRANSITION_TYPED);
add_visit(nonvisited_URIs[1], PlacesUtils.history.TRANSITION_BOOKMARK);
add_visit(nonvisited_URIs[2], PlacesUtils.history.TRANSITION_LINK);
add_visit(nonvisited_URIs[3], PlacesUtils.history.TRANSITION_DOWNLOAD);
add_visit(nonvisited_URIs[4], PlacesUtils.history.TRANSITION_EMBED);
add_visit(nonvisited_URIs[5], PlacesUtils.history.TRANSITION_FRAMED_LINK);
add_visit(nonvisited_URIs[6], PlacesUtils.history.TRANSITION_REDIRECT_PERMANENT);
add_visit(nonvisited_URIs[7], PlacesUtils.history.TRANSITION_REDIRECT_TEMPORARY);
}
}, null);
}
// Initial batch of history items (7) + Bookmark_A (1)
// This number should not change after tests enter private browsing
// it will be set to 10 with the addition of Bookmark-B during private
// browsing mode.
var num_places_entries = 9;
let num_places_entries = 8;
/**
* Function performs a really simple query on our places entries,
* and makes sure that the number of entries equal num_places_entries.
*
* @returns nothing
*/
function check_placesItem_Count(){
// get bookmarks count
var options = histsvc.getNewQueryOptions();
let options = PlacesUtils.history.getNewQueryOptions();
options.includeHidden = true;
options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
var query = histsvc.getNewQuery();
var result = histsvc.executeQuery(query, options);
var root = result.root;
let root = PlacesUtils.history.executeQuery(PlacesUtils.history.getNewQuery(),
options).root;
root.containerOpen = true;
var cc = root.childCount;
let cc = root.childCount;
root.containerOpen = false;
// get history item count
options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY;
query = histsvc.getNewQuery();
result = histsvc.executeQuery(query, options);
root = result.root;
let root = PlacesUtils.history.executeQuery(PlacesUtils.history.getNewQuery(),
options).root;
root.containerOpen = true;
cc += root.childCount;
root.containerOpen = false;
@ -202,13 +170,14 @@ function check_placesItem_Count(){
* @returns the bookmark
*/
var myBookmarks=new Array(2); // Bookmark-A
// Bookmark-B
let myBookmarks = new Array(2); // Bookmark-A and Bookmark-B
function create_bookmark(aURI, aTitle, aKeyword) {
var bookmarkID = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder,aURI,
bmsvc.DEFAULT_INDEX,aTitle);
bmsvc.setKeywordForBookmark(bookmarkID,aKeyword);
let bookmarkID = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.bookmarksMenuFolderId,
aURI,
PlacesUtils.bookmarks.DEFAULT_INDEX,
aTitle);
PlacesUtils.bookmarks.setKeywordForBookmark(bookmarkID, aKeyword);
return bookmarkID;
}
@ -221,121 +190,131 @@ function create_bookmark(aURI, aTitle, aKeyword) {
*/
function is_bookmark_A_altered(){
var options = histsvc.getNewQueryOptions();
let options = PlacesUtils.history.getNewQueryOptions();
options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
options.maxResults = 1; // should only expect Bookmark-A
options.resultType = options.RESULT_TYPE_VISIT;
var query = histsvc.getNewQuery();
query.setFolders([bmsvc.bookmarksMenuFolder],1);
var result = histsvc.executeQuery(query, options);
var root = result.root;
let query = PlacesUtils.history.getNewQuery();
query.setFolders([PlacesUtils.bookmarks.bookmarksMenuFolder],1);
let root = PlacesUtils.history.executeQuery(query, options).root;
root.containerOpen = true;
do_check_eq(root.childCount,options.maxResults);
var node = root.getChild(0);
let node = root.getChild(0);
root.containerOpen = false;
return (node.accessCount!=0);
}
function run_test() {
// Fetch the private browsing service
var pb = get_PBSvc();
if (pb) { // Private Browsing might not be available
do_test_pending();
Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true);
var bookmark_A_URI = NetUtil.newURI("http://google.com/");
var bookmark_B_URI = NetUtil.newURI("http://bugzilla.mozilla.org/");
var onBookmarkAAdded = function() {
check_placesItem_Count();
// Bookmark-A should be bookmarked, data should be retrievable
do_check_true(bmsvc.isBookmarked(bookmark_A_URI));
do_check_eq("google", bmsvc.getKeywordForURI(bookmark_A_URI));
// Enter Private Browsing Mode
pb.privateBrowsingEnabled = true;
// History items should not retrievable by isVisited
for each(var visited_uri in visited_URIs)
do_check_false(bhist.isVisited(uri(visited_uri)));
// Check if Bookmark-A has been visited, should be false
do_check_false(is_bookmark_A_altered());
// Add a second set of history items during private browsing mode
// should not be viewed/stored or in any way retrievable
fill_history_nonvisitedURI();
for each(var nonvisited_uri in nonvisited_URIs) {
do_check_false(uri_in_db(uri(nonvisited_uri)));
do_check_false(bhist.isVisited(uri(nonvisited_uri)));
}
// We attempted to add another 7 new entires, but we still have 7 history entries
// and 1 history entry, Bookmark-A.
// Private browsing blocked the entry of the new history entries
check_placesItem_Count();
// Check if Bookmark-A is still accessible
do_check_true(bmsvc.isBookmarked(bookmark_A_URI));
do_check_eq("google",bmsvc.getKeywordForURI(bookmark_A_URI));
// Create Bookmark-B
myBookmarks[1] = create_bookmark(bookmark_B_URI,"title 2", "bugzilla");
onBookmarkBAdded();
};
var onBookmarkBAdded = function() {
// A check on the history count should be same as before, 7 history entries with
// now 2 bookmark items (A) and bookmark (B), so we set num_places_entries to 9
num_places_entries = 10; // Bookmark-B successfully added but not the history entries.
check_placesItem_Count();
// Exit Private Browsing Mode
pb.privateBrowsingEnabled = false;
// Check if Bookmark-B is still accessible
do_check_true(bmsvc.isBookmarked(bookmark_B_URI));
do_check_eq("bugzilla",bmsvc.getKeywordForURI(bookmark_B_URI));
// Check if Bookmark-A is still accessible
do_check_true(bmsvc.isBookmarked(bookmark_A_URI));
do_check_eq("google",bmsvc.getKeywordForURI(bookmark_A_URI));
// Check that the original set of history items are still accessible via isVisited
for each(var visited_uri in visited_URIs) {
do_check_true(uri_in_db(uri(visited_uri)));
do_check_true(bhist.isVisited(uri(visited_uri)));
}
Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
do_test_finished();
};
// History database should be empty
do_check_false(histsvc.hasHistoryEntries);
// Create a handful of history items with various visit types
fill_history_visitedURI();
// History database should have entries
do_check_true(histsvc.hasHistoryEntries);
// Create Bookmark-A
myBookmarks[0] = create_bookmark(bookmark_A_URI,"title 1", "google");
// History items should be retrievable by query
for each(var visited_uri in visited_URIs) {
do_check_true(bhist.isVisited(uri(visited_uri)));
do_check_true(uri_in_db(uri(visited_uri)));
}
onBookmarkAAdded();
// Private Browsing might not be available.
let pb = get_PBSvc();
if (!pb) {
return;
}
do_test_pending();
Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true);
let bookmark_A_URI = NetUtil.newURI("http://google.com/");
let bookmark_B_URI = NetUtil.newURI("http://bugzilla.mozilla.org/");
let onBookmarkAAdded = function() {
check_placesItem_Count();
// Bookmark-A should be bookmarked, data should be retrievable
do_check_true(PlacesUtils.bookmarks.isBookmarked(bookmark_A_URI));
do_check_eq("google", PlacesUtils.bookmarks.getKeywordForURI(bookmark_A_URI));
// Enter Private Browsing Mode
pb.privateBrowsingEnabled = true;
// History items should not retrievable by isVisited
visited_URIs.forEach(function (visited_uri) {
do_check_false(PlacesUtils.bhistory.isVisited(uri(visited_uri)));
});
// Check if Bookmark-A has been visited, should be false
do_check_false(is_bookmark_A_altered());
// Add a second set of history items during private browsing mode
// should not be viewed/stored or in any way retrievable
fill_history_nonvisitedURI();
nonvisited_URIs.forEach(function (nonvisited_uri) {
do_check_false(!!page_in_database(nonvisited_uri));
do_check_false(PlacesUtils.bhistory.isVisited(uri(nonvisited_uri)));
});
// We attempted to add another 7 new entires, but we still have 7 history entries
// and 1 history entry, Bookmark-A.
// Private browsing blocked the entry of the new history entries
check_placesItem_Count();
// Check if Bookmark-A is still accessible
do_check_true(PlacesUtils.bookmarks.isBookmarked(bookmark_A_URI));
do_check_eq("google",PlacesUtils.bookmarks.getKeywordForURI(bookmark_A_URI));
// Create Bookmark-B
myBookmarks[1] = create_bookmark(bookmark_B_URI,"title 2", "bugzilla");
onBookmarkBAdded();
};
let onBookmarkBAdded = function() {
// A check on the history count should be same as before, 7 history entries with
// now 2 bookmark items (A) and bookmark (B), so we increase num_places_entries.
num_places_entries++; // Bookmark-B successfully added but not the history entries.
check_placesItem_Count();
// Exit Private Browsing Mode
pb.privateBrowsingEnabled = false;
// Check if Bookmark-B is still accessible
do_check_true(PlacesUtils.bookmarks.isBookmarked(bookmark_B_URI));
do_check_eq("bugzilla",PlacesUtils.bookmarks.getKeywordForURI(bookmark_B_URI));
// Check if Bookmark-A is still accessible
do_check_true(PlacesUtils.bookmarks.isBookmarked(bookmark_A_URI));
do_check_eq("google",PlacesUtils.bookmarks.getKeywordForURI(bookmark_A_URI));
// Check that the original set of history items are still accessible via isVisited
visited_URIs.forEach(function (visited_uri) {
do_check_true(PlacesUtils.bhistory.isVisited(uri(visited_uri)));
if (/embed/.test(visited_uri)) {
do_check_false(!!page_in_database(visited_uri));
}
else {
do_check_true(!!page_in_database(visited_uri));
}
});
Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
do_test_finished();
};
// History database should be empty
do_check_false(PlacesUtils.history.hasHistoryEntries);
// Create a handful of history items with various visit types
fill_history_visitedURI();
// History database should have entries
do_check_true(PlacesUtils.history.hasHistoryEntries);
// Create Bookmark-A
myBookmarks[0] = create_bookmark(bookmark_A_URI,"title 1", "google");
// History items should be retrievable by query
visited_URIs.forEach(function (visited_uri) {
do_check_true(PlacesUtils.bhistory.isVisited(uri(visited_uri)));
if (/embed/.test(visited_uri)) {
do_check_false(!!page_in_database(visited_uri));
}
else {
do_check_true(!!page_in_database(visited_uri));
}
});
onBookmarkAAdded();
}

View File

@ -39,38 +39,30 @@
*
* ***** END LICENSE BLOCK ***** */
// Get history service
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
// adds a test URI visit to the database, and checks for a valid place ID
function add_visit(aURI, aWhen, aType) {
var visitID = histsvc.addVisit(aURI,
aWhen,
null, // no referrer
aType,
false, // not redirect
0);
do_check_true(visitID > 0);
return visitID;
PlacesUtils.history.addVisit(aURI, aWhen, null, aType, false, 0);
}
const TOTAL_SITES = 20;
// main
function run_test() {
var now = Date.now() * 1000;
// add visits
for (var i=0; i < TOTAL_SITES; i++) {
var site = "http://www.test-" + i + ".com/";
var testURI = uri(site);
var testImageURI = uri(site + "blank.gif");
var when = now + (i * TOTAL_SITES);
add_visit(testURI, when, histsvc.TRANSITION_TYPED);
add_visit(testImageURI, ++when, histsvc.TRANSITION_EMBED);
add_visit(testImageURI, ++when, histsvc.TRANSITION_FRAMED_LINK);
add_visit(testURI, ++when, histsvc.TRANSITION_LINK);
}
let now = Date.now() * 1000;
PlacesUtils.history.runInBatchMode({
runBatched: function (aUserData) {
for (let i=0; i < TOTAL_SITES; i++) {
let site = "http://www.test-" + i + ".com/";
let testURI = uri(site);
let testImageURI = uri(site + "blank.gif");
let when = now + (i * TOTAL_SITES);
add_visit(testURI, when, PlacesUtils.history.TRANSITION_TYPED);
add_visit(testImageURI, ++when, PlacesUtils.history.TRANSITION_EMBED);
add_visit(testImageURI, ++when, PlacesUtils.history.TRANSITION_FRAMED_LINK);
add_visit(testURI, ++when, PlacesUtils.history.TRANSITION_LINK);
}
}
}, null);
// verify our visits AS_VISIT, ordered by date descending
// including hidden
@ -84,29 +76,26 @@ function run_test() {
// http://www.test-0.com/blank.gif
// http://www.test-0.com/
// http://www.test-0.com/
var options = histsvc.getNewQueryOptions();
let options = PlacesUtils.history.getNewQueryOptions();
options.sortingMode = options.SORT_BY_DATE_DESCENDING;
options.resultType = options.RESULTS_AS_VISIT;
options.includeHidden = true;
var query = histsvc.getNewQuery();
var result = histsvc.executeQuery(query, options);
var root = result.root;
let root = PlacesUtils.history.executeQuery(PlacesUtils.history.getNewQuery(),
options).root;
root.containerOpen = true;
var cc = root.childCount;
do_check_eq(cc, 4 * TOTAL_SITES);
for (var i = 0; i < TOTAL_SITES; i++) {
var index = i * 4;
var node = root.getChild(index);
var site = "http://www.test-" + (TOTAL_SITES - 1 - i) + ".com/";
let cc = root.childCount;
// Embed visits are not added to the database, thus they won't appear.
do_check_eq(cc, 3 * TOTAL_SITES);
for (let i = 0; i < TOTAL_SITES; i++) {
let index = i * 3;
let node = root.getChild(index);
let site = "http://www.test-" + (TOTAL_SITES - 1 - i) + ".com/";
do_check_eq(node.uri, site);
do_check_eq(node.type, options.RESULTS_AS_VISIT);
node = root.getChild(++index);
do_check_eq(node.uri, site + "blank.gif");
do_check_eq(node.type, options.RESULTS_AS_VISIT);
node = root.getChild(++index);
do_check_eq(node.uri, site + "blank.gif");
do_check_eq(node.type, options.RESULTS_AS_VISIT);
node = root.getChild(++index);
do_check_eq(node.uri, site);
do_check_eq(node.type, options.RESULTS_AS_VISIT);
}
@ -119,20 +108,19 @@ function run_test() {
// ...
// http://www.test-0.com/
// http://www.test-0.com/
var options = histsvc.getNewQueryOptions();
let options = PlacesUtils.history.getNewQueryOptions();
options.sortingMode = options.SORT_BY_DATE_DESCENDING;
options.resultType = options.RESULTS_AS_VISIT;
var query = histsvc.getNewQuery();
var result = histsvc.executeQuery(query, options);
var root = result.root;
let root = PlacesUtils.history.executeQuery(PlacesUtils.history.getNewQuery(),
options).root;
root.containerOpen = true;
var cc = root.childCount;
let cc = root.childCount;
// 2 * TOTAL_SITES because we count the TYPED and LINK, but not EMBED or FRAMED
do_check_eq(cc, 2 * TOTAL_SITES);
for (var i=0; i < TOTAL_SITES; i++) {
var index = i * 2;
var node = root.getChild(index);
var site = "http://www.test-" + (TOTAL_SITES - 1 - i) + ".com/";
for (let i=0; i < TOTAL_SITES; i++) {
let index = i * 2;
let node = root.getChild(index);
let site = "http://www.test-" + (TOTAL_SITES - 1 - i) + ".com/";
do_check_eq(node.uri, site);
do_check_eq(node.type, options.RESULTS_AS_VISIT);
node = root.getChild(++index);
@ -148,19 +136,18 @@ function run_test() {
// http://www.test-19.com/
// ...
// http://www.test-10.com/
var options = histsvc.getNewQueryOptions();
let options = PlacesUtils.history.getNewQueryOptions();
options.sortingMode = options.SORT_BY_DATE_DESCENDING;
options.maxResults = 10;
options.resultType = options.RESULTS_AS_URI;
var query = histsvc.getNewQuery();
var result = histsvc.executeQuery(query, options);
var root = result.root;
let root = PlacesUtils.history.executeQuery(PlacesUtils.history.getNewQuery(),
options).root;
root.containerOpen = true;
var cc = root.childCount;
let cc = root.childCount;
do_check_eq(cc, options.maxResults);
for (var i=0; i < cc; i++) {
var node = root.getChild(i);
var site = "http://www.test-" + (TOTAL_SITES - 1 - i) + ".com/";
for (let i=0; i < cc; i++) {
let node = root.getChild(i);
let site = "http://www.test-" + (TOTAL_SITES - 1 - i) + ".com/";
do_check_eq(node.uri, site);
do_check_eq(node.type, options.RESULTS_AS_URI);
}
@ -173,18 +160,17 @@ function run_test() {
// http://www.test-19.com/
// ...
// http://www.test-10.com/
var options = histsvc.getNewQueryOptions();
let options = PlacesUtils.history.getNewQueryOptions();
options.sortingMode = options.SORT_BY_DATE_DESCENDING;
options.resultType = options.RESULTS_AS_URI;
var query = histsvc.getNewQuery();
var result = histsvc.executeQuery(query, options);
var root = result.root;
let root = PlacesUtils.history.executeQuery(PlacesUtils.history.getNewQuery(),
options).root;
root.containerOpen = true;
var cc = root.childCount;
let cc = root.childCount;
do_check_eq(cc, TOTAL_SITES);
for (var i=0; i < 10; i++) {
var node = root.getChild(i);
var site = "http://www.test-" + (TOTAL_SITES - 1 - i) + ".com/";
for (let i=0; i < 10; i++) {
let node = root.getChild(i);
let site = "http://www.test-" + (TOTAL_SITES - 1 - i) + ".com/";
do_check_eq(node.uri, site);
do_check_eq(node.type, options.RESULTS_AS_URI);
}

View File

@ -39,39 +39,27 @@
*
* ***** END LICENSE BLOCK ***** */
// Get history service
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
function add_visit(aURI, aType) {
var placeID = histsvc.addVisit(uri(aURI),
Date.now() * 1000,
null, // no referrer
aType,
false, // not redirect
0);
do_check_true(placeID > 0);
return placeID;
PlacesUtils.history.addVisit(uri(aURI), Date.now() * 1000, null, aType,
false, 0);
}
const TOTAL_SITES = 20;
// main
function run_test() {
// add visits
for (var i=0; i < TOTAL_SITES; i++) {
for (var j=0; j<=i; j++) {
add_visit("http://www.test-" + i + ".com/", histsvc.TRANSITION_TYPED);
// because these are embedded visits, they should not show up on our
// query results. If they do, we have a problem.
add_visit("http://www.hidden.com/hidden.gif", histsvc.TRANSITION_EMBED);
add_visit("http://www.alsohidden.com/hidden.gif", histsvc.TRANSITION_FRAMED_LINK);
PlacesUtils.history.runInBatchMode({
runBatched: function (aUserData) {
for (let i = 0; i < TOTAL_SITES; i++) {
for (let j = 0; j <= i; j++) {
add_visit("http://www.test-" + i + ".com/", TRANSITION_TYPED);
// because these are embedded visits, they should not show up on our
// query results. If they do, we have a problem.
add_visit("http://www.hidden.com/hidden.gif", TRANSITION_EMBED);
add_visit("http://www.alsohidden.com/hidden.gif", TRANSITION_FRAMED_LINK);
}
}
}
}
}, null);
// test our optimized query for the "Most Visited" item
// in the "Smart Bookmarks" folder
@ -81,19 +69,18 @@ function run_test() {
// http://www.test-19.com/
// ...
// http://www.test-10.com/
var options = histsvc.getNewQueryOptions();
let options = PlacesUtils.history.getNewQueryOptions();
options.sortingMode = options.SORT_BY_VISITCOUNT_DESCENDING;
options.maxResults = 10;
options.resultType = options.RESULTS_AS_URI;
var query = histsvc.getNewQuery();
var result = histsvc.executeQuery(query, options);
var root = result.root;
let root = PlacesUtils.history.executeQuery(PlacesUtils.history.getNewQuery(),
options).root;
root.containerOpen = true;
var cc = root.childCount;
let cc = root.childCount;
do_check_eq(cc, options.maxResults);
for (var i=0; i < cc; i++) {
var node = root.getChild(i);
var site = "http://www.test-" + (TOTAL_SITES - 1 - i) + ".com/";
for (let i = 0; i < cc; i++) {
let node = root.getChild(i);
let site = "http://www.test-" + (TOTAL_SITES - 1 - i) + ".com/";
do_check_eq(node.uri, site);
do_check_eq(node.type, options.RESULTS_AS_URI);
}
@ -106,18 +93,17 @@ function run_test() {
// http://www.test-19.com/
// ...
// http://www.test-10.com/
var options = histsvc.getNewQueryOptions();
let options = PlacesUtils.history.getNewQueryOptions();
options.sortingMode = options.SORT_BY_VISITCOUNT_DESCENDING;
options.resultType = options.RESULTS_AS_URI;
var query = histsvc.getNewQuery();
var result = histsvc.executeQuery(query, options);
var root = result.root;
let root = PlacesUtils.history.executeQuery(PlacesUtils.history.getNewQuery(),
options).root;
root.containerOpen = true;
var cc = root.childCount;
let cc = root.childCount;
do_check_eq(cc, TOTAL_SITES);
for (var i=0; i < 10; i++) {
var node = root.getChild(i);
var site = "http://www.test-" + (TOTAL_SITES - 1 - i) + ".com/";
for (let i = 0; i < 10; i++) {
let node = root.getChild(i);
let site = "http://www.test-" + (TOTAL_SITES - 1 - i) + ".com/";
do_check_eq(node.uri, site);
do_check_eq(node.type, options.RESULTS_AS_URI);
}

View File

@ -37,68 +37,56 @@
*
* ***** END LICENSE BLOCK ***** */
// Get history services
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var bhist = histsvc.QueryInterface(Ci.nsIBrowserHistory);
// adds a test URI visit to the database, and checks for a valid place ID
function add_visit(aURI, aType) {
var visitID = histsvc.addVisit(uri(aURI),
Date.now() * 1000,
null, // no referrer
aType,
false, // not redirect
0);
do_check_true(visitID > 0);
return visitID;
PlacesUtils.history.addVisit(uri(aURI), Date.now() * 1000, null, aType,
false, 0);
}
// main
function run_test() {
var count_visited_URIs = ["http://www.test-link.com/",
let count_visited_URIs = ["http://www.test-link.com/",
"http://www.test-typed.com/",
"http://www.test-bookmark.com/",
"http://www.test-redirect-permanent.com/",
"http://www.test-redirect-temporary.com/"];
var notcount_visited_URIs = ["http://www.test-embed.com/",
let notcount_visited_URIs = ["http://www.test-embed.com/",
"http://www.test-download.com/",
"http://www.test-framed.com/"];
// add visits, one for each transition type
add_visit("http://www.test-link.com/", histsvc.TRANSITION_LINK);
add_visit("http://www.test-typed.com/", histsvc.TRANSITION_TYPED);
add_visit("http://www.test-bookmark.com/", histsvc.TRANSITION_BOOKMARK);
add_visit("http://www.test-embed.com/", histsvc.TRANSITION_EMBED);
add_visit("http://www.test-framed.com/", histsvc.TRANSITION_FRAMED_LINK);
add_visit("http://www.test-redirect-permanent.com/", histsvc.TRANSITION_REDIRECT_PERMANENT);
add_visit("http://www.test-redirect-temporary.com/", histsvc.TRANSITION_REDIRECT_TEMPORARY);
add_visit("http://www.test-download.com/", histsvc.TRANSITION_DOWNLOAD);
add_visit("http://www.test-link.com/", TRANSITION_LINK);
add_visit("http://www.test-typed.com/", TRANSITION_TYPED);
add_visit("http://www.test-bookmark.com/", TRANSITION_BOOKMARK);
add_visit("http://www.test-embed.com/", TRANSITION_EMBED);
add_visit("http://www.test-framed.com/", TRANSITION_FRAMED_LINK);
add_visit("http://www.test-redirect-permanent.com/", TRANSITION_REDIRECT_PERMANENT);
add_visit("http://www.test-redirect-temporary.com/", TRANSITION_REDIRECT_TEMPORARY);
add_visit("http://www.test-download.com/", TRANSITION_DOWNLOAD);
// check that all links are marked as visited
for each(var visited_uri in count_visited_URIs)
do_check_eq(bhist.isVisited(uri(visited_uri)), true);
for each(var visited_uri in notcount_visited_URIs)
do_check_eq(bhist.isVisited(uri(visited_uri)), true);
count_visited_URIs.forEach(function (visited_uri) {
do_check_eq(PlacesUtils.bhistory.isVisited(uri(visited_uri)), true);
});
notcount_visited_URIs.forEach(function (visited_uri) {
do_check_eq(PlacesUtils.bhistory.isVisited(uri(visited_uri)), true);
});
// check that visit_count does not take in count embed and downloads
// maxVisits query are directly binded to visit_count
var options = histsvc.getNewQueryOptions();
let options = PlacesUtils.history.getNewQueryOptions();
options.sortingMode = options.SORT_BY_VISITCOUNT_DESCENDING;
options.resultType = options.RESULTS_AS_VISIT;
options.includeHidden = true;
var query = histsvc.getNewQuery();
let query = PlacesUtils.history.getNewQuery();
query.minVisits = 1;
var result = histsvc.executeQuery(query, options);
var root = result.root;
let root = PlacesUtils.history.executeQuery(query, options).root;
root.containerOpen = true;
var cc = root.childCount;
let cc = root.childCount;
do_check_eq(cc, count_visited_URIs.length);
for (var i = 0; i < cc; i++) {
var node = root.getChild(i);
for (let i = 0; i < cc; i++) {
let node = root.getChild(i);
do_check_neq(count_visited_URIs.indexOf(node.uri), -1);
}
root.containerOpen = false;

View File

@ -36,35 +36,35 @@
*
* ***** END LICENSE BLOCK ***** */
// Get services
var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var mDBConn = hs.QueryInterface(Ci.nsPIPlacesDatabase).DBConnection;
// Cache actual visit_count value, filled by add_visit, used by check_results
var visit_count = 0;
let visit_count = 0;
function add_visit(aURI, aVisitDate, aVisitType) {
var isRedirect = aVisitType == hs.TRANSITION_REDIRECT_PERMANENT ||
aVisitType == hs.TRANSITION_REDIRECT_TEMPORARY;
var visitId = hs.addVisit(aURI, aVisitDate, null,
aVisitType, isRedirect, 0);
do_check_true(visitId > 0);
let isRedirect = aVisitType == TRANSITION_REDIRECT_PERMANENT ||
aVisitType == TRANSITION_REDIRECT_TEMPORARY;
let visitId = PlacesUtils.history.addVisit(aURI, aVisitDate, null,
aVisitType, isRedirect, 0);
// Increase visit_count if applicable
if (aVisitType != 0 &&
aVisitType != hs.TRANSITION_EMBED &&
aVisitType != hs.TRANSITION_FRAMED_LINK &&
aVisitType != hs.TRANSITION_DOWNLOAD)
aVisitType != TRANSITION_EMBED &&
aVisitType != TRANSITION_FRAMED_LINK &&
aVisitType != TRANSITION_DOWNLOAD) {
visit_count ++;
}
// Get the place id
var sql = "SELECT place_id FROM moz_historyvisits WHERE id = ?1";
var stmt = mDBConn.createStatement(sql);
stmt.bindInt64Parameter(0, visitId);
do_check_true(stmt.executeStep());
var placeId = stmt.getInt64(0);
stmt.finalize();
do_check_true(placeId > 0);
return placeId;
if (visitId > 0) {
let sql = "SELECT place_id FROM moz_historyvisits WHERE id = ?1";
let stmt = DBConn().createStatement(sql);
stmt.bindInt64Parameter(0, visitId);
do_check_true(stmt.executeStep());
let placeId = stmt.getInt64(0);
stmt.finalize();
do_check_true(placeId > 0);
return placeId;
}
return 0;
}
/**
@ -75,14 +75,13 @@ function add_visit(aURI, aVisitDate, aVisitType) {
* Number of history results we are expecting (included hidden ones)
*/
function check_results(aExpectedCount, aExpectedCountWithHidden) {
var query = hs.getNewQuery();
let query = PlacesUtils.history.getNewQuery();
// used to check visit_count
query.minVisits = visit_count;
query.maxVisits = visit_count;
var options = hs.getNewQueryOptions();
let options = PlacesUtils.history.getNewQueryOptions();
options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY;
var result = hs.executeQuery(query, options);
var root = result.root;
let root = PlacesUtils.history.executeQuery(query, options).root;
root.containerOpen = true;
// Children without hidden ones
do_check_eq(root.childCount, aExpectedCount);
@ -91,8 +90,7 @@ function check_results(aExpectedCount, aExpectedCountWithHidden) {
// Execute again with includeHidden = true
// This will ensure visit_count is correct
options.includeHidden = true;
result = hs.executeQuery(query, options);
var root = result.root;
root = PlacesUtils.history.executeQuery(query, options).root;
root.containerOpen = true;
// Children with hidden ones
do_check_eq(root.childCount, aExpectedCountWithHidden);
@ -101,24 +99,24 @@ function check_results(aExpectedCount, aExpectedCountWithHidden) {
// main
function run_test() {
var testURI = uri("http://test.mozilla.org/");
const TEST_URI = uri("http://test.mozilla.org/");
// Add a visit that force hidden
var placeId = add_visit(testURI, Date.now()*1000, hs.TRANSITION_EMBED);
add_visit(TEST_URI, Date.now()*1000, TRANSITION_EMBED);
check_results(0, 0);
let placeId = add_visit(TEST_URI, Date.now()*1000, TRANSITION_FRAMED_LINK);
check_results(0, 1);
var placeId = add_visit(testURI, Date.now()*1000, hs.TRANSITION_FRAMED_LINK);
check_results(0, 1);
// Add a visit that force unhide and check place id
// Add a visit that force unhide and check the place id.
// - We expect that the place gets hidden = 0 while retaining the same
// place_id and a correct visit_count.
do_check_eq(add_visit(testURI, Date.now()*1000, hs.TRANSITION_TYPED), placeId);
// place id and a correct visit_count.
do_check_eq(add_visit(TEST_URI, Date.now()*1000, TRANSITION_TYPED), placeId);
check_results(1, 1);
// Add a visit, check that hidden is not overwritten and check place id
// - We expect that the place has still hidden = 0, while retaining the same
// place_id and a correct visit_count.
do_check_eq(add_visit(testURI, Date.now()*1000, hs.TRANSITION_EMBED), placeId);
// Add a visit, check that hidden is not overwritten
// - We expect that the place has still hidden = 0, while retaining
// correct visit_count.
add_visit(TEST_URI, Date.now()*1000, TRANSITION_EMBED);
check_results(1, 1);
}

View File

@ -44,57 +44,45 @@
* appear but TRANSITION_EMBED and TRANSITION_FRAMED_LINK ones.
*/
var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
// adds a test URI visit to the database, and checks for a valid visitId
function add_visit(aURI, aType) {
var visitId = hs.addVisit(uri(aURI),
Date.now() * 1000,
null, // no referrer
aType,
false, // not redirect
0);
do_check_true(visitId > 0);
return visitId;
PlacesUtils.history.addVisit(uri(aURI), Date.now() * 1000, null, aType,
false, 0);
}
var transitions = [ hs.TRANSITION_LINK,
hs.TRANSITION_TYPED,
hs.TRANSITION_BOOKMARK,
hs.TRANSITION_EMBED,
hs.TRANSITION_FRAMED_LINK,
hs.TRANSITION_REDIRECT_PERMANENT,
hs.TRANSITION_REDIRECT_TEMPORARY,
hs.TRANSITION_DOWNLOAD ];
let transitions = [
TRANSITION_LINK
, TRANSITION_TYPED
, TRANSITION_BOOKMARK
, TRANSITION_EMBED
, TRANSITION_FRAMED_LINK
, TRANSITION_REDIRECT_PERMANENT
, TRANSITION_REDIRECT_TEMPORARY
, TRANSITION_DOWNLOAD
];
function runQuery(aResultType) {
var options = hs.getNewQueryOptions();
let options = PlacesUtils.history.getNewQueryOptions();
options.resultType = aResultType;
var query = hs.getNewQuery();
var result = hs.executeQuery(query, options);
var root = result.root;
let root = PlacesUtils.history.executeQuery(PlacesUtils.history.getNewQuery(),
options).root;
root.containerOpen = true;
var cc = root.childCount;
do_check_eq(cc, transitions.length-2);
let cc = root.childCount;
do_check_eq(cc, transitions.length - 2);
for (var i = 0; i < cc; i++) {
var node = root.getChild(i);
for (let i = 0; i < cc; i++) {
let node = root.getChild(i);
// Check that all transition types but EMBED and FRAMED appear in results
do_check_neq(node.uri.substr(6,1), hs.TRANSITION_EMBED);
do_check_neq(node.uri.substr(6,1), hs.TRANSITION_FRAMED_LINK);
do_check_neq(node.uri.substr(6,1), TRANSITION_EMBED);
do_check_neq(node.uri.substr(6,1), TRANSITION_FRAMED_LINK);
}
root.containerOpen = false;
}
// main
function run_test() {
// add visits, one for each transition type
transitions.forEach(
function(transition) {
add_visit("http://" + transition +".mozilla.org/", transition)
});
transitions.forEach(function(transition) {
add_visit("http://" + transition +".mozilla.org/", transition);
});
runQuery(Ci.nsINavHistoryQueryOptions.RESULTS_AS_VISIT);
runQuery(Ci.nsINavHistoryQueryOptions.RESULTS_AS_URI);

View File

@ -36,59 +36,41 @@
*
* ***** END LICENSE BLOCK ***** */
// Get history service
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
/**
* Adds a test URI visit to the database, and checks for a valid place ID.
* Adds a test URI visit to history.
*
* @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_visit(aURI, aDayOffset, aTransition) {
var visitID = histsvc.addVisit(aURI,
(Date.now() + aDayOffset*86400000) * 1000,
null,
aTransition,
false, // not redirect
0);
do_check_true(visitID > 0);
return visitID;
PlacesUtils.history.addVisit(aURI, (Date.now() + aDayOffset*86400000) * 1000,
null, aTransition, false, 0);
}
// main
function run_test() {
var testURI = uri("http://mirror1.mozilla.com/a");
add_visit(testURI, -1, histsvc.TRANSITION_LINK);
testURI = uri("http://mirror2.mozilla.com/b");
add_visit(testURI, -2, histsvc.TRANSITION_LINK);
testURI = uri("http://mirror3.mozilla.com/c");
add_visit(testURI, -4, histsvc.TRANSITION_FRAMED_LINK);
testURI = uri("http://mirror1.google.com/b");
add_visit(testURI, -1, histsvc.TRANSITION_EMBED);
testURI = uri("http://mirror2.google.com/a");
add_visit(testURI, -2, histsvc.TRANSITION_LINK);
testURI = uri("http://mirror1.apache.org/b");
add_visit(testURI, -3, histsvc.TRANSITION_LINK);
testURI = uri("http://mirror2.apache.org/a");
add_visit(testURI, -4, histsvc.TRANSITION_FRAMED_LINK);
var options = histsvc.getNewQueryOptions();
var queries = [];
queries.push(histsvc.getNewQuery());
queries.push(histsvc.getNewQuery());
add_visit(uri("http://mirror1.mozilla.com/a"), -1, TRANSITION_LINK);
add_visit(uri("http://mirror2.mozilla.com/b"), -2, TRANSITION_LINK);
add_visit(uri("http://mirror3.mozilla.com/c"), -4, TRANSITION_FRAMED_LINK);
add_visit(uri("http://mirror1.google.com/b"), -1, TRANSITION_EMBED);
add_visit(uri("http://mirror2.google.com/a"), -2, TRANSITION_LINK);
add_visit(uri("http://mirror1.apache.org/b"), -3, TRANSITION_LINK);
add_visit(uri("http://mirror2.apache.org/a"), -4, TRANSITION_FRAMED_LINK);
let queries = [
PlacesUtils.history.getNewQuery(),
PlacesUtils.history.getNewQuery()
];
queries[0].domain = "mozilla.com";
queries[1].domain = "google.com";
var result = histsvc.executeQueries(queries, queries.length, options);
var root = result.root;
let root = PlacesUtils.history.executeQueries(
queries, queries.length, PlacesUtils.history.getNewQueryOptions()
).root;
root.containerOpen = true;
do_check_eq(root.childCount, 3);
let childCount = root.childCount;
root.containerOpen = false;
do_check_eq(childCount, 3);
}

View File

@ -389,8 +389,8 @@ function run_next_test() {
let test = gTests.shift();
print("\n ***Test: " + test.desc);
waitForClearHistory(function() {
DBConn().executeSimpleSQL("DELETE FROM moz_places");
remove_all_bookmarks();
DBConn().executeSimpleSQL("DELETE FROM moz_places");
test.run.call(test);
});
}