Bug 317472 - "Save custom encoding (last charset) in annotation service" [p=mak77@supereva.it (Marco Bonardo [mak77]) r=dietrich r=Mano a=blocking-firefox3+]

This commit is contained in:
reed%reedloden.com 2008-04-08 18:41:08 +00:00
Родитель 2edc65396e
Коммит fda0a4c9e3
18 изменённых файлов: 465 добавлений и 150 удалений

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

@ -388,9 +388,11 @@ var PlacesCommandHook = {
var url = webNav.currentURI;
var title;
var description;
var charset;
try {
title = webNav.document.title || url.spec;
description = PlacesUIUtils.getDescriptionFromDocument(webNav.document);
charset = webNav.document.characterSet;
}
catch (e) { }
@ -407,6 +409,9 @@ var PlacesCommandHook = {
var txn = PlacesUIUtils.ptm.createItem(uri, parent, -1,
title, null, [descAnno]);
PlacesUIUtils.ptm.doTransaction(txn);
// Set the character-set
if (charset)
PlacesUtils.history.setCharsetForURI(uri, charset);
itemId = PlacesUtils.getMostRecentBookmarkForURI(uri);
}

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

@ -1759,7 +1759,12 @@ function getShortcutOrURI(aURL, aPostDataRef) {
if (matches)
[, shortcutURL, charset] = matches;
else {
//XXX Bug 317472 will add lastCharset support to places.
// Try to get the saved character-set.
try {
// makeURI throws if URI is invalid.
// Will return an empty string if character-set is not found.
charset = PlacesUtils.history.getCharsetForURI(makeURI(shortcutURL));
} catch (e) {}
}
var encodedParam = "";
@ -5089,6 +5094,8 @@ function BrowserSetForcedCharacterSet(aCharset)
var docCharset = getBrowser().docShell.QueryInterface(
Components.interfaces.nsIDocCharset);
docCharset.charset = aCharset;
// Save the forced character-set
PlacesUtils.history.setCharsetForURI(getWebNavigation().currentURI, aCharset);
BrowserReloadWithFlags(nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
}
@ -5757,11 +5764,13 @@ function AddKeywordForSearchField()
{
var node = document.popupNode;
var charset = node.ownerDocument.characterSet;
var docURI = makeURI(node.ownerDocument.URL,
node.ownerDocument.characterSet);
charset);
var formURI = makeURI(node.form.getAttribute("action"),
node.ownerDocument.characterSet,
charset,
docURI);
var spec = formURI.spec;
@ -5810,7 +5819,7 @@ function AddKeywordForSearchField()
var description = PlacesUIUtils.getDescriptionFromDocument(node.ownerDocument);
PlacesUIUtils.showMinimalAddBookmarkUI(makeURI(spec), "", description, null,
null, null, "", postData);
null, null, "", postData, charset);
}
function SwitchDocumentDirection(aWindow) {

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

@ -124,6 +124,7 @@ var BookmarkPropertiesPanel = {
_microsummaries: null,
_URIList: null,
_postData: null,
_charSet: "",
// sizeToContent is not usable due to bug 90276, so we'll use resizeTo
// instead and cache the bookmarks tree view size. See WSucks in the legacy
@ -220,6 +221,8 @@ var BookmarkPropertiesPanel = {
this._bookmarkKeyword = dialogInfo.keyword;
if ("postData" in dialogInfo)
this._postData = dialogInfo.postData;
if ("charSet" in dialogInfo)
this._charSet = dialogInfo.charSet;
}
break;
@ -936,6 +939,9 @@ var BookmarkPropertiesPanel = {
PlacesUIUtils.ptm.editBookmarkPostData(-1, this._postData));
}
if (this._charSet)
PlacesUtils.history.setCharsetForURI(this._bookmarkURI, this._charSet);
var transactions = [PlacesUIUtils.ptm.createItem(uri, aContainer, aIndex,
title, keyword,
annotations,

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

@ -418,6 +418,8 @@ var PlacesUIUtils = {
* will be shown in the dialog if this is used.
* @param [optional] aPostData
* POST data for POST-style keywords.
* @param [optional] aCharSet
* The character set for the bookmarked page.
* @return true if any transaction has been performed.
*
* Notes:
@ -433,7 +435,8 @@ var PlacesUIUtils = {
aShowPicker,
aLoadInSidebar,
aKeyword,
aPostData) {
aPostData,
aCharSet) {
var info = {
action: "add",
type: "bookmark"
@ -462,6 +465,8 @@ var PlacesUIUtils = {
info.keyword = aKeyword;
if (typeof(aPostData) == "string")
info.postData = aPostData;
if (typeof(aCharSet) == "string")
info.charSet = aCharSet;
}
return this._showBookmarkDialog(info);
@ -481,7 +486,8 @@ var PlacesUIUtils = {
showMinimalAddBookmarkUI:
function PU_showMinimalAddBookmarkUI(aURI, aTitle, aDescription,
aDefaultInsertionPoint, aShowPicker,
aLoadInSidebar, aKeyword, aPostData) {
aLoadInSidebar, aKeyword, aPostData,
aCharSet) {
var info = {
action: "add",
type: "bookmark",
@ -510,6 +516,8 @@ var PlacesUIUtils = {
info.keyword = aKeyword;
if (typeof(aPostData) == "string")
info.postData = aPostData;
if (typeof(aCharSet) == "string")
info.charSet = aCharSet;
}
else
info.hiddenRows.push("keyword");

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

@ -129,7 +129,6 @@ static NS_DEFINE_CID(kParserCID, NS_PARSER_CID);
#define LOAD_IN_SIDEBAR_ANNO NS_LITERAL_CSTRING("bookmarkProperties/loadInSidebar")
#define DESCRIPTION_ANNO NS_LITERAL_CSTRING("bookmarkProperties/description")
#define POST_DATA_ANNO NS_LITERAL_CSTRING("bookmarkProperties/POSTData")
#define LAST_CHARSET_ANNO NS_LITERAL_CSTRING("URIProperties/characterSet")
#define STATIC_TITLE_ANNO NS_LITERAL_CSTRING("bookmarks/staticTitle")
#define BOOKMARKS_MENU_ICON_URI "chrome://browser/skin/places/bookmarksMenu.png"
@ -987,13 +986,8 @@ BookmarkContentSink::HandleLinkBegin(const nsIParserNode& node)
// import last charset
if (!lastCharset.IsEmpty()) {
PRBool hasCharset = PR_FALSE;
mAnnotationService->ItemHasAnnotation(frame.mPreviousId,
LAST_CHARSET_ANNO, &hasCharset);
if (!hasCharset)
mAnnotationService->SetItemAnnotationString(frame.mPreviousId, LAST_CHARSET_ANNO,
lastCharset, 0,
nsIAnnotationService::EXPIRE_NEVER);
rv = mHistoryService->SetCharsetForURI(frame.mPreviousLink,lastCharset);
NS_ASSERTION(NS_SUCCEEDED(rv), "setCharsetForURI failed");
}
}
@ -1935,15 +1929,9 @@ nsPlacesImportExportService::WriteItem(nsINavHistoryResultNode* aItem,
}
// last charset
PRBool hasLastCharset = PR_FALSE;
rv = mAnnotationService->ItemHasAnnotation(itemId, LAST_CHARSET_ANNO,
&hasLastCharset);
NS_ENSURE_SUCCESS(rv, rv);
if (hasLastCharset) {
nsAutoString lastCharset;
rv = mAnnotationService->GetItemAnnotationString(itemId, LAST_CHARSET_ANNO,
lastCharset);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString lastCharset;
if (NS_SUCCEEDED(mHistoryService->GetCharsetForURI(pageURI, lastCharset)) &&
!lastCharset.IsEmpty()) {
rv = aOutput->Write(kLastCharsetAttribute, sizeof(kLastCharsetAttribute)-1, &dummy);
NS_ENSURE_SUCCESS(rv, rv);
char* escapedLastCharset = nsEscapeHTML(NS_ConvertUTF16toUTF8(lastCharset).get());

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

@ -39,7 +39,6 @@
const LOAD_IN_SIDEBAR_ANNO = "bookmarkProperties/loadInSidebar";
const DESCRIPTION_ANNO = "bookmarkProperties/description";
const POST_DATA_ANNO = "bookmarkProperties/POSTData";
const LAST_CHARSET_ANNO = "URIProperties/characterSet";
Components.utils.import("resource://gre/modules/utils.js");
do_check_eq(typeof PlacesUtils, "object");
@ -209,10 +208,10 @@ function testCanonicalBookmarks() {
do_check_eq("hidden1%3Dbar&text1%3D%25s",
PlacesUtils.annotations.getItemAnnotation(testBookmark1.itemId, POST_DATA_ANNO));
// last charset
do_check_true(PlacesUtils.annotations.itemHasAnnotation(testBookmark1.itemId, LAST_CHARSET_ANNO));
do_check_eq("ISO-8859-1", PlacesUtils.annotations.getItemAnnotation(testBookmark1.itemId,
LAST_CHARSET_ANNO));
// last charset
var testURI = PlacesUtils._uri(testBookmark1.uri);
do_check_eq("ISO-8859-1", PlacesUtils.history.getCharsetForURI(testURI));
// description
do_check_true(PlacesUtils.annotations.itemHasAnnotation(testBookmark1.itemId,
DESCRIPTION_ANNO));

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

@ -81,7 +81,6 @@ try {
const DESCRIPTION_ANNO = "bookmarkProperties/description";
const LOAD_IN_SIDEBAR_ANNO = "bookmarkProperties/loadInSidebar";
const POST_DATA_ANNO = "bookmarkProperties/POSTData";
const LAST_CHARSET_ANNO = "URIProperties/characterSet";
// main
function run_test() {
@ -247,10 +246,9 @@ function testCanonicalBookmarks(aFolder) {
annosvc.getItemAnnotation(testBookmark1.itemId, POST_DATA_ANNO));
// last charset
do_check_true(annosvc.itemHasAnnotation(testBookmark1.itemId,
LAST_CHARSET_ANNO));
do_check_eq("ISO-8859-1", annosvc.getItemAnnotation(testBookmark1.itemId,
LAST_CHARSET_ANNO));
var testURI = uri(testBookmark1.uri);
do_check_eq("ISO-8859-1", histsvc.getCharsetForURI(testURI));
// description
do_check_true(annosvc.itemHasAnnotation(testBookmark1.itemId,
DESCRIPTION_ANNO));

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

@ -90,11 +90,14 @@ interface nsIAnnotationService : nsISupports
// Removed at 180 days.
const unsigned short EXPIRE_MONTHS = 3;
// For data that should never expire. Must be explictly removed.
// For annotations that only live as long as the URI is in the database.
// A page annotation will expire if the page has no visits
// and is not bookmarked.
// An item annotation will expire when the item is deleted.
const unsigned short EXPIRE_NEVER = 4;
// For annotations that only live as long as the URI is in history
// (eg: Has >0 visits).
// For annotations that only live as long as the URI has visits.
// Valid only for page annotations.
const unsigned short EXPIRE_WITH_HISTORY = 5;
// For short-lived temporary data that you still want to outlast a session.

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

@ -1045,7 +1045,7 @@ interface nsINavHistoryQueryOptions : nsISupports
nsINavHistoryQueryOptions clone();
};
[scriptable, uuid(1972ac40-d270-40ee-995a-c97d02849596)]
[scriptable, uuid(8b258ff6-b591-4da5-8b7c-0665b27d09cc)]
interface nsINavHistoryService : nsISupports
{
/**
@ -1104,7 +1104,6 @@ interface nsINavHistoryService : nsISupports
*/
AString getPageTitle(in nsIURI aURI);
/**
* This is just like markPageAsTyped (in nsIBrowserHistory, also implemented
* by the history service), but for bookmarks. It declares that the given URI
@ -1114,6 +1113,25 @@ interface nsINavHistoryService : nsISupports
*/
void markPageAsFollowedBookmark(in nsIURI aURI);
/**
* Gets the stored character-set for an URI.
*
* @param aURI
* URI to retrieve character-set for
* @returns character-set, empty string if not found
*/
AString getCharsetForURI(in nsIURI aURI);
/**
* Sets the character-set for an URI.
*
* @param aURI
* URI to set the character-set for
* @param aCharset
* character-set to be set
*/
void setCharsetForURI(in nsIURI aURI, in AString aCharset);
/**
* Returns true if this URI would be added to the history. You don't have to
* worry about calling this, addPageToSession/addURI will always check before

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

@ -72,6 +72,7 @@ REQUIRES = xpcom \
txmgr \
nkcache \
widget \
chardet \
$(NULL)
CPPSRCS = \

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

@ -208,6 +208,9 @@
#define DB_MIGRATION_CREATED 1
#define DB_MIGRATION_UPDATED 2
// character-set annotation
#define CHARSET_ANNO NS_LITERAL_CSTRING("URIProperties/characterSet")
NS_IMPL_ADDREF(nsNavHistory)
NS_IMPL_RELEASE(nsNavHistory)
@ -219,6 +222,7 @@ NS_INTERFACE_MAP_BEGIN(nsNavHistory)
NS_INTERFACE_MAP_ENTRY(nsIBrowserHistory)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsICharsetResolver)
#ifdef MOZ_XUL
NS_INTERFACE_MAP_ENTRY(nsIAutoCompleteSearch)
NS_INTERFACE_MAP_ENTRY(nsIAutoCompleteSimpleResultListener)
@ -3647,8 +3651,8 @@ nsNavHistory::RemovePagesInternal(const nsCString& aPlaceIdsQueryString)
// this will remove all expire-able annotations for these URIs.
(void)mExpire.OnDeleteURI();
// if there are no more annotations, and the entry is not bookmarked
// then we can remove the moz_places entry.
// if the entry is not bookmarked and is not a place: uri
// then we can remove it from moz_places.
// Note that we do NOT delete favicons. Any unreferenced favicons will be
// deleted next time the browser is shut down.
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
@ -3656,8 +3660,8 @@ nsNavHistory::RemovePagesInternal(const nsCString& aPlaceIdsQueryString)
"SELECT h.id FROM moz_places h WHERE h.id IN (") +
aPlaceIdsQueryString +
NS_LITERAL_CSTRING(") AND "
"NOT EXISTS (SELECT b.id FROM moz_bookmarks b WHERE b.fk = h.id) AND "
"NOT EXISTS (SELECT a.id FROM moz_annos a WHERE a.place_id = h.id))"));
"NOT EXISTS (SELECT b.id FROM moz_bookmarks b WHERE b.fk = h.id LIMIT 1) "
"AND SUBSTR(h.url,0,6) <> 'place:')"));
NS_ENSURE_SUCCESS(rv, rv);
// placeId could have a livemark item, so setting the frecency to -1
@ -4003,6 +4007,57 @@ nsNavHistory::MarkPageAsTyped(nsIURI *aURI)
return NS_OK;
}
// nsNavHistory::SetCharsetForURI
//
// Sets the character-set for an URI.
// If aCharset is empty remove character-set annotation for aURI.
NS_IMETHODIMP
nsNavHistory::SetCharsetForURI(nsIURI* aURI,
const nsAString& aCharset)
{
nsAnnotationService* annosvc = nsAnnotationService::GetAnnotationService();
NS_ENSURE_TRUE(annosvc, NS_ERROR_OUT_OF_MEMORY);
if (aCharset.IsEmpty()) {
// remove the current page character-set annotation
nsresult rv = annosvc->RemovePageAnnotation(aURI, CHARSET_ANNO);
NS_ENSURE_SUCCESS(rv, rv);
}
else {
// Set page character-set annotation, silently overwrite if already exists
nsresult rv = annosvc->SetPageAnnotationString(aURI, CHARSET_ANNO,
aCharset, 0,
nsAnnotationService::EXPIRE_NEVER);
NS_ENSURE_SUCCESS(rv, rv);
}
return NS_OK;
}
// nsNavHistory::GetCharsetForURI
//
// Get the last saved character-set for an URI.
NS_IMETHODIMP
nsNavHistory::GetCharsetForURI(nsIURI* aURI,
nsAString& aCharset)
{
nsAnnotationService* annosvc = nsAnnotationService::GetAnnotationService();
NS_ENSURE_TRUE(annosvc, NS_ERROR_OUT_OF_MEMORY);
nsAutoString charset;
nsresult rv = annosvc->GetPageAnnotationString(aURI, CHARSET_ANNO, aCharset);
if (NS_FAILED(rv)) {
// be sure to return an empty string if character-set is not found
aCharset.Truncate();
}
return NS_OK;
}
// nsGlobalHistory2 ************************************************************
@ -6425,3 +6480,36 @@ nsNavHistory::RecalculateFrecenciesInternal(mozIStorageStatement *aStatement, PR
return NS_OK;
}
// nsICharsetResolver **********************************************************
NS_IMETHODIMP
nsNavHistory::RequestCharset(nsIWebNavigation* aWebNavigation,
nsIChannel* aChannel,
PRBool* aWantCharset,
nsISupports** aClosure,
nsACString& aResult)
{
*aWantCharset = PR_FALSE;
*aClosure = nsnull;
nsCOMPtr<nsIURI> uri;
nsresult rv = aChannel->GetURI(getter_AddRefs(uri));
if (NS_FAILED(rv))
return NS_OK;
nsAutoString charset;
rv = GetCharsetForURI(uri, charset);
NS_ENSURE_SUCCESS(rv, rv);
CopyUTF16toUTF8(charset, aResult);
return NS_OK;
}
NS_IMETHODIMP
nsNavHistory::NotifyResolvedCharset(const nsACString& aCharset,
nsISupports* aClosure)
{
NS_ERROR("Unexpected call to NotifyResolvedCharset -- we never set aWantCharset to true!");
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -86,6 +86,8 @@
#include "nsNavHistoryResult.h"
#include "nsNavHistoryQuery.h"
#include "nsICharsetResolver.h"
// set to use more optimized (in-memory database) link coloring
//#define IN_MEMORY_LINKS
@ -122,7 +124,8 @@ class nsNavHistory : public nsSupportsWeakReference,
public nsIObserver,
public nsIBrowserHistory,
public nsIGlobalHistory3,
public nsIDownloadHistory
public nsIDownloadHistory,
public nsICharsetResolver
#ifdef MOZ_XUL
, public nsIAutoCompleteSearch,
public nsIAutoCompleteSimpleResultListener
@ -411,6 +414,9 @@ protected:
nsCOMPtr<mozIStorageStatement> mDBUrlToUrlResult; // kGetInfoIndex_* results
nsCOMPtr<mozIStorageStatement> mDBBookmarkToUrlResult; // kGetInfoIndex_* results
// nsICharsetResolver
NS_DECL_NSICHARSETRESOLVER
/**
* Recalculates aCount frecencies. If aRecalcOld, it will also calculate
* the frecency of aCount history visits that have not occurred recently.

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

@ -599,8 +599,8 @@ nsNavHistoryExpire::EraseVisits(mozIStorageConnection* aConnection,
// nsNavHistoryExpire::EraseHistory
//
// This erases records in moz_places when there are no more visits.
// We need to be careful not to delete bookmarks, place:URIs and
// URIs with EXPIRE_NEVER annotations.
// We need to be careful not to delete: bookmarks, items that still have
// visits and place: URIs.
//
// This will modify the input by setting the erased flag on each of the
// array elements according to whether the history item was erased or not.
@ -635,12 +635,13 @@ nsNavHistoryExpire::EraseHistory(mozIStorageConnection* aConnection,
NS_LITERAL_CSTRING("DELETE FROM moz_places WHERE id IN( "
"SELECT h.id "
"FROM moz_places h "
"LEFT OUTER JOIN moz_historyvisits v ON v.place_id = h.id "
"LEFT OUTER JOIN moz_annos a ON a.place_id = h.id "
"WHERE h.id IN(") + deletedPlaceIds +
NS_LITERAL_CSTRING(") AND v.place_id IS NULL AND (a.expiration <> ") +
nsPrintfCString("%d", nsIAnnotationService::EXPIRE_NEVER) +
NS_LITERAL_CSTRING(" OR a.expiration IS NULL))"));
"WHERE h.id IN(") +
deletedPlaceIds +
NS_LITERAL_CSTRING(") AND NOT EXISTS "
"(SELECT id FROM moz_historyvisits WHERE place_id = h.id LIMIT 1) "
"AND NOT EXISTS "
"(SELECT id FROM moz_bookmarks WHERE fk = h.id LIMIT 1) "
"AND SUBSTR(h.url,0,6) <> 'place:')"));
}
@ -786,6 +787,15 @@ nsNavHistoryExpire::ExpireAnnotations(mozIStorageConnection* aConnection)
rv = expireItemsStatement->Execute();
NS_ENSURE_SUCCESS(rv, rv);
// remove EXPIRE_WITH_HISTORY annos for pages without visits
rv = aConnection->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
"DELETE FROM moz_annos WHERE expiration = ") +
nsPrintfCString("%d", nsIAnnotationService::EXPIRE_WITH_HISTORY) +
NS_LITERAL_CSTRING(" AND NOT EXISTS "
"(SELECT id FROM moz_historyvisits "
"WHERE place_id = moz_annos.place_id LIMIT 1)"));
NS_ENSURE_SUCCESS(rv, rv);
rv = transaction.Commit();
NS_ENSURE_SUCCESS(rv, rv);
@ -822,7 +832,7 @@ nsNavHistoryExpire::ExpireEmbeddedLinks(mozIStorageConnection* aConnection)
// nsNavHistoryExpire::ExpireHistoryParanoid
//
// Deletes any dangling history entries that aren't associated with any
// visits, bookmarks, EXPIRE_NEVER annotations or "place:" URIs.
// visits, bookmarks or "place:" URIs.
//
// The aMaxRecords parameter is an optional cap on the number of
// records to delete. If it's value is -1, all records will be deleted.
@ -831,15 +841,12 @@ nsresult
nsNavHistoryExpire::ExpireHistoryParanoid(mozIStorageConnection* aConnection,
PRInt32 aMaxRecords)
{
nsCAutoString query = NS_LITERAL_CSTRING(
nsCAutoString query(
"DELETE FROM moz_places WHERE id IN ("
"SELECT h.id FROM moz_places h "
"LEFT OUTER JOIN moz_historyvisits v ON h.id = v.place_id "
"LEFT OUTER JOIN moz_bookmarks b ON h.id = b.fk "
"LEFT OUTER JOIN moz_annos a ON h.id = a.place_id "
"WHERE v.id IS NULL AND b.id IS NULL AND (a.expiration != ") +
nsPrintfCString("%d", nsIAnnotationService::EXPIRE_NEVER) +
NS_LITERAL_CSTRING(" OR a.id IS NULL) AND SUBSTR(h.url,0,6) <> 'place:'");
"WHERE v.id IS NULL AND b.id IS NULL AND SUBSTR(h.url,0,6) <> 'place:'");
if (aMaxRecords != -1) {
query.AppendLiteral(" LIMIT ");
query.AppendInt(aMaxRecords);
@ -896,49 +903,47 @@ nsNavHistoryExpire::ExpireAnnotationsParanoid(mozIStorageConnection* aConnection
NS_LITERAL_CSTRING("))"));
NS_ENSURE_SUCCESS(rv, rv);
// XXX REMOVE ME BEFORE FINAL
// There was a period in which we inserted bogus charset annos during bookmark
// import, we must move them into items annos, since those pages will
// never get deleted from moz_places and that is a valid privacy concern.
// XXX REMOVE ME LATE AFTER FINAL
// Move current charset item annos to page annos.
// There was a period in which EXPIRE_NEVER annos were undeletable
// so we moved charset annos from pageAnnos to itemAnnos.
// Since this has been fixed in RC1, we can use pageAnnos for charset
// so we must revert old itemAnnos to pageAnnos.
// see bug 317472 for details.
nsCAutoString charsetAnno("URIProperties/characterSet");
// XXX REMOVE ME BEFORE FINAL
// Move current page annos to items annos for bookmarked items.
// In the migration query we use NULL as the id, since we don't know the
// new id where the annotation will be inserted
nsCOMPtr<mozIStorageStatement> migrateStatement;
// The GROUP BY is needed because we have a unique index on annos tables
// INSERT OR REPLACE is needed to overwrite existing values and not fail
nsCOMPtr<mozIStorageStatement> migrateCharsetStatement;
rv = aConnection->CreateStatement(NS_LITERAL_CSTRING(
"INSERT INTO moz_items_annos "
"SELECT null, b.id, a.anno_attribute_id, a.mime_type, a.content, "
" a.flags, a.expiration, a.type, a.dateAdded, a.lastModified "
"FROM moz_annos a "
"JOIN moz_anno_attributes n ON a.anno_attribute_id = n.id "
"JOIN moz_bookmarks b ON b.fk = a.place_id "
"WHERE b.id IS NOT NULL AND n.name = ?1 AND a.expiration = ") +
nsPrintfCString("%d", nsIAnnotationService::EXPIRE_NEVER),
getter_AddRefs(migrateStatement));
"INSERT OR REPLACE INTO moz_annos "
"SELECT null, b.fk, t.anno_attribute_id, t.mime_type, t.content, "
"t.flags, t.expiration, t.type, t.dateAdded, t.lastModified "
"FROM moz_items_annos t "
"JOIN moz_anno_attributes n ON t.anno_attribute_id = n.id "
"JOIN moz_bookmarks b ON b.id = t.item_id "
"WHERE n.name = ?1 "
"GROUP BY b.fk, t.anno_attribute_id"),
getter_AddRefs(migrateCharsetStatement));
NS_ENSURE_SUCCESS(rv, rv);
rv = migrateStatement->BindUTF8StringParameter(0, charsetAnno);
rv = migrateCharsetStatement->BindUTF8StringParameter(0, charsetAnno);
NS_ENSURE_SUCCESS(rv, rv);
rv = migrateStatement->Execute();
rv = migrateCharsetStatement->Execute();
NS_ENSURE_SUCCESS(rv, rv);
// XXX REMOVE ME BEFORE FINAL
// Delete old bogus page annos for bookmarked items
nsCOMPtr<mozIStorageStatement> cleanupStatement;
// delete old charset item annos
nsCOMPtr<mozIStorageStatement> deleteCharsetStatement;
rv = aConnection->CreateStatement(NS_LITERAL_CSTRING(
"DELETE FROM moz_annos WHERE id IN "
"(SELECT a.id FROM moz_annos a "
"JOIN moz_anno_attributes n ON a.anno_attribute_id = n.id "
"JOIN moz_bookmarks b ON b.fk = a.place_id "
"WHERE b.id IS NOT NULL AND n.name = ?1 AND a.expiration = ") +
nsPrintfCString("%d", nsIAnnotationService::EXPIRE_NEVER) +
NS_LITERAL_CSTRING(")"),
getter_AddRefs(cleanupStatement));
"DELETE FROM moz_items_annos WHERE id IN "
"(SELECT t.id FROM moz_items_annos t "
"JOIN moz_anno_attributes n ON t.anno_attribute_id = n.id "
"WHERE n.name = ?1)"),
getter_AddRefs(deleteCharsetStatement));
NS_ENSURE_SUCCESS(rv, rv);
rv = cleanupStatement->BindUTF8StringParameter(0, charsetAnno);
rv = deleteCharsetStatement->BindUTF8StringParameter(0, charsetAnno);
NS_ENSURE_SUCCESS(rv, rv);
rv = cleanupStatement->Execute();
rv = deleteCharsetStatement->Execute();
NS_ENSURE_SUCCESS(rv, rv);
// delete item annos w/o a corresponding item id

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

@ -56,6 +56,11 @@ static const nsModuleComponentInfo components[] =
NS_FAVICONSERVICE_CONTRACTID,
nsFaviconServiceConstructor },
{ "Browser History Charset Resolver",
NS_NAVHISTORYSERVICE_CID,
"@mozilla.org/embeddor.implemented/bookmark-charset-resolver;1",
nsNavHistoryConstructor },
};
NS_IMPL_NSGETMODULE(nsPlacesModule, components)

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

@ -1135,6 +1135,8 @@ var PlacesUtils = {
if (tags.length)
this.tagging.tagURI(this._uri(aData.uri), tags);
}
if (aData.charset)
this.history.setCharsetForURI(this._uri(aData.uri), aData.charset);
break;
case this.TYPE_X_MOZ_PLACE_SEPARATOR:
id = this.bookmarks.insertSeparator(aContainer, aIndex);
@ -1219,6 +1221,12 @@ var PlacesUtils = {
var tags = aIsUICommand ? aPlacesNode.tags : null;
if (tags)
aJSNode.tags = tags;
// last character-set
var uri = self._uri(aPlacesNode.uri);
var lastCharset = self.history.getCharsetForURI(uri);
if (lastCharset)
aJSNode.charset = lastCharset;
}
function addSeparatorProperties(aPlacesNode, aJSNode) {

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

@ -0,0 +1,111 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* ***** 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 Places unit test code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Marco Bonardo <mak77@supereva.it>
*
* 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 ***** */
const charset = "UTF-8";
const CHARSET_ANNO = "URIProperties/characterSet";
// Get history service
try {
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);
var annosvc = Cc["@mozilla.org/browser/annotation-service;1"].
getService(Ci.nsIAnnotationService);
} catch(ex) {
do_throw("Could not get services\n");
}
function run_test() {
do_test_pending();
var now = Date.now();
var testURI = uri("http://foo.com");
var testBookmarkedURI = uri("http://bar.com");
// add pages to history
histsvc.addVisit(testURI, now, null,
Ci.nsINavHistoryService.TRANSITION_TYPED,
false, 0);
histsvc.addVisit(testBookmarkedURI, now, null,
Ci.nsINavHistoryService.TRANSITION_TYPED,
false, 0);
// create bookmarks on testBookmarkedURI
var bm1 = bmsvc.insertBookmark(bmsvc.unfiledBookmarksFolder,
testBookmarkedURI, bmsvc.DEFAULT_INDEX,
testBookmarkedURI.spec);
var bm2 = bmsvc.insertBookmark(bmsvc.toolbarFolder,
testBookmarkedURI, bmsvc.DEFAULT_INDEX,
testBookmarkedURI.spec);
// set charset on not-bookmarked page
histsvc.setCharsetForURI(testURI, charset);
// set charset on bookmarked page
histsvc.setCharsetForURI(testBookmarkedURI, charset);
// check that we have created a page annotation
do_check_eq(annosvc.getPageAnnotation(testURI, CHARSET_ANNO), charset);
// get charset from not-bookmarked page
do_check_eq(histsvc.getCharsetForURI(testURI), charset);
// get charset from bookmarked page
do_check_eq(histsvc.getCharsetForURI(testBookmarkedURI), charset);
// clear history
bhist.removeAllPages();
// ensure that charset has gone for not-bookmarked page
do_check_neq(histsvc.getCharsetForURI(testURI), charset);
// check that page annotation has been removed
try {
annosvc.getPageAnnotation(testURI, CHARSET_ANNO);
do_throw("Charset page annotation has not been removed correctly");
} catch (e) {}
// ensure that charset still exists for bookmarked page
do_check_eq(histsvc.getCharsetForURI(testBookmarkedURI), charset);
// remove charset from bookmark and check that has gone
histsvc.setCharsetForURI(testBookmarkedURI, "");
do_check_neq(histsvc.getCharsetForURI(testBookmarkedURI), charset);
do_test_finished();
}

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

@ -159,6 +159,9 @@ function run_test() {
Ci.nsIAnnotationService.EXPIRE_NEVER);
var bookmark = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder,
deletedPages[bookmarkIndex], bmsvc.DEFAULT_INDEX, bookmarkName);
annosvc.setPageAnnotation(deletedPages[bookmarkIndex],
annoName, annoValue, 0,
Ci.nsIAnnotationService.EXPIRE_NEVER);
try {
bhist.removePages(deletedPages, deletedPages.length, false);
@ -170,10 +173,14 @@ function run_test() {
// check that bookmark and annotation still exist
do_check_eq(bmsvc.getBookmarkURI(bookmark).spec,
deletedPages[bookmarkIndex].spec);
do_check_eq(annosvc.getPageAnnotation(deletedPages[annoIndex], annoName),
do_check_eq(annosvc.getPageAnnotation(deletedPages[bookmarkIndex], annoName),
annoValue);
try {
annosvc.getPageAnnotation(deletedPages[annoIndex], annoName);
do_throw("did not expire expire_never anno on a not bookmarked item");
} catch(ex) {}
// remove annotation and bookmark
annosvc.removePageAnnotation(deletedPages[annoIndex], annoName);
annosvc.removePageAnnotation(deletedPages[bookmarkIndex], annoName);
bmsvc.removeItem(bookmark);
bhist.removeAllPages();

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

@ -23,6 +23,7 @@
* Darin Fisher <darin@meer.net>
* Dietrich Ayala <dietrich@mozilla.com>
* Dan Mills <thunder@mozilla.com>
* Marco Bonardo <mak77@supereva.it>
*
* 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
@ -38,34 +39,41 @@
*
* ***** END LICENSE BLOCK ***** */
// Get browser history service
// Get history services
try {
var bhist = Cc["@mozilla.org/browser/global-history;2"].getService(Ci.nsIBrowserHistory);
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var bhist = histsvc.QueryInterface(Ci.nsIBrowserHistory);
var ghist = Cc["@mozilla.org/browser/global-history;2"].
getService(Ci.nsIGlobalHistory2);
} catch(ex) {
do_throw("Could not get history service\n");
}
// Get navhistory 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");
}
do_throw("Could not get history services\n");
}
// Get annotation service
try {
var annosvc= Cc["@mozilla.org/browser/annotation-service;1"].getService(Ci.nsIAnnotationService);
var annosvc = Cc["@mozilla.org/browser/annotation-service;1"].
getService(Ci.nsIAnnotationService);
} catch(ex) {
do_throw("Could not get annotation service\n");
}
}
// Get bookmark service
try {
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
} catch(ex) {
do_throw("Could not get nav-bookmarks-service\n");
}
// Get prefs service
try {
var prefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
} catch(ex) {
do_throw("Could not get prefs service\n");
}
// create and add history observer
var observer = {
onBeginUpdateBatch: function() {
@ -98,13 +106,15 @@ var observer = {
histsvc.addObserver(observer, false);
// get direct db connection for date-based anno tests
var dirService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
var dirService = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
var dbFile = dirService.get("ProfD", Ci.nsIFile);
dbFile.append("places.sqlite");
var dbService = Cc["@mozilla.org/storage/service;1"].getService(Ci.mozIStorageService);
var dbService = Cc["@mozilla.org/storage/service;1"].
getService(Ci.mozIStorageService);
var dbConnection = dbService.openDatabase(dbFile);
var testURI = uri("http://mozilla.com");
var testAnnoName = "tests/expiration/history";
@ -115,76 +125,114 @@ var triggerURI = uri("http://foobar.com");
// main
function run_test() {
/*
test that nsIBrowserHistory.removePagesFromHost does remove expirable annotations
but doesn't remove bookmarks or EXPIRE_NEVER annotations.
Test that nsIBrowserHistory.removePagesFromHost removes expirable
annotations but doesn't remove bookmarks.
*/
histsvc.addVisit(testURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(testURI, testAnnoName + "Hist", testAnnoVal, 0, annosvc.EXPIRE_WITH_HISTORY);
annosvc.setPageAnnotation(testURI, testAnnoName + "Never", testAnnoVal, 0, annosvc.EXPIRE_NEVER);
bhist.removePagesFromHost("mozilla.com", false);
do_check_eq(bmsvc.getBookmarkURI(bookmark).spec, testURI.spec);
// EXPIRE_WITH_HISTORY anno should be removed since we don't have visits
try {
annosvc.getPageAnnotation(testAnnoName + "Hist");
do_throw("nsIBrowserHistory.removePagesFromHost() didn't remove an EXPIRE_WITH_HISTORY annotation");
do_throw("removePagesFromHost() didn't remove an EXPIRE_WITH_HISTORY annotation");
} catch(ex) {}
// EXPIRE_NEVER anno should be retained since the uri is bookmarked
do_check_eq(annosvc.getPageAnnotation(testURI, testAnnoName + "Never"), testAnnoVal);
// check that moz_places record was not removed for this URI (is bookmarked)
do_check_eq(histsvc.getPageTitle(testURI), "mozilla.com");
//cleanup
annosvc.removePageAnnotation(testURI, testAnnoName + "Never");
/*
test that nsIBrowserHistory.removeAllPages does remove expirable annotations
but doesn't remove bookmarks or EXPIRE_NEVER annotations.
Test that nsIBrowserHistory.removeAllPages removes expirable
annotations but doesn't remove bookmarks.
*/
var removeAllTestURI = uri("http://removeallpages.com");
var removeAllTestURINever = uri("http://removeallpagesnever.com");
histsvc.addVisit(removeAllTestURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
var bmURI = uri("http://bookmarked");
bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder, bmURI, bmsvc.DEFAULT_INDEX, "foo");
//bhist.addPageWithDetails(placeURI, "place uri", Date.now() * 1000);
var bookmark2 = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder, bmURI, bmsvc.DEFAULT_INDEX, "foo");
var placeURI = uri("place:folder=23");
bhist.addPageWithDetails(placeURI, "place uri", Date.now() * 1000);
annosvc.setPageAnnotation(removeAllTestURI, testAnnoName + "Hist", testAnnoVal, 0, annosvc.EXPIRE_WITH_HISTORY);
annosvc.setPageAnnotation(removeAllTestURINever, testAnnoName + "Never", testAnnoVal, 0, annosvc.EXPIRE_NEVER);
bhist.removeAllPages();
// both annotations should be removed since those URIs are not bookmarked
try {
annosvc.getPageAnnotation(removeAllTestURI, testAnnoName + "Hist");
do_throw("nsIBrowserHistory.removeAllPages() didn't remove an EXPIRE_WITH_HISTORY annotation");
} catch(ex) {}
// test that the moz_places record was removed for this URI
do_check_eq(histsvc.getPageTitle(removeAllTestURI), null);
try {
do_check_eq(annosvc.getPageAnnotation(removeAllTestURINever, testAnnoName + "Never"), testAnnoVal);
annosvc.removePageAnnotation(removeAllTestURINever, testAnnoName + "Never");
} catch(ex) {
do_throw("nsIBrowserHistory.removeAllPages deleted EXPIRE_NEVER annos!");
}
// test that the moz_places record was not removed for EXPIRE_NEVER anno
do_check_neq(histsvc.getPageTitle(removeAllTestURINever), null);
// for place URI
annosvc.getPageAnnotation(removeAllTestURINever, testAnnoName + "Never");
do_throw("nsIBrowserHistory.removePagesFromHost() didn't remove an EXPIRE_NEVER annotation");
} catch(ex) {}
// test that the moz_places record was not removed for place URI
do_check_neq(histsvc.getPageTitle(placeURI), null);
// for bookmarked URI
// test that the moz_places record was not removed for bookmarked URI
do_check_neq(histsvc.getPageTitle(bmURI), null);
/*
test anno expiration (expire never)
*/
histsvc.addVisit(testURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
annosvc.setItemAnnotation(bookmark, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
histsvc.removeAllPages();
// anno should still be there
do_check_eq(annosvc.getPageAnnotation(testURI, testAnnoName), testAnnoVal);
do_check_eq(annosvc.getItemAnnotation(bookmark, testAnnoName), testAnnoVal);
annosvc.removeItemAnnotation(bookmark, testAnnoName);
// cleanup
bmsvc.removeItem(bookmark2);
/*
test anno expiration (expire with history)
Test anno expiration (EXPIRE_NEVER)
- A page annotation should be expired only if the page is removed from the
database, i.e. when it has no visits and is not bookmarked
- An item annotation does not never expire
*/
histsvc.addVisit(testURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
// add page/item annotations to bookmarked uri
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
annosvc.setItemAnnotation(bookmark, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
// add page/item annotations to a not bookmarked uri
var expireNeverURI = uri("http://expiremenever.com");
histsvc.addVisit(expireNeverURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(expireNeverURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
histsvc.removeAllPages();
// check that page and item annotations are still there for bookmarked uri
do_check_eq(annosvc.getPageAnnotation(testURI, testAnnoName), testAnnoVal);
do_check_eq(annosvc.getItemAnnotation(bookmark, testAnnoName), testAnnoVal);
// check that page annotation has been removed for not bookmarked uri
try {
annosvc.getPageAnnotation(expireNeverURI, testAnnoName);
do_throw("nsIBrowserHistory.removeAllPages() didn't remove an EXPIRE_NEVER annotation");
} catch(ex) {}
// do some cleanup
annosvc.removeItemAnnotation(bookmark, testAnnoName);
annosvc.removePageAnnotation(testURI, testAnnoName);
/*
Test anno expiration (EXPIRE_WITH_HISTORY)
- A page annotation should be expired when the page has no more visits
whatever it is bookmarked or not
- An item annotation cannot have this kind of expiration
*/
// Add page anno on a bookmarked URI
histsvc.addVisit(testURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_WITH_HISTORY);
// Check that we can't add an EXPIRE_WITH_HISTORY anno to a bookmark
try {
annosvc.setItemAnnotation(bookmark, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_WITH_HISTORY);
do_throw("I was able to set an EXPIRE_WITH_HISTORY anno on a bookmark");
} catch(ex) {}
histsvc.removeAllPages();
// check that anno has been expired correctly even if the URI is bookmarked
try {
annosvc.getPageAnnotation(testURI, testAnnoName);
do_throw("page still had expire_with_history anno");
do_throw("page still had expire_with_history page anno");
} catch(ex) {}
/*
@ -442,6 +490,11 @@ function run_test() {
do_throw("bookmark lost a days anno that was modified 8 days ago");
} catch(ex) {}
// cleanup
bmsvc.removeItem(bookmark);
annosvc.removePageAnnotations(testURI);
annosvc.removePageAnnotations(triggerURI);
startIncrementalExpirationTests();
}
@ -452,9 +505,6 @@ function startIncrementalExpirationTests() {
startExpireNeither();
}
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
var ghist = Cc["@mozilla.org/browser/global-history;2"].getService(Ci.nsIGlobalHistory2);
/*
test 1: NO EXPIRATION CRITERIA MET (INSIDE SITES CAP)
@ -484,7 +534,7 @@ function startExpireNeither() {
// add data
histsvc.addVisit(testURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_WITH_HISTORY);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
// set sites cap to 2
prefs.setIntPref("browser.history_expire_sites", 2);
@ -541,7 +591,7 @@ function startExpireDaysOnly() {
// add expirable visit
histsvc.addVisit(testURI, (Date.now() - (86400 * 2 * 1000)) * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_WITH_HISTORY);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
// add un-expirable visit
histsvc.addVisit(uri("http://unexpirable.com"), (Date.now() - (86400 * 1000)) * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
@ -604,7 +654,7 @@ function startExpireBoth() {
var age = (Date.now() - (86400 * 2 * 1000)) * 1000;
dump("AGE: " + age + "\n");
histsvc.addVisit(testURI, age, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_WITH_HISTORY);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
// set sites cap to 1
prefs.setIntPref("browser.history_expire_sites", 1);
@ -615,7 +665,7 @@ function startExpireBoth() {
// trigger expiration
histsvc.addVisit(triggerURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(triggerURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_WITH_HISTORY);
annosvc.setPageAnnotation(triggerURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
// setup confirmation
do_timeout(3600, "checkExpireBoth();"); // incremental expiration timer is 3500
@ -661,7 +711,7 @@ function startExpireNeitherOver() {
// add data
histsvc.addVisit(testURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_WITH_HISTORY);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
// set sites cap to 1
prefs.setIntPref("browser.history_expire_sites", 1);
@ -672,7 +722,7 @@ function startExpireNeitherOver() {
// trigger expiration
histsvc.addVisit(triggerURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(triggerURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_WITH_HISTORY);
annosvc.setPageAnnotation(triggerURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
// setup confirmation
do_timeout(3600, "checkExpireNeitherOver();"); // incremental expiration timer is 3500
@ -716,7 +766,7 @@ function startExpireHistoryDisabled() {
// add data
histsvc.addVisit(testURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_WITH_HISTORY);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
// set date maximum to 0
prefs.setIntPref("browser.history_expire_days", 0);
@ -764,7 +814,7 @@ function startExpireBadPrefs() {
// add data
var age = (Date.now() - (86400 * 10 * 1000)) * 1000;
histsvc.addVisit(testURI, age, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_WITH_HISTORY);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
// set date minimum to 20
prefs.setIntPref("browser.history_expire_days_min", 20);