Bug 1150678 - Part 1: notify the old value in onItemChanged (only URI changes for now). r=ttaubert

This commit is contained in:
Marco Bonardo 2015-08-05 23:10:11 +02:00
parent 67afd88630
commit 578905bc97
12 changed files with 131 additions and 74 deletions

View File

@ -187,7 +187,8 @@ let Bookmarks = Object.freeze({
notify(observers, "onItemChanged", [ entry._id, "tags", false, "",
toPRTime(entry.lastModified),
entry.type, entry._parentId,
entry.guid, entry.parentGuid ]);
entry.guid, entry.parentGuid,
"" ]);
}
}
@ -325,7 +326,7 @@ let Bookmarks = Object.freeze({
updatedItem.type,
updatedItem._parentId,
updatedItem.guid,
updatedItem.parentGuid ]);
updatedItem.parentGuid, "" ]);
}
if (updateInfo.hasOwnProperty("title")) {
notify(observers, "onItemChanged", [ updatedItem._id, "title",
@ -334,7 +335,7 @@ let Bookmarks = Object.freeze({
updatedItem.type,
updatedItem._parentId,
updatedItem.guid,
updatedItem.parentGuid ]);
updatedItem.parentGuid, "" ]);
}
if (updateInfo.hasOwnProperty("url")) {
notify(observers, "onItemChanged", [ updatedItem._id, "uri",
@ -343,7 +344,8 @@ let Bookmarks = Object.freeze({
updatedItem.type,
updatedItem._parentId,
updatedItem.guid,
updatedItem.parentGuid ]);
updatedItem.parentGuid,
item.url.href ]);
}
// If the item was moved, notify onItemMoved.
if (item.parentGuid != updatedItem.parentGuid ||
@ -410,7 +412,8 @@ let Bookmarks = Object.freeze({
notify(observers, "onItemChanged", [ entry._id, "tags", false, "",
toPRTime(entry.lastModified),
entry.type, entry._parentId,
entry.guid, entry.parentGuid ]);
entry.guid, entry.parentGuid,
"" ]);
}
}
@ -872,7 +875,8 @@ function fetchBookmarksByURL(info) {
Task.async(function*(db) {
let rows = yield db.executeCached(
`SELECT b.guid, IFNULL(p.guid, "") AS parentGuid, b.position AS 'index',
`/* do not warn (bug no): not worth to add an index */
SELECT b.guid, IFNULL(p.guid, "") AS parentGuid, b.position AS 'index',
b.dateAdded, b.lastModified, b.type, b.title, h.url AS url,
b.id AS _id, b.parent AS _parentId,
(SELECT count(*) FROM moz_bookmarks WHERE parent = b.id) AS _childCount,
@ -1428,7 +1432,8 @@ Task.async(function* (db, folderGuids) {
notify(observers, "onItemChanged", [ entry._id, "tags", false, "",
toPRTime(entry.lastModified),
entry.type, entry._parentId,
entry.guid, entry.parentGuid ]);
entry.guid, entry.parentGuid,
"" ]);
}
}
}

View File

@ -117,7 +117,8 @@ function* notifyKeywordChange(url, keyword) {
bookmark.lastModified * 1000,
bookmark.type,
bookmark.parentId,
bookmark.guid, bookmark.parentGuid
bookmark.guid, bookmark.parentGuid,
""
]);
}
gIgnoreKeywordNotifications = false;

View File

@ -13,7 +13,7 @@ interface nsINavHistoryBatchCallback;
/**
* Observer for bookmarks changes.
*/
[scriptable, uuid(8ab925f8-af9b-4837-afa0-ffed507212ce)]
[scriptable, uuid(cff3efcc-e144-490d-9f23-8b6f6dd09e7f)]
interface nsINavBookmarkObserver : nsISupports
{
/**
@ -122,17 +122,30 @@ interface nsINavBookmarkObserver : nsISupports
* The unique ID associated with the item.
* @param aParentGuid
* The unique ID associated with the item's parent.
* @param aOldValue
* For certain properties, this is set to the new value of the
* property (see the list below).
*
* @note List of values that may be associated with properties:
* aProperty | aNewValue
* =====================================================================
* cleartime | Empty string (all visits to this item were removed).
* cleartime | Empty string (all visits to this item were removed).
* title | The new title.
* favicon | The "moz-anno" URL of the new favicon.
* uri | new URL.
* tags | Empty string (tags for this item changed)
* dateAdded | PRTime (as string) when the item was first added.
* lastModified | PRTime (as string) when the item was last modified.
*
* aProperty | aOldValue
* =====================================================================
* cleartime | Empty string (currently unused).
* title | Empty string (currently unused).
* favicon | Empty string (currently unused).
* uri | old URL.
* tags | Empty string (currently unused).
* dateAdded | Empty string (currently unused).
* lastModified | Empty string (currently unused).
*/
void onItemChanged(in long long aItemId,
in ACString aProperty,
@ -142,7 +155,8 @@ interface nsINavBookmarkObserver : nsISupports
in unsigned short aItemType,
in long long aParentId,
in ACString aGuid,
in ACString aParentGuid);
in ACString aParentGuid,
in AUTF8String aOldValue);
/**
* Notifies that the item was visited. Can be invoked only for TYPE_BOOKMARK

View File

@ -551,7 +551,8 @@ nsNavBookmarks::InsertBookmark(int64_t aFolder,
TYPE_BOOKMARK,
bookmarks[i].parentId,
bookmarks[i].guid,
bookmarks[i].parentGuid));
bookmarks[i].parentGuid,
EmptyCString()));
}
}
@ -656,7 +657,8 @@ nsNavBookmarks::RemoveItem(int64_t aItemId)
TYPE_BOOKMARK,
bookmarks[i].parentId,
bookmarks[i].guid,
bookmarks[i].parentGuid));
bookmarks[i].parentGuid,
EmptyCString()));
}
}
@ -1132,7 +1134,8 @@ nsNavBookmarks::RemoveFolderChildren(int64_t aFolderId)
TYPE_BOOKMARK,
bookmarks[i].parentId,
bookmarks[i].guid,
bookmarks[i].parentGuid));
bookmarks[i].parentGuid,
EmptyCString()));
}
}
}
@ -1413,7 +1416,8 @@ nsNavBookmarks::SetItemDateAdded(int64_t aItemId, PRTime aDateAdded)
bookmark.type,
bookmark.parentId,
bookmark.guid,
bookmark.parentGuid));
bookmark.parentGuid,
EmptyCString()));
return NS_OK;
}
@ -1459,7 +1463,8 @@ nsNavBookmarks::SetItemLastModified(int64_t aItemId, PRTime aLastModified)
bookmark.type,
bookmark.parentId,
bookmark.guid,
bookmark.parentGuid));
bookmark.parentGuid,
EmptyCString()));
return NS_OK;
}
@ -1527,7 +1532,8 @@ nsNavBookmarks::SetItemTitle(int64_t aItemId, const nsACString& aTitle)
bookmark.type,
bookmark.parentId,
bookmark.guid,
bookmark.parentGuid));
bookmark.parentGuid,
EmptyCString()));
return NS_OK;
}
@ -2010,7 +2016,8 @@ nsNavBookmarks::ChangeBookmarkURI(int64_t aBookmarkId, nsIURI* aNewURI)
bookmark.type,
bookmark.parentId,
bookmark.guid,
bookmark.parentGuid));
bookmark.parentGuid,
bookmark.url));
return NS_OK;
}
@ -2044,6 +2051,7 @@ nsNavBookmarks::GetBookmarkIdsForURITArray(nsIURI* aURI,
// importing, syncing or due to extensions.
// Note: not using a JOIN is cheaper in this case.
nsCOMPtr<mozIStorageStatement> stmt = mDB->GetStatement(
"/* do not warn (bug 1175249) */ "
"SELECT b.id, b.guid, b.parent, b.lastModified, t.guid, t.parent "
"FROM moz_bookmarks b "
"JOIN moz_bookmarks t on t.id = b.parent "
@ -2087,6 +2095,7 @@ nsNavBookmarks::GetBookmarksForURI(nsIURI* aURI,
// importing, syncing or due to extensions.
// Note: not using a JOIN is cheaper in this case.
nsCOMPtr<mozIStorageStatement> stmt = mDB->GetStatement(
"/* do not warn (bug 1175249) */ "
"SELECT b.id, b.guid, b.parent, b.lastModified, t.guid, t.parent "
"FROM moz_bookmarks b "
"JOIN moz_bookmarks t on t.id = b.parent "
@ -2302,7 +2311,8 @@ nsNavBookmarks::SetKeywordForBookmark(int64_t aBookmarkId,
TYPE_BOOKMARK,
bookmarks[i].parentId,
bookmarks[i].guid,
bookmarks[i].parentGuid));
bookmarks[i].parentGuid,
EmptyCString()));
}
return NS_OK;
@ -2354,7 +2364,8 @@ nsNavBookmarks::SetKeywordForBookmark(int64_t aBookmarkId,
TYPE_BOOKMARK,
bookmarks[i].parentId,
bookmarks[i].guid,
bookmarks[i].parentGuid));
bookmarks[i].parentGuid,
EmptyCString()));
}
stmt = mDB->GetStatement(
@ -2393,7 +2404,8 @@ nsNavBookmarks::SetKeywordForBookmark(int64_t aBookmarkId,
TYPE_BOOKMARK,
bookmarks[i].parentId,
bookmarks[i].guid,
bookmarks[i].parentGuid));
bookmarks[i].parentGuid,
EmptyCString()));
}
return NS_OK;
@ -2589,7 +2601,8 @@ nsNavBookmarks::NotifyItemChanged(const ItemChangeData& aData)
aData.bookmark.type,
aData.bookmark.parentId,
aData.bookmark.guid,
aData.bookmark.parentGuid));
aData.bookmark.parentGuid,
aData.oldValue));
}
////////////////////////////////////////////////////////////////////////////////
@ -2820,7 +2833,8 @@ nsNavBookmarks::OnItemAnnotationSet(int64_t aItemId, const nsACString& aName)
bookmark.type,
bookmark.parentId,
bookmark.guid,
bookmark.parentGuid));
bookmark.parentGuid,
EmptyCString()));
return NS_OK;
}

View File

@ -55,6 +55,7 @@ namespace places {
nsCString property;
bool isAnnotation;
nsCString newValue;
nsCString oldValue;
};
typedef void (nsNavBookmarks::*ItemVisitMethod)(const ItemVisitData&);

View File

@ -2856,7 +2856,8 @@ nsNavHistoryQueryResultNode::OnItemChanged(int64_t aItemId,
uint16_t aItemType,
int64_t aParentId,
const nsACString& aGUID,
const nsACString& aParentGUID)
const nsACString& aParentGUID,
const nsACString& aOldValue)
{
// History observers should not get OnItemChanged
// but should get the corresponding history notifications instead.
@ -2902,7 +2903,7 @@ nsNavHistoryQueryResultNode::OnItemChanged(int64_t aItemId,
aIsAnnotationProperty,
aNewValue, aLastModified,
aItemType, aParentId, aGUID,
aParentGUID);
aParentGUID, aOldValue);
}
NS_IMETHODIMP
@ -3667,7 +3668,8 @@ nsNavHistoryResultNode::OnItemChanged(int64_t aItemId,
uint16_t aItemType,
int64_t aParentId,
const nsACString& aGUID,
const nsACString& aParentGUID)
const nsACString& aParentGUID,
const nsACString& aOldValue)
{
if (aItemId != mItemId)
return NS_OK;
@ -3757,7 +3759,8 @@ nsNavHistoryFolderResultNode::OnItemChanged(int64_t aItemId,
uint16_t aItemType,
int64_t aParentId,
const nsACString& aGUID,
const nsACString&aParentGUID)
const nsACString& aParentGUID,
const nsACString& aOldValue)
{
RESTART_AND_RETURN_IF_ASYNC_PENDING();
@ -3765,7 +3768,7 @@ nsNavHistoryFolderResultNode::OnItemChanged(int64_t aItemId,
aIsAnnotationProperty,
aNewValue, aLastModified,
aItemType, aParentId, aGUID,
aParentGUID);
aParentGUID, aOldValue);
}
/**
@ -4462,11 +4465,13 @@ nsNavHistoryResult::OnItemChanged(int64_t aItemId,
uint16_t aItemType,
int64_t aParentId,
const nsACString& aGUID,
const nsACString& aParentGUID)
const nsACString& aParentGUID,
const nsACString& aOldValue)
{
ENUMERATE_ALL_BOOKMARKS_OBSERVERS(
OnItemChanged(aItemId, aProperty, aIsAnnotationProperty, aNewValue,
aLastModified, aItemType, aParentId, aGUID, aParentGUID));
aLastModified, aItemType, aParentId, aGUID, aParentGUID,
aOldValue));
// Note: folder-nodes set their own bookmark observer only once they're
// opened, meaning we cannot optimize this code path for changes done to
@ -4490,7 +4495,7 @@ nsNavHistoryResult::OnItemChanged(int64_t aItemId,
folder->StartIncrementalUpdate()) {
node->OnItemChanged(aItemId, aProperty, aIsAnnotationProperty,
aNewValue, aLastModified, aItemType, aParentId,
aGUID, aParentGUID);
aGUID, aParentGUID, aOldValue);
}
}
}

View File

@ -281,7 +281,8 @@ public:
uint16_t aItemType,
int64_t aParentId,
const nsACString& aGUID,
const nsACString& aParentGUID);
const nsACString& aParentGUID,
const nsACString &aOldValue);
protected:
virtual ~nsNavHistoryResultNode() {}

View File

@ -43,11 +43,13 @@ let bookmarksObserver = {
this._itemRemovedIndex = index;
},
onItemChanged: function(id, property, isAnnotationProperty, value,
lastModified, itemType) {
lastModified, itemType, parentId, guid, parentGuid,
oldValue) {
this._itemChangedId = id;
this._itemChangedProperty = property;
this._itemChanged_isAnnotationProperty = isAnnotationProperty;
this._itemChangedValue = value;
this._itemChangedOldValue = oldValue;
},
onItemVisited: function(id, visitID, time) {
this._itemVisitedId = id;
@ -452,6 +454,7 @@ add_task(function test_bookmarks() {
do_check_eq(bookmarksObserver._itemChangedId, newId10);
do_check_eq(bookmarksObserver._itemChangedProperty, "uri");
do_check_eq(bookmarksObserver._itemChangedValue, "http://foo11.com/");
do_check_eq(bookmarksObserver._itemChangedOldValue, "http://foo10.com/");
// test getBookmarkURI
let newId11 = bs.insertBookmark(testRoot, uri("http://foo11.com/"),

View File

@ -94,7 +94,7 @@ add_task(function* insert_bookmark_tag_notification() {
{ name: "onItemChanged",
arguments: [ itemId, "tags", false, "",
bm.lastModified, bm.type, parentId,
bm.guid, bm.parentGuid ] }
bm.guid, bm.parentGuid, "" ] }
]);
});
@ -111,7 +111,7 @@ add_task(function* update_bookmark_lastModified() {
observer.check([ { name: "onItemChanged",
arguments: [ itemId, "lastModified", false,
`${bm.lastModified * 1000}`, bm.lastModified,
bm.type, parentId, bm.guid, bm.parentGuid ] }
bm.type, parentId, bm.guid, bm.parentGuid, "" ] }
]);
});
@ -128,7 +128,7 @@ add_task(function* update_bookmark_title() {
observer.check([ { name: "onItemChanged",
arguments: [ itemId, "title", false, bm.title,
bm.lastModified, bm.type, parentId, bm.guid,
bm.parentGuid ] }
bm.parentGuid, "" ] }
]);
});
@ -145,7 +145,7 @@ add_task(function* update_bookmark_uri() {
observer.check([ { name: "onItemChanged",
arguments: [ itemId, "uri", false, bm.url.href,
bm.lastModified, bm.type, parentId, bm.guid,
bm.parentGuid ] }
bm.parentGuid, "http://url.example.com/" ] }
]);
});
@ -264,7 +264,7 @@ add_task(function* remove_bookmark_tag_notification() {
{ name: "onItemChanged",
arguments: [ itemId, "tags", false, "",
bm.lastModified, bm.type, parentId,
bm.guid, bm.parentGuid ] }
bm.guid, bm.parentGuid, "" ] }
]);
});

View File

@ -44,7 +44,7 @@ function expectNotifications() {
}
if (name.startsWith("onItemChanged")) {
return (id, prop, isAnno, val, lastMod, itemType, parentId, guid, parentGuid) => {
return (id, prop, isAnno, val, lastMod, itemType, parentId, guid, parentGuid, oldVal) => {
if (prop != "keyword")
return;
let args = Array.from(arguments, arg => {
@ -97,7 +97,7 @@ add_task(function test_addBookmarkAndKeyword() {
arguments: [ itemId, "keyword", false, "keyword",
bookmark.lastModified, bookmark.type,
(yield PlacesUtils.promiseItemId(bookmark.parentGuid)),
bookmark.guid, bookmark.parentGuid ] }
bookmark.guid, bookmark.parentGuid, "" ] }
]);
yield PlacesTestUtils.promiseAsyncUpdates();
@ -148,12 +148,12 @@ add_task(function test_sameKeywordDifferentURI() {
"keyword", false, "",
bookmark1.lastModified, bookmark1.type,
(yield PlacesUtils.promiseItemId(bookmark1.parentGuid)),
bookmark1.guid, bookmark1.parentGuid ] },
bookmark1.guid, bookmark1.parentGuid, "" ] },
{ name: "onItemChanged",
arguments: [ itemId, "keyword", false, "keyword",
bookmark2.lastModified, bookmark2.type,
(yield PlacesUtils.promiseItemId(bookmark2.parentGuid)),
bookmark2.guid, bookmark2.parentGuid ] }
bookmark2.guid, bookmark2.parentGuid, "" ] }
]);
yield PlacesTestUtils.promiseAsyncUpdates();
@ -187,13 +187,13 @@ add_task(function test_sameURIDifferentKeyword() {
"keyword", false, "keyword2",
bookmarks[0].lastModified, bookmarks[0].type,
(yield PlacesUtils.promiseItemId(bookmarks[0].parentGuid)),
bookmarks[0].guid, bookmarks[0].parentGuid ] },
bookmarks[0].guid, bookmarks[0].parentGuid, "" ] },
{ name: "onItemChanged",
arguments: [ (yield PlacesUtils.promiseItemId(bookmarks[1].guid)),
"keyword", false, "keyword2",
bookmarks[1].lastModified, bookmarks[1].type,
(yield PlacesUtils.promiseItemId(bookmarks[1].parentGuid)),
bookmarks[1].guid, bookmarks[1].parentGuid ] }
bookmarks[1].guid, bookmarks[1].parentGuid, "" ] }
]);
yield PlacesTestUtils.promiseAsyncUpdates();
@ -243,19 +243,19 @@ add_task(function test_unsetKeyword() {
"keyword", false, "",
bookmarks[0].lastModified, bookmarks[0].type,
(yield PlacesUtils.promiseItemId(bookmarks[0].parentGuid)),
bookmarks[0].guid, bookmarks[0].parentGuid ] },
bookmarks[0].guid, bookmarks[0].parentGuid, "" ] },
{ name: "onItemChanged",
arguments: [ (yield PlacesUtils.promiseItemId(bookmarks[1].guid)),
"keyword", false, "",
bookmarks[1].lastModified, bookmarks[1].type,
(yield PlacesUtils.promiseItemId(bookmarks[1].parentGuid)),
bookmarks[1].guid, bookmarks[1].parentGuid ] },
bookmarks[1].guid, bookmarks[1].parentGuid, "" ] },
{ name: "onItemChanged",
arguments: [ (yield PlacesUtils.promiseItemId(bookmarks[2].guid)),
"keyword", false, "",
bookmarks[2].lastModified, bookmarks[2].type,
(yield PlacesUtils.promiseItemId(bookmarks[2].parentGuid)),
bookmarks[2].guid, bookmarks[2].parentGuid ] }
bookmarks[2].guid, bookmarks[2].parentGuid, "" ] }
]);
check_keyword(URI1, null);
@ -286,7 +286,7 @@ add_task(function test_addRemoveBookmark() {
"keyword", false, "keyword",
bookmark.lastModified, bookmark.type,
parentId,
bookmark.guid, bookmark.parentGuid ] }
bookmark.guid, bookmark.parentGuid, "" ] }
]);
check_keyword(URI3, null);

View File

@ -21,20 +21,27 @@ let gBookmarksObserver = {
},
// nsINavBookmarkObserver
onBeginUpdateBatch: function onBeginUpdateBatch()
this.validate(arguments.callee.name, arguments),
onEndUpdateBatch: function onEndUpdateBatch()
this.validate(arguments.callee.name, arguments),
onItemAdded: function onItemAdded()
this.validate(arguments.callee.name, arguments),
onItemRemoved: function onItemRemoved()
this.validate(arguments.callee.name, arguments),
onItemChanged: function onItemChanged()
this.validate(arguments.callee.name, arguments),
onItemVisited: function onItemVisited()
this.validate(arguments.callee.name, arguments),
onItemMoved: function onItemMoved()
this.validate(arguments.callee.name, arguments),
onBeginUpdateBatch() {
return this.validate("onBeginUpdateBatch", arguments);
},
onEndUpdateBatch() {
return this.validate("onEndUpdateBatch", arguments);
},
onItemAdded() {
return this.validate("onItemAdded", arguments);
},
onItemRemoved() {
return this.validate("onItemRemoved", arguments);
},
onItemChanged() {
return this.validate("onItemChanged", arguments);
},
onItemVisited() {
return this.validate("onItemVisited", arguments);
},
onItemMoved() {
return this.validate("onItemMoved", arguments);
},
// nsISupports
QueryInterface: XPCOMUtils.generateQI([Ci.nsINavBookmarkObserver]),
@ -132,6 +139,7 @@ add_test(function onItemChanged_title_bookmark() {
{ name: "parentId", check: function (v) v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: function (v) typeof(v) == "string" },
] },
];
PlacesUtils.bookmarks.setItemTitle(id, TITLE);
@ -178,6 +186,7 @@ add_test(function onItemChanged_tags_bookmark() {
{ name: "parentId", check: function (v) v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: function (v) typeof(v) == "string" },
] },
{ name: "onItemRemoved", // This is the tag.
args: [
@ -210,6 +219,7 @@ add_test(function onItemChanged_tags_bookmark() {
{ name: "parentId", check: function (v) v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: function (v) typeof(v) == "string" },
] },
];
PlacesUtils.tagging.tagURI(uri, [TAG]);
@ -283,6 +293,7 @@ add_test(function onItemRemoved_bookmark() {
{ name: "parentId", check: function (v) v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: function (v) typeof(v) == "string" },
] },
{ name: "onItemRemoved",
args: [
@ -312,6 +323,7 @@ add_test(function onItemRemoved_separator() {
{ name: "parentId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: function (v) typeof(v) == "string" },
] },
{ name: "onItemRemoved",
args: [
@ -342,6 +354,7 @@ add_test(function onItemRemoved_folder() {
{ name: "parentId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: function (v) typeof(v) == "string" },
] },
{ name: "onItemRemoved",
args: [

View File

@ -185,7 +185,7 @@ add_task(function* test_addBookmarkAndKeyword() {
"keyword", false, "keyword",
bookmark.lastModified, bookmark.type,
(yield PlacesUtils.promiseItemId(bookmark.parentGuid)),
bookmark.guid, bookmark.parentGuid ] } ]);
bookmark.guid, bookmark.parentGuid, "" ] } ]);
yield check_keyword(true, "http://example.com/", "keyword");
Assert.equal((yield foreign_count("http://example.com/")), fc + 2); // +1 bookmark +1 keyword
@ -199,7 +199,7 @@ add_task(function* test_addBookmarkAndKeyword() {
"keyword", false, "",
bookmark.lastModified, bookmark.type,
(yield PlacesUtils.promiseItemId(bookmark.parentGuid)),
bookmark.guid, bookmark.parentGuid ] } ]);
bookmark.guid, bookmark.parentGuid, "" ] } ]);
yield check_keyword(false, "http://example.com/", "keyword");
Assert.equal((yield foreign_count("http://example.com/")), fc + 1); // -1 keyword
@ -312,13 +312,13 @@ add_task(function* test_sameKeywordDifferentURL() {
"keyword", false, "",
bookmark1.lastModified, bookmark1.type,
(yield PlacesUtils.promiseItemId(bookmark1.parentGuid)),
bookmark1.guid, bookmark1.parentGuid ] },
bookmark1.guid, bookmark1.parentGuid, "" ] },
{ name: "onItemChanged",
arguments: [ (yield PlacesUtils.promiseItemId(bookmark2.guid)),
"keyword", false, "keyword",
bookmark2.lastModified, bookmark2.type,
(yield PlacesUtils.promiseItemId(bookmark2.parentGuid)),
bookmark2.guid, bookmark2.parentGuid ] } ]);
bookmark2.guid, bookmark2.parentGuid, "" ] } ]);
yield check_keyword(false, "http://example1.com/", "keyword");
Assert.equal((yield foreign_count("http://example1.com/")), fc1 + 1); // -1 keyword
@ -333,7 +333,7 @@ add_task(function* test_sameKeywordDifferentURL() {
"keyword", false, "",
bookmark2.lastModified, bookmark2.type,
(yield PlacesUtils.promiseItemId(bookmark2.parentGuid)),
bookmark2.guid, bookmark2.parentGuid ] } ]);
bookmark2.guid, bookmark2.parentGuid, "" ] } ]);
yield check_keyword(false, "http://example1.com/", "keyword");
yield check_keyword(false, "http://example2.com/", "keyword");
@ -365,7 +365,7 @@ add_task(function* test_sameURIDifferentKeyword() {
"keyword", false, "keyword",
bookmark.lastModified, bookmark.type,
(yield PlacesUtils.promiseItemId(bookmark.parentGuid)),
bookmark.guid, bookmark.parentGuid ] } ]);
bookmark.guid, bookmark.parentGuid, "" ] } ]);
observer = expectBookmarkNotifications();
yield PlacesUtils.keywords.insert({ keyword: "keyword2", url: "http://example.com/" });
@ -377,7 +377,7 @@ add_task(function* test_sameURIDifferentKeyword() {
"keyword", false, "keyword2",
bookmark.lastModified, bookmark.type,
(yield PlacesUtils.promiseItemId(bookmark.parentGuid)),
bookmark.guid, bookmark.parentGuid ] } ]);
bookmark.guid, bookmark.parentGuid, "" ] } ]);
// Add a third keyword.
yield PlacesUtils.keywords.insert({ keyword: "keyword3", url: "http://example.com/" });
@ -397,7 +397,7 @@ add_task(function* test_sameURIDifferentKeyword() {
"keyword", false, "",
bookmark.lastModified, bookmark.type,
(yield PlacesUtils.promiseItemId(bookmark.parentGuid)),
bookmark.guid, bookmark.parentGuid ] } ]);
bookmark.guid, bookmark.parentGuid, "" ] } ]);
Assert.equal((yield foreign_count("http://example.com/")), fc + 3); // -1 keyword
// Now remove the bookmark.
@ -429,13 +429,13 @@ add_task(function* test_deleteKeywordMultipleBookmarks() {
"keyword", false, "keyword",
bookmark2.lastModified, bookmark2.type,
(yield PlacesUtils.promiseItemId(bookmark2.parentGuid)),
bookmark2.guid, bookmark2.parentGuid ] },
bookmark2.guid, bookmark2.parentGuid, "" ] },
{ name: "onItemChanged",
arguments: [ (yield PlacesUtils.promiseItemId(bookmark1.guid)),
"keyword", false, "keyword",
bookmark1.lastModified, bookmark1.type,
(yield PlacesUtils.promiseItemId(bookmark1.parentGuid)),
bookmark1.guid, bookmark1.parentGuid ] } ]);
bookmark1.guid, bookmark1.parentGuid, "" ] } ]);
observer = expectBookmarkNotifications();
yield PlacesUtils.keywords.remove("keyword");
@ -446,13 +446,13 @@ add_task(function* test_deleteKeywordMultipleBookmarks() {
"keyword", false, "",
bookmark2.lastModified, bookmark2.type,
(yield PlacesUtils.promiseItemId(bookmark2.parentGuid)),
bookmark2.guid, bookmark2.parentGuid ] },
bookmark2.guid, bookmark2.parentGuid, "" ] },
{ name: "onItemChanged",
arguments: [ (yield PlacesUtils.promiseItemId(bookmark1.guid)),
"keyword", false, "",
bookmark1.lastModified, bookmark1.type,
(yield PlacesUtils.promiseItemId(bookmark1.parentGuid)),
bookmark1.guid, bookmark1.parentGuid ] } ]);
bookmark1.guid, bookmark1.parentGuid, "" ] } ]);
// Now remove the bookmarks.
yield PlacesUtils.bookmarks.remove(bookmark1);