--- a/toolkit/components/places/tests/bookmarks/test_bookmarks_notifications.js
+++ b/toolkit/components/places/tests/bookmarks/test_bookmarks_notifications.js
@@ -4,79 +4,79 @@
add_task(async function insert_separator_notification() {
let observer = expectNotifications();
let bm = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_SEPARATOR,
parentGuid: PlacesUtils.bookmarks.unfiledGuid});
let itemId = await PlacesUtils.promiseItemId(bm.guid);
let parentId = await PlacesUtils.promiseItemId(bm.parentGuid);
observer.check([ { name: "onItemAdded",
arguments: [ itemId, parentId, bm.index, bm.type,
- null, "", bm.dateAdded * 1000,
+ null, "", PlacesUtils.toPRTime(bm.dateAdded),
bm.guid, bm.parentGuid,
Ci.nsINavBookmarksService.SOURCE_DEFAULT ] }
]);
});
add_task(async function insert_folder_notification() {
let observer = expectNotifications();
let bm = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_FOLDER,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
title: "a folder" });
let itemId = await PlacesUtils.promiseItemId(bm.guid);
let parentId = await PlacesUtils.promiseItemId(bm.parentGuid);
observer.check([ { name: "onItemAdded",
arguments: [ itemId, parentId, bm.index, bm.type,
- null, bm.title, bm.dateAdded * 1000,
+ null, bm.title, PlacesUtils.toPRTime(bm.dateAdded),
bm.guid, bm.parentGuid,
Ci.nsINavBookmarksService.SOURCE_DEFAULT ] }
]);
});
add_task(async function insert_folder_notitle_notification() {
let observer = expectNotifications();
let bm = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_FOLDER,
parentGuid: PlacesUtils.bookmarks.unfiledGuid });
strictEqual(bm.title, "", "Should return empty string for untitled folder");
let itemId = await PlacesUtils.promiseItemId(bm.guid);
let parentId = await PlacesUtils.promiseItemId(bm.parentGuid);
observer.check([ { name: "onItemAdded",
arguments: [ itemId, parentId, bm.index, bm.type,
- null, "", bm.dateAdded * 1000,
+ null, "", PlacesUtils.toPRTime(bm.dateAdded),
bm.guid, bm.parentGuid,
Ci.nsINavBookmarksService.SOURCE_DEFAULT ] }
]);
});
add_task(async function insert_bookmark_notification() {
let observer = expectNotifications();
let bm = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: new URL("http://example.com/"),
title: "a bookmark" });
let itemId = await PlacesUtils.promiseItemId(bm.guid);
let parentId = await PlacesUtils.promiseItemId(bm.parentGuid);
observer.check([ { name: "onItemAdded",
arguments: [ itemId, parentId, bm.index, bm.type,
- bm.url, bm.title, bm.dateAdded * 1000,
+ bm.url, bm.title, PlacesUtils.toPRTime(bm.dateAdded),
bm.guid, bm.parentGuid,
Ci.nsINavBookmarksService.SOURCE_DEFAULT ] }
]);
});
add_task(async function insert_bookmark_notitle_notification() {
let observer = expectNotifications();
let bm = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: new URL("http://example.com/") });
strictEqual(bm.title, "", "Should return empty string for untitled bookmark");
let itemId = await PlacesUtils.promiseItemId(bm.guid);
let parentId = await PlacesUtils.promiseItemId(bm.parentGuid);
observer.check([ { name: "onItemAdded",
arguments: [ itemId, parentId, bm.index, bm.type,
- bm.url, "", bm.dateAdded * 1000,
+ bm.url, "", PlacesUtils.toPRTime(bm.dateAdded),
bm.guid, bm.parentGuid,
Ci.nsINavBookmarksService.SOURCE_DEFAULT ] }
]);
});
add_task(async function insert_bookmark_tag_notification() {
let bm = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
@@ -91,40 +91,41 @@ add_task(async function insert_bookmark_
let tag = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: tagFolder.guid,
url: new URL("http://tag.example.com/") });
let tagId = await PlacesUtils.promiseItemId(tag.guid);
let tagParentId = await PlacesUtils.promiseItemId(tag.parentGuid);
observer.check([ { name: "onItemAdded",
arguments: [ tagId, tagParentId, tag.index, tag.type,
- tag.url, "", tag.dateAdded * 1000,
+ tag.url, "", PlacesUtils.toPRTime(tag.dateAdded),
tag.guid, tag.parentGuid,
Ci.nsINavBookmarksService.SOURCE_DEFAULT ] },
{ name: "onItemChanged",
arguments: [ itemId, "tags", false, "",
- bm.lastModified * 1000, bm.type, parentId,
- bm.guid, bm.parentGuid, "",
+ PlacesUtils.toPRTime(bm.lastModified),
+ bm.type, parentId, bm.guid, bm.parentGuid, "",
Ci.nsINavBookmarksService.SOURCE_DEFAULT ] }
]);
});
add_task(async function update_bookmark_lastModified() {
let bm = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: new URL("http://lastmod.example.com/") });
let observer = expectNotifications();
bm = await PlacesUtils.bookmarks.update({ guid: bm.guid,
lastModified: new Date() });
let itemId = await PlacesUtils.promiseItemId(bm.guid);
let parentId = await PlacesUtils.promiseItemId(bm.parentGuid);
observer.check([ { name: "onItemChanged",
arguments: [ itemId, "lastModified", false,
- `${bm.lastModified * 1000}`, bm.lastModified * 1000,
+ `${PlacesUtils.toPRTime(bm.lastModified)}`,
+ PlacesUtils.toPRTime(bm.lastModified),
bm.type, parentId, bm.guid, bm.parentGuid, "",
Ci.nsINavBookmarksService.SOURCE_DEFAULT ] }
]);
});
add_task(async function update_bookmark_title() {
let bm = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
@@ -132,34 +133,36 @@ add_task(async function update_bookmark_
let observer = expectNotifications();
bm = await PlacesUtils.bookmarks.update({ guid: bm.guid,
title: "new title" });
let itemId = await PlacesUtils.promiseItemId(bm.guid);
let parentId = await PlacesUtils.promiseItemId(bm.parentGuid);
observer.check([ { name: "onItemChanged",
arguments: [ itemId, "title", false, bm.title,
- bm.lastModified * 1000, bm.type, parentId, bm.guid,
+ PlacesUtils.toPRTime(bm.lastModified),
+ bm.type, parentId, bm.guid,
bm.parentGuid, "", Ci.nsINavBookmarksService.SOURCE_DEFAULT ] }
]);
});
add_task(async function update_bookmark_uri() {
let bm = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: new URL("http://url.example.com/") });
let observer = expectNotifications();
bm = await PlacesUtils.bookmarks.update({ guid: bm.guid,
url: "http://mozilla.org/" });
let itemId = await PlacesUtils.promiseItemId(bm.guid);
let parentId = await PlacesUtils.promiseItemId(bm.parentGuid);
observer.check([ { name: "onItemChanged",
arguments: [ itemId, "uri", false, bm.url.href,
- bm.lastModified * 1000, bm.type, parentId, bm.guid,
+ PlacesUtils.toPRTime(bm.lastModified),
+ bm.type, parentId, bm.guid,
bm.parentGuid, "http://url.example.com/",
Ci.nsINavBookmarksService.SOURCE_DEFAULT ] }
]);
});
add_task(async function update_move_same_folder() {
// Ensure there are at least two items in place (others test do so for us,
// but we don't have to depend on that).
@@ -298,18 +301,18 @@ add_task(async function remove_bookmark_
await PlacesUtils.bookmarks.remove(tag.guid);
observer.check([ { name: "onItemRemoved",
arguments: [ tagId, tagParentId, tag.index, tag.type,
tag.url, tag.guid, tag.parentGuid,
Ci.nsINavBookmarksService.SOURCE_DEFAULT ] },
{ name: "onItemChanged",
arguments: [ itemId, "tags", false, "",
- bm.lastModified * 1000, bm.type, parentId,
- bm.guid, bm.parentGuid, "",
+ PlacesUtils.toPRTime(bm.lastModified),
+ bm.type, parentId, bm.guid, bm.parentGuid, "",
Ci.nsINavBookmarksService.SOURCE_DEFAULT ] }
]);
});
add_task(async function remove_folder_notification() {
let folder1 = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_FOLDER,
parentGuid: PlacesUtils.bookmarks.unfiledGuid });
let folder1Id = await PlacesUtils.promiseItemId(folder1.guid);
@@ -538,29 +541,29 @@ add_task(async function update_notitle_n
let updatedMenuBm = await PlacesUtils.bookmarks.update({
guid: menuFolder.guid,
title: null,
});
strictEqual(updatedMenuBm.title, "",
"Async API should return empty string for untitled bookmark");
- let toolbarBmModified =
- PlacesUtils.toDate(PlacesUtils.bookmarks.getItemLastModified(toolbarBmId));
+ let toolbarBmModified = await PlacesUtils.bookmarks.fetch(toolbarBmGuid);
observer.check([{
name: "onItemChanged",
- arguments: [toolbarBmId, "title", false, "", toolbarBmModified * 1000,
+ arguments: [toolbarBmId, "title", false, "",
+ PlacesUtils.toPRTime(toolbarBmModified.lastModified),
PlacesUtils.bookmarks.TYPE_BOOKMARK,
PlacesUtils.toolbarFolderId, toolbarBmGuid,
PlacesUtils.bookmarks.toolbarGuid,
"", PlacesUtils.bookmarks.SOURCES.DEFAULT],
}, {
name: "onItemChanged",
arguments: [menuFolderId, "title", false, "",
- updatedMenuBm.lastModified * 1000,
+ PlacesUtils.toPRTime(updatedMenuBm.lastModified),
PlacesUtils.bookmarks.TYPE_FOLDER,
PlacesUtils.bookmarksMenuFolderId, menuFolder.guid,
PlacesUtils.bookmarks.menuGuid,
"", PlacesUtils.bookmarks.SOURCES.DEFAULT],
}]);
});
function expectNotifications() {