Bug 392401 EXPIRE_HISTORY expiration policy should be disallowed for item annotations (r=mano)

This commit is contained in:
dietrich@mozilla.com 2007-08-19 13:02:48 -07:00
Родитель a40f3ac216
Коммит 310c55c6a6
3 изменённых файлов: 28 добавлений и 7 удалений

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

@ -411,6 +411,9 @@ nsAnnotationService::SetItemAnnotation(PRInt64 aItemId,
{
NS_ENSURE_ARG(aValue);
if (aExpiration == EXPIRE_WITH_HISTORY)
return NS_ERROR_INVALID_ARG;
PRUint16 dataType;
nsresult rv = aValue->GetDataType(&dataType);
NS_ENSURE_SUCCESS(rv, rv);
@ -505,6 +508,9 @@ nsAnnotationService::SetItemAnnotationString(PRInt64 aItemId,
PRInt32 aFlags,
PRUint16 aExpiration)
{
if (aExpiration == EXPIRE_WITH_HISTORY)
return NS_ERROR_INVALID_ARG;
nsresult rv = SetAnnotationStringInternal(aItemId, PR_TRUE, aName, aValue,
aFlags, aExpiration);
NS_ENSURE_SUCCESS(rv, rv);
@ -578,6 +584,9 @@ nsAnnotationService::SetItemAnnotationInt32(PRInt64 aItemId,
PRInt32 aFlags,
PRUint16 aExpiration)
{
if (aExpiration == EXPIRE_WITH_HISTORY)
return NS_ERROR_INVALID_ARG;
nsresult rv = SetAnnotationInt32Internal(aItemId, PR_TRUE, aName, aValue,
aFlags, aExpiration);
NS_ENSURE_SUCCESS(rv, rv);
@ -651,6 +660,9 @@ nsAnnotationService::SetItemAnnotationInt64(PRInt64 aItemId,
PRInt32 aFlags,
PRUint16 aExpiration)
{
if (aExpiration == EXPIRE_WITH_HISTORY)
return NS_ERROR_INVALID_ARG;
nsresult rv = SetAnnotationInt64Internal(aItemId, PR_TRUE, aName, aValue,
aFlags, aExpiration);
NS_ENSURE_SUCCESS(rv, rv);
@ -724,6 +736,9 @@ nsAnnotationService::SetItemAnnotationDouble(PRInt64 aItemId,
PRInt32 aFlags,
PRUint16 aExpiration)
{
if (aExpiration == EXPIRE_WITH_HISTORY)
return NS_ERROR_INVALID_ARG;
nsresult rv = SetAnnotationDoubleInternal(aItemId, PR_TRUE, aName, aValue,
aFlags, aExpiration);
NS_ENSURE_SUCCESS(rv, rv);
@ -804,6 +819,9 @@ nsAnnotationService::SetItemAnnotationBinary(PRInt64 aItemId,
PRInt32 aFlags,
PRUint16 aExpiration)
{
if (aExpiration == EXPIRE_WITH_HISTORY)
return NS_ERROR_INVALID_ARG;
nsresult rv = SetAnnotationBinaryInternal(aItemId, PR_TRUE, aName, aData,
aDataLen, aMimeType, aFlags,
aExpiration);

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

@ -333,5 +333,14 @@ function run_test() {
catch(ex) { }
}
// setting an annotation with EXPIRE_HISTORY for an item should throw
var itemId = bmsvc.insertBookmark(bmsvc.bookmarksRoot, testURI, -1, "");
try {
annosvc.setItemAnnotation(itemId, "foo", "bar", 0, annosvc.EXPIRE_WITH_HISTORY);
do_throw("setting an item annotation with EXPIRE_HISTORY should throw");
}
catch(ex) {
}
annosvc.removeObserver(annoObserver);
}

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

@ -172,24 +172,18 @@ function run_test() {
// 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);
/*
test anno expiration (expire with history)
*/
histsvc.addVisit(testURI, Date.now(), 0, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_WITH_HISTORY);
annosvc.setItemAnnotation(bookmark, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_WITH_HISTORY);
histsvc.removeAllPages();
try {
annosvc.getPageAnnotation(testURI, testAnnoName);
do_throw("page still had expire_with_history anno");
} catch(ex) {}
try {
annosvc.getItemAnnotation(bookmark, testAnnoName);
} catch(ex) {
do_throw("bookmark lost it's expire_with_history anno when history was cleared!");
}
annosvc.removeItemAnnotation(bookmark, testAnnoName);
/*
test anno expiration (days)