Bug 331654 - Provide a way to handle annotations values in a type-agnostic way. r=dietrich.

This commit is contained in:
mozilla.mano@sent.com 2007-07-11 02:57:59 -07:00
Родитель 42441b5442
Коммит d068e388b8
15 изменённых файлов: 417 добавлений и 286 удалений

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

@ -725,43 +725,15 @@ MicrosummaryService.prototype = {
},
_getField: function MSS__getField(aBookmarkId, aFieldName) {
var fieldValue;
switch(aFieldName) {
case FIELD_MICSUM_EXPIRATION:
fieldValue = this._ans.getItemAnnotationInt64(aBookmarkId, aFieldName);
break;
case FIELD_MICSUM_GEN_URI:
case FIELD_GENERATED_TITLE:
case FIELD_CONTENT_TYPE:
default:
fieldValue = this._ans.getItemAnnotationString(aBookmarkId, aFieldName);
break;
}
return fieldValue;
return this._ans.getItemAnnotation(aBookmarkId, aFieldName);
},
_setField: function MSS__setField(aBookmarkId, aFieldName, aFieldValue) {
switch(aFieldName) {
case FIELD_MICSUM_EXPIRATION:
this._ans.setItemAnnotationInt64(aBookmarkId,
aFieldName,
aFieldValue,
0,
this._ans.EXPIRE_NEVER);
break;
case FIELD_MICSUM_GEN_URI:
case FIELD_GENERATED_TITLE:
case FIELD_CONTENT_TYPE:
default:
this._ans.setItemAnnotationString(aBookmarkId,
aFieldName,
aFieldValue,
0,
this._ans.EXPIRE_NEVER);
break;
}
this._ans.setItemAnnotation(aBookmarkId,
aFieldName,
aFieldValue,
0,
this._ans.EXPIRE_NEVER);
},
_clearField: function MSS__clearField(aBookmarkId, aFieldName) {

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

@ -315,8 +315,8 @@ var BookmarkPropertiesPanel = {
// XXXmano: unify the two id fields
var itemId = dialogInfo.type == "bookmark" ? this._bookmarkId : this._folderId;
if (annos.itemHasAnnotation(itemId, DESCRIPTION_ANNO)) {
this._itemDescription = annos.getItemAnnotationString(itemId,
DESCRIPTION_ANNO);
this._itemDescription = annos.getItemAnnotation(itemId,
DESCRIPTION_ANNO);
}
}
},
@ -412,7 +412,7 @@ var BookmarkPropertiesPanel = {
*/
var folders = [];
for (var i=0; i < folderIds.length; i++) {
var lastUsed = annos.getItemAnnotationInt64(folderIds[i], LAST_USED_ANNO);
var lastUsed = annos.getItemAnnotation(folderIds[i], LAST_USED_ANNO);
folders.push({ folderId: folderIds[i], lastUsed: lastUsed });
}
folders.sort(function(a, b) {
@ -1118,9 +1118,9 @@ var BookmarkPropertiesPanel = {
// We'll figure out when/if to expire the annotation if it turns out
// we keep this recently-used-folders implementation
PlacesUtils.annotations
.setItemAnnotationInt64(aFolderId, LAST_USED_ANNO,
new Date().getTime(), 0,
Ci.nsIAnnotationService.EXPIRE_NEVER);
.setItemAnnotation(aFolderId, LAST_USED_ANNO,
new Date().getTime(), 0,
Ci.nsIAnnotationService.EXPIRE_NEVER);
},
newFolder: function BPP_newFolder() {

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

@ -2075,13 +2075,13 @@ PlacesEditItemDescriptionTransaction.prototype = {
if (annos.itemHasAnnotation(this.id, this.DESCRIPTION_ANNO)) {
this._oldDescription =
annos.getItemAnnotationString(this.id, this.DESCRIPTION_ANNO);
annos.getItemAnnotation(this.id, this.DESCRIPTION_ANNO);
}
if (this._newDescription) {
annos.setItemAnnotationString(this.id, this.DESCRIPTION_ANNO,
this._newDescription, 0,
this.nsIAnnotationService.EXPIRE_NEVER);
annos.setItemAnnotation(this.id, this.DESCRIPTION_ANNO,
this._newDescription, 0,
this.nsIAnnotationService.EXPIRE_NEVER);
}
else if (this._oldDescription)
annos.removeItemAnnotation(this.id, this.DESCRIPTION_ANNO);
@ -2091,9 +2091,9 @@ PlacesEditItemDescriptionTransaction.prototype = {
const annos = this.utils.annotations;
if (this._oldDescription) {
annos.setItemAnnotationString(this.id, this.DESCRIPTION_ANNO,
this._oldDescription, 0,
this.nsIAnnotationService.EXPIRE_NEVER);
annos.setItemAnnotation(this.id, this.DESCRIPTION_ANNO,
this._oldDescription, 0,
this.nsIAnnotationService.EXPIRE_NEVER);
}
else if (annos.itemHasAnnotation(this.id, this.DESCRIPTION_ANNO))
annos.removeItemAnnotation(this.id, this.DESCRIPTION_ANNO);

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

@ -168,7 +168,7 @@
// service provides no mechanism for doing so.
for (var i = 0; i < bookmarks.length; i++) {
this.__generatedTitles[bookmarks[i]] =
annotations.getItemAnnotationString(bookmarks[i], "bookmarks/generatedTitle");
annotations.getItemAnnotation(bookmarks[i], "bookmarks/generatedTitle");
}
}
@ -252,7 +252,7 @@
var siteURIString;
try {
siteURIString =
PlacesUtils.annotations.getItemAnnotationString(folder, "livemark/siteURI");
PlacesUtils.annotations.getItemAnnotation(folder, "livemark/siteURI");
}
catch (ex) {}
// end duplication
@ -913,7 +913,7 @@
NS_ASSERT(aAnnoName == "bookmarks/generatedTitle",
"annotation " + aAnnoName + ", is not 'bookmarks/generatedTitle'");
var newTitle =
PlacesUtils.annotations.getItemAnnotationString(aItemId, aAnnoName);
PlacesUtils.annotations.getItemAnnotation(aItemId, aAnnoName);
this._self._generatedTitles[aItemId] = newTitle;
this._doRebuild();
},

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

@ -1043,7 +1043,7 @@ PlacesTreeView.prototype = {
case this.COLUMN_TYPE_DESCRIPTION:
const annos = PlacesUtils.annotations;
if (annos.itemHasAnnotation(node.itemId, DESCRIPTION_ANNO))
return annos.getItemAnnotationString(node.itemId, DESCRIPTION_ANNO)
return annos.getItemAnnotation(node.itemId, DESCRIPTION_ANNO)
return "";
case this.COLUMN_TYPE_DATEADDED:
if (node.dateAdded)

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

@ -1143,25 +1143,14 @@ var PlacesUtils = {
for (var i = 0; i < annoNames.length; i++) {
var flags = {}, exp = {}, mimeType = {}, storageType = {};
annosvc.getPageAnnotationInfo(aURI, annoNames[i], flags, exp, mimeType, storageType);
switch (storageType.value) {
case annosvc.TYPE_INT32:
val = annosvc.getPageAnnotationInt32(aURI, annoNames[i]);
break;
case annosvc.TYPE_INT64:
val = annosvc.getPageAnnotationInt64(aURI, annoNames[i]);
break;
case annosvc.TYPE_DOUBLE:
val = annosvc.getPageAnnotationDouble(aURI, annoNames[i]);
break;
case annosvc.TYPE_STRING:
val = annosvc.getPageAnnotationString(aURI, annoNames[i]);
break;
case annosvc.TYPE_BINARY:
var data = {}, length = {}, mimeType = {};
annosvc.getPageAnnotationBinary(aURI, annoNames[i], data, length, mimeType);
val = data.value;
break;
if (storageType.value == annosvc.TYPE_BINARY) {
var data = {}, length = {}, mimeType = {};
annosvc.getPageAnnotationBinary(aURI, annoNames[i], data, length, mimeType);
val = data.value;
}
else
val = annosvc.getPageAnnotation(aURI, annoNames[i]);
annos.push({name: annoNames[i],
flags: flags.value,
expires: exp.value,
@ -1173,7 +1162,7 @@ var PlacesUtils = {
},
/**
* Fetch all annotations for a URI, including all properties of each
* Fetch all annotations for an item, including all properties of each
* annotation which would be required to recreate it.
* @param aItemId
* The identifier of the itme for which annotations are to be
@ -1187,27 +1176,15 @@ var PlacesUtils = {
var annoNames = annosvc.getItemAnnotationNames(aItemId, {});
for (var i = 0; i < annoNames.length; i++) {
var flags = {}, exp = {}, mimeType = {}, storageType = {};
annosvc.getItemAnnotationInfo(aItemId, annoNames[i], flags, exp,
mimeType, storageType);
switch (storageType.value) {
case annosvc.TYPE_INT32:
val = annosvc.getItemAnnotationInt32(aItemId, annoNames[i]);
break;
case annosvc.TYPE_INT64:
val = annosvc.getItemAnnotationInt64(aItemId, annoNames[i]);
break;
case annosvc.TYPE_DOUBLE:
val = annosvc.getItemAnnotationDouble(aItemId, annoNames[i]);
break;
case annosvc.TYPE_STRING:
val = annosvc.getItemAnnotationString(aItemId, annoNames[i]);
break;
case annosvc.TYPE_BINARY:
var data = {}, length = {}, mimeType = {};
annosvc.getItemAnnotationBinary(aItemId, annoNames[i], data, length, mimeType);
val = data.value;
break;
annosvc.getItemAnnotationInfo(aItemId, annoNames[i], flags, exp, mimeType, storageType);
if (storageType.value == annosvc.TYPE_BINARY) {
var data = {}, length = {}, mimeType = {};
annosvc.geItemAnnotationBinary(aItemId, annoNames[i], data, length, mimeType);
val = data.value;
}
else
val = annosvc.getItemAnnotation(aItemId, annoNames[i]);
annos.push({name: annoNames[i],
flags: flags.value,
expires: exp.value,
@ -1230,34 +1207,20 @@ var PlacesUtils = {
setAnnotationsForURI: function PU_setAnnotationsForURI(aURI, aAnnos) {
var annosvc = this.annotations;
aAnnos.forEach(function(anno) {
switch (anno.type) {
case annosvc.TYPE_INT32:
annosvc.setPageAnnotationInt32(aURI, anno.name, anno.value,
anno.flags, anno.expires);
break;
case annosvc.TYPE_INT64:
annosvc.setPageAnnotationInt64(aURI, anno.name, anno.value,
anno.flags, anno.expires);
break;
case annosvc.TYPE_DOUBLE:
annosvc.setPageAnnotationDouble(aURI, anno.name, anno.value,
anno.flags, anno.expires);
break;
case annosvc.TYPE_STRING:
annosvc.setPageAnnotationString(aURI, anno.name, anno.value,
anno.flags, anno.expires);
break;
case annosvc.TYPE_BINARY:
annosvc.setPageAnnotationBinary(aURI, anno.name, anno.value,
anno.value.length, anno.mimeType,
anno.flags, anno.expires);
break;
if (anno.type == annosvc.TYPE_BINARY) {
annosvc.setPageAnnotationBinary(aURI, anno.name, anno.value,
anno.value.length, anno.mimeType,
anno.flags, anno.expires);
}
else {
annosvc.setPageAnnotation(aURI, anno.name, anno.value,
anno.flags, anno.expires);
}
});
},
/**
* Annotate a URI with a batch of annotations.
* Annotate an item with a batch of annotations.
* @param aItemId
* The identifier of the item for which annotations are to be set
* @param aAnnotations
@ -1268,28 +1231,14 @@ var PlacesUtils = {
setAnnotationsForItem: function PU_setAnnotationsForItem(aItemId, aAnnos) {
var annosvc = this.annotations;
aAnnos.forEach(function(anno) {
switch (anno.type) {
case annosvc.TYPE_INT32:
annosvc.setItemAnnotationInt32(aItemId, anno.name, anno.value,
anno.flags, anno.expires);
break;
case annosvc.TYPE_INT64:
annosvc.setItemAnnotationInt64(aItemId, anno.name, anno.value,
anno.flags, anno.expires);
break;
case annosvc.TYPE_DOUBLE:
annosvc.setItemAnnotationDouble(aItemId, anno.name, anno.value,
anno.flags, anno.expires);
break;
case annosvc.TYPE_STRING:
annosvc.setItemAnnotationString(aItemId, anno.name, anno.value,
anno.flags, anno.expires);
break;
case annosvc.TYPE_BINARY:
annosvc.setItemAnnotationBinary(aItemId, anno.name, anno.value,
anno.value.length, anno.mimeType,
anno.flags, anno.expires);
break;
if (anno.type == annosvc.TYPE_BINARY) {
annosvc.setItemAnnotationBinary(aItemId, anno.name, anno.value,
anno.value.length, anno.mimeType,
anno.flags, anno.expires);
}
else {
annosvc.setItemAnnotation(aItemId, anno.name, anno.value,
anno.flags, anno.expires);
}
});
},

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

@ -228,8 +228,7 @@ function testCanonicalBookmarks(aFolder) {
do_check_true(annosvc.itemHasAnnotation(testFolder.itemId,
DESCRIPTION_ANNO));
do_check_eq("folder test comment",
annosvc.getItemAnnotationString(testFolder.itemId,
DESCRIPTION_ANNO));
annosvc.getItemAnnotation(testFolder.itemId, DESCRIPTION_ANNO));
// open test folder, and test the children
testFolder.containerOpen = true;
var cc = testFolder.childCount;
@ -258,17 +257,17 @@ function testCanonicalBookmarks(aFolder) {
var pageURI = iosvc.newURI(testBookmark1.uri, "", null);
do_check_true(annosvc.pageHasAnnotation(pageURI, POST_DATA_ANNO));
do_check_eq("hidden1%3Dbar&text1%3D%25s",
annosvc.getPageAnnotationString(pageURI, POST_DATA_ANNO));
annosvc.getPageAnnotation(pageURI, POST_DATA_ANNO));
// last charset
do_check_true(annosvc.pageHasAnnotation(pageURI, LAST_CHARSET_ANNO));
do_check_eq("ISO-8859-1", annosvc.getPageAnnotationString(pageURI,
LAST_CHARSET_ANNO));
do_check_eq("ISO-8859-1", annosvc.getPageAnnotation(pageURI,
LAST_CHARSET_ANNO));
// description
do_check_true(annosvc.itemHasAnnotation(testBookmark1.itemId,
DESCRIPTION_ANNO));
do_check_eq("item description",
annosvc.getItemAnnotationString(testBookmark1.itemId,
DESCRIPTION_ANNO));
annosvc.getItemAnnotation(testBookmark1.itemId,
DESCRIPTION_ANNO));
/*
// XXX Bug 380468

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

@ -60,7 +60,7 @@ interface nsIAnnotationObserver : nsISupports
void onItemAnnotationRemoved(in long long aItemId, in AUTF8String aName);
};
[scriptable, uuid(1e2f77a8-7923-4c3d-9100-965687740acd)]
[scriptable, uuid(db773ab7-38c9-4e30-9010-9bd620ceedfb)]
interface nsIAnnotationService : nsISupports
{
/**
@ -114,8 +114,9 @@ interface nsIAnnotationService : nsISupports
* aExpiration is one of EXPIRE_* above. aFlags should be 0 for now, some
* flags will be defined in the future.
*
* NOTE: ALL ANNOTATIONS WILL GET DELETED WHEN THE PAGE IS REMOVED FROM
* HISTORY, regardless of expiration date. This means that if you create an
* NOTE (NOTE: NOT YET IMPLEMENTED, see bug 319455),: ALL ANNOTATIONS WILL
* GET DELETED WHEN THE PAGE IS REMOVED FROM HISTORY,
* regardless of expiration date. This means that if you create an
* annotation on a random unvisited URI, it will get deleted when the
* browser shuts down. Otherwise, things can exist in history as
* annotations but the user has no way of knowing it, potentially violating
@ -127,46 +128,57 @@ interface nsIAnnotationService : nsISupports
* The annotation "favicon" is special. favicons are stored in the favicon
* service, but are special cased in the protocol handler so they look like
* annotations. Do not set favicons using this service, it will not work.
*
* Binary annotations should be set using
* setItemAnnotationBinary/setPageAnnotationBinary. For other types, only
* C++ consumers may use the type-specific methods.
*/
void setPageAnnotationString(in nsIURI aURI, in AUTF8String aName,
void setPageAnnotation(in nsIURI aURI, in AUTF8String aName,
in nsIVariant aValue, in long aFlags,
in unsigned short aExpiration);
void setItemAnnotation(in long long aItemId, in AUTF8String aName,
in nsIVariant aValue, in long aFlags,
in unsigned short aExpiration);
[noscript] void setPageAnnotationString(in nsIURI aURI, in AUTF8String aName,
in AString aValue, in long aFlags,
in unsigned short aExpiration);
void setItemAnnotationString(in long long aItemId, in AUTF8String aName,
in AString aValue, in long aFlags,
in unsigned short aExpiration);
[noscript] void setItemAnnotationString(in long long aItemId, in AUTF8String aName,
in AString aValue, in long aFlags,
in unsigned short aExpiration);
/**
* Sets an annotation just like setAnnotationString, but takes an Int32 as
* input.
*/
void setPageAnnotationInt32(in nsIURI aURI, in AUTF8String aName,
in long aValue, in long aFlags,
in unsigned short aExpiration);
void setItemAnnotationInt32(in long long aItemId, in AUTF8String aName,
in long aValue, in long aFlags,
in unsigned short aExpiration);
[noscript] void setPageAnnotationInt32(in nsIURI aURI, in AUTF8String aName,
in long aValue, in long aFlags,
in unsigned short aExpiration);
[noscript] void setItemAnnotationInt32(in long long aItemId, in AUTF8String aName,
in long aValue, in long aFlags,
in unsigned short aExpiration);
/**
* Sets an annotation just like setAnnotationString, but takes an Int64 as
* input.
*/
void setPageAnnotationInt64(in nsIURI aURI, in AUTF8String aName,
in long long aValue, in long aFlags,
in unsigned short aExpiration);
void setItemAnnotationInt64(in long long aItemId, in AUTF8String aName,
in long long aValue, in long aFlags,
in unsigned short aExpiration);
[noscript] void setPageAnnotationInt64(in nsIURI aURI, in AUTF8String aName,
in long long aValue, in long aFlags,
in unsigned short aExpiration);
[noscript] void setItemAnnotationInt64(in long long aItemId, in AUTF8String aName,
in long long aValue, in long aFlags,
in unsigned short aExpiration);
/**
* Sets an annotation just like setAnnotationString, but takes a double as
* input.
*/
void setPageAnnotationDouble(in nsIURI aURI, in AUTF8String aName,
in double aValue, in long aFlags,
in unsigned short aExpiration);
void setItemAnnotationDouble(in long long aItemId, in AUTF8String aName,
in double aValue, in long aFlags,
in unsigned short aExpiration);
[noscript] void setPageAnnotationDouble(in nsIURI aURI, in AUTF8String aName,
in double aValue, in long aFlags,
in unsigned short aExpiration);
[noscript] void setItemAnnotationDouble(in long long aItemId, in AUTF8String aName,
in double aValue, in long aFlags,
in unsigned short aExpiration);
/*
* Sets an annotation just like setAnnotationString, but takes binary data
* as input. You MUST supply a valid MIME type.
@ -185,51 +197,49 @@ interface nsIAnnotationService : nsISupports
in unsigned short aExpiration);
/**
* Retrieves the string value of a given annotation. Throws an error if the
* annotation does not exist. If the annotation was set as a different
* type than you are retrieving it as, the value will be converted as best
* as we can. You aren't always guaranteed a good conversion, however,
* and errors will not be thrown in this case. (For example, doubles will
* lose precision when stringified.)
* Retrieves the value of a given annotation. Throws an error if the
* annotation does not exist. Throws for binary annotations, for which
* getPageAnnotationBinary/getItemAnnotationBinary should be used. C++
* consumers may use the type-specific methods.
*
* The type-specific methods throw if the given annotation is set in
* a different type.
*/
AString getPageAnnotationString(in nsIURI aURI, in AUTF8String aName);
AString getItemAnnotationString(in long long aItemId, in AUTF8String aName);
nsIVariant getPageAnnotation(in nsIURI aURI, in AUTF8String aName);
nsIVariant getItemAnnotation(in long long aItemId, in AUTF8String aName);
/**
* Same as getAnnotationString but for ints. If the value doesn't look like
* an int, returns 0. (this is current sqlite behavior when asking for an
* int when there is not one, it will possibly change in the future if we
* start caching stuff).
* @see getPageAnnotation
*/
long getPageAnnotationInt32(in nsIURI aURI, in AUTF8String aName);
long getItemAnnotationInt32(in long long aItemId, in AUTF8String aName);
[noscript] AString getPageAnnotationString(in nsIURI aURI, in AUTF8String aName);
[noscript] AString getItemAnnotationString(in long long aItemId, in AUTF8String aName);
/**
* Same as getAnnotationString for Int64s. If the value doesn't look like
* an int, returns 0. (this is current sqlite behavior when asking for an
* int when there is not one, it will possibly change in the future if we
* start caching stuff).
* @see getPageAnnotation
*/
long long getPageAnnotationInt64(in nsIURI aURI, in AUTF8String aName);
long long getItemAnnotationInt64(in long long aItemId, in AUTF8String aName);
[noscript] long getPageAnnotationInt32(in nsIURI aURI, in AUTF8String aName);
[noscript] long getItemAnnotationInt32(in long long aItemId, in AUTF8String aName);
/**
* Same as getAnnotationString but returns a double-precision float. If the
* value doesn't look like an float, returns 0. (this is current sqlite
* behavior when asking for an number when there is not one, it will
* possibly change in the future if we start caching stuff).
* @see getPageAnnotation
*/
double getPageAnnotationDouble(in nsIURI aURI, in AUTF8String aName);
double getItemAnnotationDouble(in long long aItemId, in AUTF8String aName);
[noscript] long long getPageAnnotationInt64(in nsIURI aURI, in AUTF8String aName);
[noscript] long long getItemAnnotationInt64(in long long aItemId, in AUTF8String aName);
/**
* Same as getAnnotationString but for binary data. This also returns the
* @see getPageAnnotation
*/
[noscript] double getPageAnnotationDouble(in nsIURI aURI, in AUTF8String aName);
[noscript] double getItemAnnotationDouble(in long long aItemId, in AUTF8String aName);
/**
* @see getPageAnnotation. This also returns the
* MIME type.
*/
void getPageAnnotationBinary(in nsIURI aURI, in AUTF8String aName,
[array,size_is(aDataLen)] out octet aData,
out unsigned long aDataLen,
out AUTF8String aMimeType);
[array,size_is(aDataLen)] out octet aData,
out unsigned long aDataLen,
out AUTF8String aMimeType);
void getItemAnnotationBinary(in long long aItemId, in AUTF8String aName,
[array,size_is(aDataLen)] out octet aData,
out unsigned long aDataLen,
@ -246,10 +256,12 @@ interface nsIAnnotationService : nsISupports
* annotator.getAnnotationInfo(myURI, "foo", flags, exp, mimeType);
* // now you can use 'exp.value' and 'flags.value'
*/
void getPageAnnotationInfo(in nsIURI aURI, in AUTF8String aName,
out PRInt32 aFlags, out unsigned short aExpiration,
out AUTF8String aMimeType,
out unsigned short aType);
void getPageAnnotationInfo(in nsIURI aURI,
in AUTF8String aName,
out PRInt32 aFlags,
out unsigned short aExpiration,
out AUTF8String aMimeType,
out unsigned short aType);
void getItemAnnotationInfo(in long long aItemId, in AUTF8String aName,
out long aFlags, out unsigned short aExpiration,
out AUTF8String aMimeType,

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

@ -324,6 +324,150 @@ nsAnnotationService::SetAnnotationStringInternal(PRInt64 aFkId,
return NS_OK;
}
NS_IMETHODIMP
nsAnnotationService::SetPageAnnotation(nsIURI* aURI,
const nsACString& aName,
nsIVariant* aValue,
PRInt32 aFlags,
PRUint16 aExpiration)
{
NS_ENSURE_ARG(aValue);
PRUint16 dataType;
nsresult rv = aValue->GetDataType(&dataType);
NS_ENSURE_SUCCESS(rv, rv);
switch (dataType) {
case nsIDataType::VTYPE_INT8:
case nsIDataType::VTYPE_UINT8:
case nsIDataType::VTYPE_INT16:
case nsIDataType::VTYPE_UINT16:
case nsIDataType::VTYPE_INT32:
case nsIDataType::VTYPE_UINT32:
case nsIDataType::VTYPE_BOOL: {
PRInt32 valueInt;
rv = aValue->GetAsInt32(&valueInt);
if (NS_SUCCEEDED(rv)) { // fall through PRInt64 case otherwise
NS_ENSURE_SUCCESS(rv, rv);
rv = SetPageAnnotationInt32(aURI, aName, valueInt, aFlags, aExpiration);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
}
case nsIDataType::VTYPE_INT64:
case nsIDataType::VTYPE_UINT64: {
PRInt64 valueLong;
rv = aValue->GetAsInt64(&valueLong);
if (NS_SUCCEEDED(rv)) { // fall through double case otherwise
NS_ENSURE_SUCCESS(rv, rv);
rv = SetPageAnnotationInt64(aURI, aName, valueLong, aFlags, aExpiration);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
}
case nsIDataType::VTYPE_FLOAT:
case nsIDataType::VTYPE_DOUBLE: {
double valueDouble;
rv = aValue->GetAsDouble(&valueDouble);
NS_ENSURE_SUCCESS(rv, rv);
rv = SetPageAnnotationDouble(aURI, aName, valueDouble, aFlags, aExpiration);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
case nsIDataType::VTYPE_CHAR:
case nsIDataType::VTYPE_WCHAR:
case nsIDataType::VTYPE_DOMSTRING:
case nsIDataType::VTYPE_CHAR_STR:
case nsIDataType::VTYPE_WCHAR_STR:
case nsIDataType::VTYPE_STRING_SIZE_IS:
case nsIDataType::VTYPE_WSTRING_SIZE_IS:
case nsIDataType::VTYPE_UTF8STRING:
case nsIDataType::VTYPE_CSTRING:
case nsIDataType::VTYPE_ASTRING: {
nsAutoString stringValue;
rv = aValue->GetAsAString(stringValue);
NS_ENSURE_SUCCESS(rv, rv);
rv = SetPageAnnotationString(aURI, aName, stringValue, aFlags, aExpiration);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
}
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsAnnotationService::SetItemAnnotation(PRInt64 aItemId,
const nsACString& aName,
nsIVariant* aValue,
PRInt32 aFlags,
PRUint16 aExpiration)
{
NS_ENSURE_ARG(aValue);
PRUint16 dataType;
nsresult rv = aValue->GetDataType(&dataType);
NS_ENSURE_SUCCESS(rv, rv);
switch (dataType) {
case nsIDataType::VTYPE_INT8:
case nsIDataType::VTYPE_UINT8:
case nsIDataType::VTYPE_INT16:
case nsIDataType::VTYPE_UINT16:
case nsIDataType::VTYPE_INT32:
case nsIDataType::VTYPE_UINT32:
case nsIDataType::VTYPE_BOOL: {
PRInt32 valueInt;
rv = aValue->GetAsInt32(&valueInt);
if (NS_SUCCEEDED(rv)) { // fall through PRInt64 case otherwise
NS_ENSURE_SUCCESS(rv, rv);
rv = SetItemAnnotationInt32(aItemId, aName, valueInt, aFlags, aExpiration);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
}
case nsIDataType::VTYPE_INT64:
case nsIDataType::VTYPE_UINT64: {
PRInt64 valueLong;
rv = aValue->GetAsInt64(&valueLong);
if (NS_SUCCEEDED(rv)) { // fall through double case otherwise
NS_ENSURE_SUCCESS(rv, rv);
rv = SetItemAnnotationInt64(aItemId, aName, valueLong, aFlags, aExpiration);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
}
case nsIDataType::VTYPE_FLOAT:
case nsIDataType::VTYPE_DOUBLE: {
double valueDouble;
rv = aValue->GetAsDouble(&valueDouble);
NS_ENSURE_SUCCESS(rv, rv);
rv = SetItemAnnotationDouble(aItemId, aName, valueDouble, aFlags, aExpiration);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
case nsIDataType::VTYPE_CHAR:
case nsIDataType::VTYPE_WCHAR:
case nsIDataType::VTYPE_DOMSTRING:
case nsIDataType::VTYPE_CHAR_STR:
case nsIDataType::VTYPE_WCHAR_STR:
case nsIDataType::VTYPE_STRING_SIZE_IS:
case nsIDataType::VTYPE_WSTRING_SIZE_IS:
case nsIDataType::VTYPE_UTF8STRING:
case nsIDataType::VTYPE_CSTRING:
case nsIDataType::VTYPE_ASTRING: {
nsAutoString stringValue;
rv = aValue->GetAsAString(stringValue);
NS_ENSURE_SUCCESS(rv, rv);
rv = SetItemAnnotationString(aItemId, aName, stringValue, aFlags, aExpiration);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
}
return NS_ERROR_NOT_IMPLEMENTED;
}
// nsAnnotationService::SetPageAnnotationString
NS_IMETHODIMP
@ -704,6 +848,92 @@ nsAnnotationService::GetItemAnnotationString(PRInt64 aItemId,
}
NS_IMETHODIMP
nsAnnotationService::GetPageAnnotation(nsIURI* aURI,
const nsACString& aName,
nsIVariant** _retval)
{
*_retval = nsnull;
nsresult rv = StartGetAnnotationFromURI(aURI, aName);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIWritableVariant> value = new nsVariant();
PRInt32 type = mDBGetAnnotationFromURI->AsInt32(kAnnoIndex_Type);
switch (type) {
case nsIAnnotationService::TYPE_INT32:
case nsIAnnotationService::TYPE_INT64:
case nsIAnnotationService::TYPE_DOUBLE: {
rv = value->SetAsDouble(mDBGetAnnotationFromURI->AsDouble(kAnnoIndex_Content));
break;
}
case nsIAnnotationService::TYPE_STRING: {
nsAutoString valueString;
rv = mDBGetAnnotationFromURI->GetString(kAnnoIndex_Content, valueString);
if (NS_SUCCEEDED(rv))
rv = value->SetAsAString(valueString);
break;
}
case nsIAnnotationService::TYPE_BINARY: {
rv = NS_ERROR_INVALID_ARG;
break;
}
default: {
rv = NS_ERROR_UNEXPECTED;
break;
}
}
if (NS_SUCCEEDED(rv))
NS_ADDREF(*_retval = value);
mDBGetAnnotationFromURI->Reset();
return rv;
}
NS_IMETHODIMP
nsAnnotationService::GetItemAnnotation(PRInt64 aItemId,
const nsACString& aName,
nsIVariant** _retval)
{
*_retval = nsnull;
nsresult rv = StartGetAnnotationFromItemId(aItemId, aName);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIWritableVariant> value = new nsVariant();
PRInt32 type = mDBGetAnnotationFromItemId->AsInt32(kAnnoIndex_Type);
switch (type) {
case nsIAnnotationService::TYPE_INT32:
case nsIAnnotationService::TYPE_INT64:
case nsIAnnotationService::TYPE_DOUBLE: {
rv = value->SetAsDouble(mDBGetAnnotationFromItemId->AsDouble(kAnnoIndex_Content));
break;
}
case nsIAnnotationService::TYPE_STRING: {
nsAutoString valueString;
rv = mDBGetAnnotationFromItemId->GetString(kAnnoIndex_Content, valueString);
if (NS_SUCCEEDED(rv))
rv = value->SetAsAString(valueString);
break;
}
case nsIAnnotationService::TYPE_BINARY: {
rv = NS_ERROR_INVALID_ARG;
break;
}
default: {
rv = NS_ERROR_UNEXPECTED;
break;
}
}
if (NS_SUCCEEDED(rv))
NS_ADDREF(*_retval = value);
mDBGetAnnotationFromItemId->Reset();
return rv;
}
// nsAnnotationService::GetPageAnnotationInt32
NS_IMETHODIMP
@ -1083,7 +1313,7 @@ nsAnnotationService::GetPageAnnotationNames(nsIURI* aURI, PRUint32* aCount,
NS_ENSURE_TRUE(*_result, NS_ERROR_OUT_OF_MEMORY);
for (PRUint32 i = 0; i < names.Length(); i ++) {
nsCOMPtr<nsIWritableVariant> var = new nsVariant;
nsCOMPtr<nsIWritableVariant> var = new nsVariant();
if (! var) {
// need to release all the variants we've already created
for (PRUint32 j = 0; j < i; j ++)
@ -1149,7 +1379,7 @@ nsAnnotationService::GetItemAnnotationNames(PRInt64 aItemId, PRUint32* aCount,
NS_ENSURE_TRUE(*_result, NS_ERROR_OUT_OF_MEMORY);
for (PRUint32 i = 0; i < names.Length(); i ++) {
nsCOMPtr<nsIWritableVariant> var = new nsVariant;
nsCOMPtr<nsIWritableVariant> var = new nsVariant();
if (! var) {
// need to release all the variants we've already created
for (PRUint32 j = 0; j < i; j ++)

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

@ -139,7 +139,7 @@ function LivemarkService() {
for (var i = 0; i < livemarks.length; i++) {
var feedURI =
gIoService.newURI(
this._ans.getItemAnnotationString(livemarks[i], LMANNO_FEEDURI),
this._ans.getItemAnnotation(livemarks[i], LMANNO_FEEDURI),
null, null
);
this._pushLivemark(livemarks[i], feedURI);
@ -208,8 +208,8 @@ LivemarkService.prototype = {
// then we assume it's never been loaded. We perform this
// check even when the update is being forced, in case the
// livemark has somehow never been loaded.
var exprTime = this._ans.getPageAnnotationInt64(livemark.feedURI,
LMANNO_EXPIRATION);
var exprTime = this._ans.getPageAnnotation(livemark.feedURI,
LMANNO_EXPIRATION);
if (!forceUpdate && exprTime > Date.now()) {
// no need to refresh
livemark.locked = false;
@ -280,8 +280,8 @@ LivemarkService.prototype = {
var livemarkID = bms.createContainer(folder, name, LS_CONTRACTID, index);
// Add an annotation to map the folder URI to the livemark feed URI
this._ans.setItemAnnotationString(livemarkID, LMANNO_FEEDURI, feedURI.spec, 0,
this._ans.EXPIRE_NEVER);
this._ans.setItemAnnotation(livemarkID, LMANNO_FEEDURI, feedURI.spec, 0,
this._ans.EXPIRE_NEVER);
// Set the favicon
var faviconService = Cc[FAV_CONTRACTID].getService(Ci.nsIFaviconService);
var livemarkURI = bms.getFolderURI(livemarkID);
@ -289,8 +289,8 @@ LivemarkService.prototype = {
if (siteURI) {
// Add an annotation to map the folder URI to the livemark site URI
this._ans.setItemAnnotationString(livemarkID, LMANNO_SITEURI, siteURI.spec,
0, this._ans.EXPIRE_NEVER);
this._ans.setItemAnnotation(livemarkID, LMANNO_SITEURI, siteURI.spec,
0, this._ans.EXPIRE_NEVER);
}
return livemarkID;
@ -315,9 +315,9 @@ LivemarkService.prototype = {
try {
this._ensureLivemark(container);
// getItemAnnotationString() can throw if there is no annotation
// getItemAnnotation() can throw if there is no annotation
var siteURIString =
this._ans.getItemAnnotationString(container, LMANNO_SITEURI);
this._ans.getItemAnnotation(container, LMANNO_SITEURI);
return gIoService.newURI(siteURIString, null, null);
}
@ -337,15 +337,15 @@ LivemarkService.prototype = {
return;
}
this._ans.setItemAnnotationString(container, LMANNO_SITEURI, siteURI.spec,
this._ans.setItemAnnotation(container, LMANNO_SITEURI, siteURI.spec,
0, this._ans.EXPIRE_NEVER);
},
getFeedURI: function LS_getFeedURI(container) {
try {
// getItemAnnotationString() can throw if there is no annotation
var feedURIString = this._ans.getItemAnnotationString(container,
LMANNO_FEEDURI);
// getItemAnnotation() can throw if there is no annotation
var feedURIString = this._ans.getItemAnnotation(container,
LMANNO_FEEDURI);
return gIoService.newURI(feedURIString, null, null);
}
@ -361,8 +361,8 @@ LivemarkService.prototype = {
if (!feedURI)
throw Cr.NS_ERROR_INVALID_ARG;
this._ans.setItemAnnotationString(container, LMANNO_FEEDURI, feedURI.spec,
0, this._ans.EXPIRE_NEVER);
this._ans.setItemAnnotation(container, LMANNO_FEEDURI, feedURI.spec, 0,
this._ans.EXPIRE_NEVER);
// now update our internal table
var livemarkIndex = this._getLivemarkIndex(container);
@ -527,8 +527,8 @@ LivemarkLoadListener.prototype = {
function LS_insertLivemarkChild(folderId, uri, title) {
var id = this._bms.insertBookmark(folderId, uri, this._bms.DEFAULT_INDEX,
title);
this._ans.setItemAnnotationString(id, LMANNO_BMANNO, uri.spec, 0,
this._ans.EXPIRE_NEVER);
this._ans.setItemAnnotation(id, LMANNO_BMANNO, uri.spec, 0,
this._ans.EXPIRE_NEVER);
},
/**
@ -596,9 +596,9 @@ LivemarkLoadListener.prototype = {
_setResourceTTL: function LLL__setResourceTTL(milliseconds) {
var exptime = Date.now() + milliseconds;
this._ans.setPageAnnotationInt64(this._livemark.feedURI,
LMANNO_EXPIRATION, exptime, 0,
Ci.nsIAnnotationService.EXPIRE_NEVER);
this._ans.setPageAnnotation(this._livemark.feedURI, LMANNO_EXPIRATION,
exptime, 0,
Ci.nsIAnnotationService.EXPIRE_NEVER);
},
/**

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

@ -984,6 +984,7 @@ PRInt32 PR_CALLBACK nsNavHistoryContainerResultNode::SortComparison_AnnotationLe
&b_type), 0);
}
// We better make the API not support this state, really
// XXXmano: this is actually wrong for double<->int and int64<->int32
if (a_hasAnno && b_type != annoType)
return 0;
annoType = b_type;

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

@ -559,7 +559,7 @@ function run_test() {
// check if setting an item annotation triggers onItemChanged
observer._itemChangedId = -1;
annosvc.setItemAnnotationString(newId3, "test-annotation", "foo", 0, 0);
annosvc.setItemAnnotation(newId3, "test-annotation", "foo", 0, 0);
do_check_eq(observer._itemChangedId, newId3);
do_check_eq(observer._itemChangedProperty, "test-annotation");
do_check_true(observer._itemChanged_isAnnotationProperty);

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

@ -101,7 +101,7 @@ function run_test() {
// create new string annotation
try {
annosvc.setPageAnnotationString(testURI, testAnnoName, testAnnoVal, 0, 0);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, 0);
} catch(ex) {
do_throw("unable to add page-annotation");
}
@ -110,15 +110,15 @@ function run_test() {
// get string annotation
do_check_true(annosvc.pageHasAnnotation(testURI, testAnnoName));
var storedAnnoVal = annosvc.getPageAnnotationString(testURI, testAnnoName);
do_check_eq(testAnnoVal, storedAnnoVal);
var storedAnnoVal = annosvc.getPageAnnotation(testURI, testAnnoName);
do_check_true(testAnnoVal === storedAnnoVal);
// string item-annotation
try {
var lastModified = bmsvc.getItemLastModified(testItemId);
// verify that lastModified is 0 before we set the annotation
do_check_eq(lastModified, 0);
annosvc.setItemAnnotationString(testItemId, testAnnoName, testAnnoVal, 0, 0);
annosvc.setItemAnnotation(testItemId, testAnnoName, testAnnoVal, 0, 0);
var lastModified2 = bmsvc.getItemLastModified(testItemId);
// verify that setting the annotation updates the last modified time
do_check_true(lastModified2 > lastModified);
@ -130,16 +130,16 @@ function run_test() {
try {
var lastModified = bmsvc.getItemLastModified(testItemId);
var annoVal = annosvc.getItemAnnotationString(testItemId, testAnnoName);
var annoVal = annosvc.getItemAnnotation(testItemId, testAnnoName);
// verify the anno value
do_check_eq(testAnnoVal, annoVal);
do_check_true(testAnnoVal === annoVal);
} catch(ex) {
do_throw("unable to get item annotation");
}
// test getPagesWithAnnotation
var uri2 = uri("http://www.tests.tld");
annosvc.setPageAnnotationString(uri2, testAnnoName, testAnnoVal, 0, 0);
annosvc.setPageAnnotation(uri2, testAnnoName, testAnnoVal, 0, 0);
var pages = annosvc.getPagesWithAnnotation(testAnnoName, { });
do_check_eq(pages.length, 2);
// Don't rely on the order
@ -149,7 +149,7 @@ function run_test() {
// test getItemsWithAnnotation
var testItemId2 = bmsvc.insertBookmark(bmsvc.bookmarksRoot, uri2, -1, "");
annosvc.setItemAnnotationString(testItemId2, testAnnoName, testAnnoVal, 0, 0);
annosvc.setItemAnnotation(testItemId2, testAnnoName, testAnnoVal, 0, 0);
var items = annosvc.getItemsWithAnnotation(testAnnoName, { });
do_check_eq(items.length, 2);
// Don't rely on the order
@ -159,11 +159,11 @@ function run_test() {
// get annotation that doesn't exist
try {
annosvc.getPageAnnotationString(testURI, "blah");
annosvc.getPageAnnotation(testURI, "blah");
do_throw("fetching page-annotation that doesn't exist, should've thrown");
} catch(ex) {}
try {
annosvc.getItemAnnotationString(testURI, "blah");
annosvc.getItemAnnotation(testURI, "blah");
do_throw("fetching item-annotation that doesn't exist, should've thrown");
} catch(ex) {}
@ -201,7 +201,7 @@ function run_test() {
// test int32 anno type
var int32Key = testAnnoName + "/types/Int32";
var int32Val = 23;
annosvc.setPageAnnotationInt32(testURI, int32Key, int32Val, 0, 0);
annosvc.setPageAnnotation(testURI, int32Key, int32Val, 0, 0);
do_check_true(annosvc.pageHasAnnotation(testURI, int32Key));
var flags = {}, exp = {}, mimeType = {}, storageType = {};
annosvc.getPageAnnotationInfo(testURI, int32Key, flags, exp, mimeType,
@ -210,53 +210,49 @@ function run_test() {
do_check_eq(exp.value, 0);
do_check_eq(mimeType.value, null);
do_check_eq(storageType.value, Ci.nsIAnnotationService.TYPE_INT32);
var storedVal = annosvc.getPageAnnotationInt32(testURI, int32Key);
var storedVal = annosvc.getPageAnnotation(testURI, int32Key);
do_check_true(int32Val === storedVal);
annosvc.setItemAnnotationInt32(testItemId, int32Key, int32Val, 0, 0);
annosvc.setItemAnnotation(testItemId, int32Key, int32Val, 0, 0);
do_check_true(annosvc.itemHasAnnotation(testItemId, int32Key));
annosvc.getItemAnnotationInfo(testItemId, int32Key, flags, exp, mimeType,
storageType);
do_check_eq(flags.value, 0);
do_check_eq(exp.value, 0);
do_check_eq(mimeType.value, null);
do_check_eq(storageType.value, Ci.nsIAnnotationService.TYPE_INT32);
storedVal = annosvc.getItemAnnotationInt32(testItemId, int32Key);
storedVal = annosvc.getItemAnnotation(testItemId, int32Key);
do_check_true(int32Val === storedVal);
// test int64 anno type
var int64Key = testAnnoName + "/types/Int64";
var int64Val = 4294967296;
annosvc.setPageAnnotationInt64(testURI, int64Key, int64Val, 0, 0);
annosvc.setPageAnnotation(testURI, int64Key, int64Val, 0, 0);
annosvc.getPageAnnotationInfo(testURI, int64Key, flags, exp, mimeType, storageType);
do_check_eq(flags.value, 0);
do_check_eq(exp.value, 0);
do_check_eq(mimeType.value, null);
do_check_eq(storageType.value, Ci.nsIAnnotationService.TYPE_INT64);
storedVal = annosvc.getPageAnnotationInt64(testURI, int64Key);
storedVal = annosvc.getPageAnnotation(testURI, int64Key);
do_check_true(int64Val === storedVal);
annosvc.setItemAnnotationInt64(testItemId, int64Key, int64Val, 0, 0);
annosvc.setItemAnnotation(testItemId, int64Key, int64Val, 0, 0);
do_check_true(annosvc.itemHasAnnotation(testItemId, int64Key));
annosvc.getItemAnnotationInfo(testItemId, int64Key, flags, exp, mimeType,
storageType);
do_check_eq(flags.value, 0);
do_check_eq(exp.value, 0);
do_check_eq(mimeType.value, null);
do_check_eq(storageType.value, Ci.nsIAnnotationService.TYPE_INT64);
storedVal = annosvc.getItemAnnotationInt64(testItemId, int64Key);
storedVal = annosvc.getItemAnnotation(testItemId, int64Key);
do_check_true(int64Val === storedVal);
// test double anno type
var doubleKey = testAnnoName + "/types/Double";
var doubleVal = 0.000002342;
annosvc.setPageAnnotationDouble(testURI, doubleKey, doubleVal, 0, 0);
annosvc.setPageAnnotation(testURI, doubleKey, doubleVal, 0, 0);
annosvc.getPageAnnotationInfo(testURI, doubleKey, flags, exp, mimeType, storageType);
do_check_eq(flags.value, 0);
do_check_eq(exp.value, 0);
do_check_eq(mimeType.value, null);
do_check_eq(storageType.value, Ci.nsIAnnotationService.TYPE_DOUBLE);
storedVal = annosvc.getPageAnnotationDouble(testURI, doubleKey);
storedVal = annosvc.getPageAnnotation(testURI, doubleKey);
do_check_true(doubleVal === storedVal);
annosvc.setItemAnnotationDouble(testItemId, doubleKey, doubleVal, 0, 0);
annosvc.setItemAnnotation(testItemId, doubleKey, doubleVal, 0, 0);
do_check_true(annosvc.itemHasAnnotation(testItemId, doubleKey));
annosvc.getItemAnnotationInfo(testItemId, doubleKey, flags, exp, mimeType,
storageType);
@ -264,7 +260,7 @@ function run_test() {
do_check_eq(exp.value, 0);
do_check_eq(mimeType.value, null);
do_check_eq(storageType.value, Ci.nsIAnnotationService.TYPE_DOUBLE);
storedVal = annosvc.getItemAnnotationDouble(testItemId, doubleKey);
storedVal = annosvc.getItemAnnotation(testItemId, doubleKey);
do_check_true(doubleVal === storedVal);
// test binary anno type
@ -293,35 +289,7 @@ function run_test() {
do_check_eq(binaryVal.toString(), data.value.toString());
do_check_eq(typeof data.value, "object");
// test that accessors throw for wrong types
try {
annosvc.getPageAnnotationString(testURI, int32Key);
do_throw("page-annotation string accessor didn't throw for a wrong type!");
annosvc.getItemAnnotationString(testItemId, int32Key);
do_throw("item-annotation string accessor didn't throw for a wrong type!");
} catch(ex) {}
try {
annosvc.getPageAnnotationInt32(testURI, int64Key);
do_throw("page-annotation int32 accessor didn't throw for a wrong type!");
annosvc.getItemAnnotationInt32(testItemId, int64Key);
do_throw("item-annotation int32 accessor didn't throw for a wrong type!");
} catch(ex) {}
try {
annosvc.getPageAnnotationInt64(testURI, int32Key);
do_throw("page-annotation int64 accessor didn't throw for a wrong type!");
annosvc.getItemAnnotationInt64(testItemId, int32Key);
do_throw("item-annotation int64 accessor didn't throw for a wrong type!");
} catch(ex) {}
try {
annosvc.getPageAnnotationDouble(testURI, int32Key);
do_throw("page-annotation double accessor didn't throw for a wrong type!");
annosvc.getItemAnnotationDouble(testItemId, int32Key);
do_throw("item-annotation double accessor didn't throw for a wrong type!");
} catch(ex) {}
// test that binary-accessors throw for wrong types
try {
var data = {}, length = {}, mimeType = {};
annosvc.getPageAnnotationBinary(testURI, int32Key, data, length, mimeType);
@ -334,7 +302,7 @@ function run_test() {
// test annotation removal
annosvc.removePageAnnotation(testURI, int32Key);
annosvc.setItemAnnotationString(testItemId, testAnnoName, testAnnoVal, 0, 0);
annosvc.setItemAnnotation(testItemId, testAnnoName, testAnnoVal, 0, 0);
// verify that removing an annotation updates the last modified date
var lastModified3 = bmsvc.getItemLastModified(testItemId);
annosvc.removeItemAnnotation(testItemId, int32Key);
@ -359,7 +327,7 @@ function run_test() {
var invalidIds = [-1, 0, 37643];
for each (var id in invalidIds) {
try {
annosvc.setItemAnnotationString(id, "foo", "bar", 0, 0);
annosvc.setItemAnnotation(id, "foo", "bar", 0, 0);
do_throw("setItemAnnotation* should throw for invalid item id: " + id)
}
catch(ex) { }

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

@ -138,8 +138,8 @@ function run_test() {
// test annotation-based queries
var annos = Cc["@mozilla.org/browser/annotation-service;1"].
getService(Ci.nsIAnnotationService);
annos.setPageAnnotationInt32(uri("http://mozilla.com/"), "testAnno", 0, 0,
Ci.nsIAnnotationService.EXPIRE_NEVER);
annos.setPageAnnotation(uri("http://mozilla.com/"), "testAnno", 0, 0,
Ci.nsIAnnotationService.EXPIRE_NEVER);
query.annotation = "testAnno";
result = histsvc.executeQuery(query, options);
result.root.containerOpen = true;

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

@ -133,8 +133,8 @@ function run_test() {
// XXXtodo: test different item types once folderId and bookmarkId are merged.
// XXXtodo: test sortingAnnotation functionality with non-bookmark nodes
annosvc.setItemAnnotationString(id1, "testAnno", "a", 0, 0);
annosvc.setItemAnnotationString(id3, "testAnno", "b", 0, 0);
annosvc.setItemAnnotation(id1, "testAnno", "a", 0, 0);
annosvc.setItemAnnotation(id3, "testAnno", "b", 0, 0);
result.sortingAnnotation = "testAnno";
result.sortingMode = NHQO.SORT_BY_ANNOTATION_DESCENDING;
@ -145,6 +145,6 @@ function run_test() {
// XXXtodo: test lastModified sort
// test live update
annosvc.setItemAnnotationString(id1, "testAnno", "c", 0, 0);
annosvc.setItemAnnotation(id1, "testAnno", "c", 0, 0);
checkOrder(id1, id3, id2);
}