--- a/services/sync/tests/unit/test_bookmark_tracker.js
+++ b/services/sync/tests/unit/test_bookmark_tracker.js
@@ -1062,58 +1062,16 @@ add_task(async function test_onLivemarkD
await verifyTrackedItems(["menu", livemark.guid]);
Assert.equal(tracker.score, SCORE_INCREMENT_XLARGE);
} finally {
_("Clean up.");
await cleanup();
}
});
-add_task(async function test_onItemMoved() {
- _("Items moved via the synchronous API should be tracked");
-
- try {
- let fx_id = PlacesUtils.bookmarks.insertBookmark(
- PlacesUtils.bookmarks.bookmarksMenuFolder,
- CommonUtils.makeURI("http://getfirefox.com"),
- PlacesUtils.bookmarks.DEFAULT_INDEX,
- "Get Firefox!");
- let fx_guid = await PlacesUtils.promiseItemGuid(fx_id);
- _("Firefox GUID: " + fx_guid);
- let tb_id = PlacesUtils.bookmarks.insertBookmark(
- PlacesUtils.bookmarks.bookmarksMenuFolder,
- CommonUtils.makeURI("http://getthunderbird.com"),
- PlacesUtils.bookmarks.DEFAULT_INDEX,
- "Get Thunderbird!");
- let tb_guid = await PlacesUtils.promiseItemGuid(tb_id);
- _("Thunderbird GUID: " + tb_guid);
-
- await startTracking();
-
- // Moving within the folder will just track the folder.
- PlacesUtils.bookmarks.moveItem(
- tb_id, PlacesUtils.bookmarks.bookmarksMenuFolder, 0);
- await verifyTrackedItems(["menu"]);
- Assert.equal(tracker.score, SCORE_INCREMENT_XLARGE);
- await resetTracker();
- await PlacesTestUtils.markBookmarksAsSynced();
-
- // Moving a bookmark to a different folder will track the old
- // folder, the new folder and the bookmark.
- PlacesUtils.bookmarks.moveItem(fx_id, PlacesUtils.bookmarks.toolbarFolder,
- PlacesUtils.bookmarks.DEFAULT_INDEX);
- await verifyTrackedItems(["menu", "toolbar", fx_guid]);
- Assert.equal(tracker.score, SCORE_INCREMENT_XLARGE);
-
- } finally {
- _("Clean up.");
- await cleanup();
- }
-});
-
add_task(async function test_async_onItemMoved_update() {
_("Items moved via the asynchronous API should be tracked");
try {
await tracker.stop();
await PlacesUtils.bookmarks.insert({
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@@ -1258,48 +1216,52 @@ add_task(async function test_onItemDelet
}
});
add_task(async function test_treeMoved() {
_("Moving an entire tree of bookmarks should track the parents");
try {
// Create a couple of parent folders.
- let folder1_id = PlacesUtils.bookmarks.createFolder(
- PlacesUtils.bookmarks.bookmarksMenuFolder,
- "First test folder",
- PlacesUtils.bookmarks.DEFAULT_INDEX);
- let folder1_guid = await PlacesUtils.promiseItemGuid(folder1_id);
+ let folder1 = await PlacesUtils.bookmarks.insert({
+ parentGuid: PlacesUtils.bookmarks.menuGuid,
+ test: "First test folder",
+ type: PlacesUtils.bookmarks.TYPE_FOLDER
+ });
// A second folder in the first.
- let folder2_id = PlacesUtils.bookmarks.createFolder(
- folder1_id,
- "Second test folder",
- PlacesUtils.bookmarks.DEFAULT_INDEX);
- let folder2_guid = await PlacesUtils.promiseItemGuid(folder2_id);
+ let folder2 = await PlacesUtils.bookmarks.insert({
+ parentGuid: folder1.guid,
+ title: "Second test folder",
+ type: PlacesUtils.bookmarks.TYPE_FOLDER
+ });
// Create a couple of bookmarks in the second folder.
- PlacesUtils.bookmarks.insertBookmark(
- folder2_id,
- CommonUtils.makeURI("http://getfirefox.com"),
- PlacesUtils.bookmarks.DEFAULT_INDEX,
- "Get Firefox!");
- PlacesUtils.bookmarks.insertBookmark(
- folder2_id,
- CommonUtils.makeURI("http://getthunderbird.com"),
- PlacesUtils.bookmarks.DEFAULT_INDEX,
- "Get Thunderbird!");
+ await PlacesUtils.bookmarks.insert({
+ parentGuid: folder2.guid,
+ url: "http://getfirefox.com",
+ title: "Get Firefox!"
+ });
+ await PlacesUtils.bookmarks.insert({
+ parentGuid: folder2.guid,
+ url: "http://getthunderbird.com",
+ title: "Get Thunderbird!"
+ });
await startTracking();
// Move folder 2 to be a sibling of folder1.
- PlacesUtils.bookmarks.moveItem(
- folder2_id, PlacesUtils.bookmarks.bookmarksMenuFolder, 0);
+ await PlacesUtils.bookmarks.update({
+ guid: folder2.guid,
+ parentGuid: PlacesUtils.bookmarks.menuGuid,
+ index: 0
+ });
+
// the menu and both folders should be tracked, the children should not be.
- await verifyTrackedItems(["menu", folder1_guid, folder2_guid]);
+ await verifyTrackedItems(["menu", folder1.guid, folder2.guid]);
Assert.equal(tracker.score, SCORE_INCREMENT_XLARGE);
} finally {
_("Clean up.");
await cleanup();
}
});
add_task(async function test_onItemDeleted() {
--- a/toolkit/components/places/nsINavBookmarksService.idl
+++ b/toolkit/components/places/nsINavBookmarksService.idl
@@ -409,37 +409,16 @@ interface nsINavBookmarksService : nsISu
* @param [optional] aSource
* The change source, forwarded to all bookmark observers. Defaults
* to SOURCE_DEFAULT.
*/
void removeFolderChildren(in long long aItemId,
[optional] in unsigned short aSource);
/**
- * Moves an item to a different container, preserving its contents.
- * @param aItemId
- * The id of the item to move
- * @param aNewParentId
- * The id of the new parent
- * @param aIndex
- * The index under aNewParent, or DEFAULT_INDEX to append
- * @param [optional] aSource
- * The change source, forwarded to all bookmark observers. Defaults
- * to SOURCE_DEFAULT.
- *
- * NOTE: When moving down in the same container we take into account the
- * removal of the original item. If you want to move from index X to
- * index Y > X you must use moveItem(id, folder, Y + 1)
- */
- void moveItem(in long long aItemId,
- in long long aNewParentId,
- in long aIndex,
- [optional] in unsigned short aSource);
-
- /**
* Set the title for an item.
* @param aItemId
* The id of the item whose title should be updated.
* @param aTitle
* The new title for the bookmark.
* @param [optional] aSource
* The change source, forwarded to all bookmark observers. Defaults
* to SOURCE_DEFAULT.
--- a/toolkit/components/places/nsNavBookmarks.cpp
+++ b/toolkit/components/places/nsNavBookmarks.cpp
@@ -1140,195 +1140,16 @@ nsNavBookmarks::RemoveFolderChildren(int
}
}
}
return NS_OK;
}
-NS_IMETHODIMP
-nsNavBookmarks::MoveItem(int64_t aItemId,
- int64_t aNewParent,
- int32_t aIndex,
- uint16_t aSource)
-{
- NS_ENSURE_ARG(!IsRoot(aItemId));
- NS_ENSURE_ARG_MIN(aItemId, 1);
- NS_ENSURE_ARG_MIN(aNewParent, 1);
- // -1 is append, but no other negative number is allowed.
- NS_ENSURE_ARG_MIN(aIndex, -1);
- // Disallow making an item its own parent.
- NS_ENSURE_ARG(aItemId != aNewParent);
-
- mozStorageTransaction transaction(mDB->MainConn(), false);
-
- BookmarkData bookmark;
- nsresult rv = FetchItemInfo(aItemId, bookmark);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // if parent and index are the same, nothing to do
- if (bookmark.parentId == aNewParent && bookmark.position == aIndex)
- return NS_OK;
-
- // Make sure aNewParent is not aFolder or a subfolder of aFolder.
- // TODO: make this performant, maybe with a nested tree (bug 408991).
- if (bookmark.type == TYPE_FOLDER) {
- int64_t ancestorId = aNewParent;
-
- while (ancestorId) {
- if (ancestorId == bookmark.id) {
- return NS_ERROR_INVALID_ARG;
- }
- rv = GetFolderIdForItem(ancestorId, &ancestorId);
- if (NS_FAILED(rv)) {
- break;
- }
- }
- }
-
- // calculate new index
- int32_t newIndex, folderCount;
- int64_t grandParentId;
- nsAutoCString newParentGuid;
- rv = FetchFolderInfo(aNewParent, &folderCount, newParentGuid, &grandParentId);
- NS_ENSURE_SUCCESS(rv, rv);
- if (aIndex == nsINavBookmarksService::DEFAULT_INDEX ||
- aIndex >= folderCount) {
- newIndex = folderCount;
- // If the parent remains the same, then the folder is really being moved
- // to count - 1 (since it's being removed from the old position)
- if (bookmark.parentId == aNewParent) {
- --newIndex;
- }
- } else {
- newIndex = aIndex;
-
- if (bookmark.parentId == aNewParent && newIndex > bookmark.position) {
- // when an item is being moved lower in the same folder, the new index
- // refers to the index before it was removed. Removal causes everything
- // to shift up.
- --newIndex;
- }
- }
-
- // this is like the previous check, except this covers if
- // the specified index was -1 (append), and the calculated
- // new index is the same as the existing index
- if (aNewParent == bookmark.parentId && newIndex == bookmark.position) {
- // Nothing to do!
- return NS_OK;
- }
-
- // adjust indices to account for the move
- // do this before we update the parent/index fields
- // or we'll re-adjust the index for the item we are moving
- bool sameParent = bookmark.parentId == aNewParent;
- if (sameParent) {
- // We can optimize the updates if moving within the same container.
- // We only shift the items between the old and new positions, since the
- // insertion will offset the deletion.
- if (bookmark.position > newIndex) {
- rv = AdjustIndices(bookmark.parentId, newIndex, bookmark.position - 1, 1);
- }
- else {
- rv = AdjustIndices(bookmark.parentId, bookmark.position + 1, newIndex, -1);
- }
- NS_ENSURE_SUCCESS(rv, rv);
- }
- else {
- // We're moving between containers, so this happens in two steps.
- // First, fill the hole from the removal from the old parent.
- rv = AdjustIndices(bookmark.parentId, bookmark.position + 1, INT32_MAX, -1);
- NS_ENSURE_SUCCESS(rv, rv);
- // Now, make room in the new parent for the insertion.
- rv = AdjustIndices(aNewParent, newIndex, INT32_MAX, 1);
- NS_ENSURE_SUCCESS(rv, rv);
- }
-
- int64_t syncChangeDelta = DetermineSyncChangeDelta(aSource);
-
- {
- // Update parent and position.
- nsCOMPtr<mozIStorageStatement> stmt = mDB->GetStatement(
- "UPDATE moz_bookmarks SET parent = :parent, position = :item_index "
- "WHERE id = :item_id "
- );
- NS_ENSURE_STATE(stmt);
- mozStorageStatementScoper scoper(stmt);
-
- rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("parent"), aNewParent);
- NS_ENSURE_SUCCESS(rv, rv);
- rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("item_index"), newIndex);
- NS_ENSURE_SUCCESS(rv, rv);
- rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("item_id"), bookmark.id);
- NS_ENSURE_SUCCESS(rv, rv);
- rv = stmt->Execute();
- NS_ENSURE_SUCCESS(rv, rv);
- }
-
- PRTime now = RoundedPRNow();
- rv = SetItemDateInternal(LAST_MODIFIED, syncChangeDelta,
- bookmark.parentId, now);
- NS_ENSURE_SUCCESS(rv, rv);
- if (sameParent) {
- // If we're moving within the same container, only the parent needs a sync
- // change. Update the item's last modified date without bumping its counter.
- rv = SetItemDateInternal(LAST_MODIFIED, 0, bookmark.id, now);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Mark all affected separators as changed
- int32_t startIndex = std::min(bookmark.position, newIndex);
- rv = AdjustSeparatorsSyncCounter(bookmark.parentId, startIndex, syncChangeDelta);
- NS_ENSURE_SUCCESS(rv, rv);
- } else {
- // Otherwise, if we're moving between containers, both parents and the child
- // need sync changes.
- rv = SetItemDateInternal(LAST_MODIFIED, syncChangeDelta, aNewParent, now);
- NS_ENSURE_SUCCESS(rv, rv);
- rv = SetItemDateInternal(LAST_MODIFIED, syncChangeDelta, bookmark.id, now);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Mark all affected separators as changed
- rv = AdjustSeparatorsSyncCounter(bookmark.parentId, bookmark.position, syncChangeDelta);
- NS_ENSURE_SUCCESS(rv, rv);
- rv = AdjustSeparatorsSyncCounter(aNewParent, newIndex, syncChangeDelta);
- NS_ENSURE_SUCCESS(rv, rv);
- }
-
- int64_t tagsRootId = TagsRootId();
- bool isChangingTagFolder = bookmark.parentId == tagsRootId;
- if (isChangingTagFolder) {
- // Moving a tag folder out of the tags root untags all its bookmarks. This
- // is an odd case, but the tagging service adds an observer to handle it,
- // so we bump the change counter for each untagged item for consistency.
- rv = AddSyncChangesForBookmarksInFolder(bookmark.id, syncChangeDelta);
- NS_ENSURE_SUCCESS(rv, rv);
- }
-
- rv = PreventSyncReparenting(bookmark);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = transaction.Commit();
- NS_ENSURE_SUCCESS(rv, rv);
-
- NOTIFY_OBSERVERS(mCanNotify, mObservers, nsINavBookmarkObserver,
- OnItemMoved(bookmark.id,
- bookmark.parentId,
- bookmark.position,
- aNewParent,
- newIndex,
- bookmark.type,
- bookmark.guid,
- bookmark.parentGuid,
- newParentGuid,
- aSource));
- return NS_OK;
-}
-
nsresult
nsNavBookmarks::FetchItemInfo(int64_t aItemId,
BookmarkData& _bookmark)
{
// LEFT JOIN since not all bookmarks have an associated place.
nsCOMPtr<mozIStorageStatement> stmt = mDB->GetStatement(
"SELECT b.id, h.url, b.title, b.position, b.fk, b.parent, b.type, "
"b.dateAdded, b.lastModified, b.guid, t.guid, t.parent, "
@@ -1650,41 +1471,16 @@ nsNavBookmarks::RemoveTombstone(const ns
nsresult rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("guid"), aGUID);
NS_ENSURE_SUCCESS(rv, rv);
return stmt->Execute();
}
-nsresult
-nsNavBookmarks::PreventSyncReparenting(const BookmarkData& aBookmark)
-{
- nsCOMPtr<mozIStorageStatement> stmt = mDB->GetStatement(
- "DELETE FROM moz_items_annos WHERE "
- "item_id = :item_id AND "
- "anno_attribute_id = (SELECT id FROM moz_anno_attributes "
- "WHERE name = :orphan_anno)"
- );
- NS_ENSURE_STATE(stmt);
- mozStorageStatementScoper scoper(stmt);
-
- nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("item_id"), aBookmark.id);
- NS_ENSURE_SUCCESS(rv, rv);
- rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("orphan_anno"),
- NS_LITERAL_CSTRING(SYNC_PARENT_ANNO));
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = stmt->Execute();
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-
NS_IMETHODIMP
nsNavBookmarks::SetItemTitle(int64_t aItemId, const nsACString& aTitle,
uint16_t aSource)
{
NS_ENSURE_ARG_MIN(aItemId, 1);
BookmarkData bookmark;
nsresult rv = FetchItemInfo(aItemId, bookmark);
--- a/toolkit/components/places/nsNavBookmarks.h
+++ b/toolkit/components/places/nsNavBookmarks.h
@@ -280,22 +280,16 @@ private:
nsresult InsertTombstone(const BookmarkData& aBookmark);
// Inserts tombstones for removed synced items.
nsresult InsertTombstones(const nsTArray<TombstoneData>& aTombstones);
// Removes a stale synced bookmark tombstone.
nsresult RemoveTombstone(const nsACString& aGUID);
- // Removes the Sync orphan annotation from a synced item, so that Sync doesn't
- // try to reparent the item once it sees the original parent. Only synced
- // bookmarks should have this anno, but we do this for all bookmarks because
- // the anno may be backed up and restored.
- nsresult PreventSyncReparenting(const BookmarkData& aBookmark);
-
nsresult SetItemTitleInternal(BookmarkData& aBookmark,
const nsACString& aTitle,
int64_t aSyncChangeDelta);
/**
* This is an handle to the Places database.
*/
RefPtr<mozilla::places::Database> mDB;
--- a/toolkit/components/places/tests/bookmarks/test_sync_fields.js
+++ b/toolkit/components/places/tests/bookmarks/test_sync_fields.js
@@ -62,22 +62,24 @@ class TestCases {
info("Test 1: inserts, updates, tags, and keywords");
try {
await this.testChanges();
} finally {
info("Reset sync fields after test 1");
await PlacesTestUtils.markBookmarksAsSynced();
}
- info("Test 2: reparenting");
- try {
- await this.testReparenting();
- } finally {
- info("Reset sync fields after test 2");
- await PlacesTestUtils.markBookmarksAsSynced();
+ if (("moveItem" in this) && ("reorder" in this)) {
+ info("Test 2: reparenting");
+ try {
+ await this.testReparenting();
+ } finally {
+ info("Reset sync fields after test 2");
+ await PlacesTestUtils.markBookmarksAsSynced();
+ }
}
if ("insertSeparator" in this) {
info("Test 3: separators");
try {
await this.testSeparators();
} finally {
info("Reset sync fields after test 3");
@@ -262,43 +264,29 @@ class SyncTestCases extends TestCases {
}
async insertBookmark(parentGuid, uri, index, title) {
let parentId = await PlacesUtils.promiseItemId(parentGuid);
let id = PlacesUtils.bookmarks.insertBookmark(parentId, uri, index, title);
return PlacesUtils.promiseItemGuid(id);
}
- async moveItem(guid, newParentGuid, index) {
- let id = await PlacesUtils.promiseItemId(guid);
- let newParentId = await PlacesUtils.promiseItemId(newParentGuid);
- PlacesUtils.bookmarks.moveItem(id, newParentId, index);
- }
-
async removeItem(guid) {
let id = await PlacesUtils.promiseItemId(guid);
PlacesUtils.bookmarks.removeItem(id);
}
async setTitle(guid, title) {
let id = await PlacesUtils.promiseItemId(guid);
PlacesUtils.bookmarks.setItemTitle(id, title);
}
async tagURI(uri, tags) {
PlacesUtils.tagging.tagURI(uri, tags);
}
-
- async reorder(parentGuid, childGuids) {
- let parentId = await PlacesUtils.promiseItemId(parentGuid);
- for (let index = 0; index < childGuids.length; ++index) {
- let id = await PlacesUtils.promiseItemId(childGuids[index]);
- PlacesUtils.bookmarks.moveItem(id, parentId, index);
- }
- }
}
async function findTagFolder(tag) {
let db = await PlacesUtils.promiseDBConnection();
let results = await db.executeCached(`
SELECT guid
FROM moz_bookmarks
WHERE type = :type AND
--- a/toolkit/components/places/tests/legacy/test_bookmarks.js
+++ b/toolkit/components/places/tests/legacy/test_bookmarks.js
@@ -241,39 +241,16 @@ add_task(async function test_bookmarks()
let newId6 = bs.insertBookmark(testRoot, uri6, bs.DEFAULT_INDEX, "");
Assert.equal(bookmarksObserver._itemAddedParent, testRoot);
Assert.equal(bookmarksObserver._itemAddedIndex, 3);
// change item
bs.setItemTitle(newId6, "Google Sites");
Assert.equal(bookmarksObserver._itemChangedProperty, "title");
- // move folder, appending, to different folder
- let oldParentCC = getChildCount(testRoot);
- bs.moveItem(workFolder, homeFolder, bs.DEFAULT_INDEX);
- Assert.equal(bookmarksObserver._itemMovedId, workFolder);
- Assert.equal(bookmarksObserver._itemMovedOldParent, testRoot);
- Assert.equal(bookmarksObserver._itemMovedOldIndex, 0);
- Assert.equal(bookmarksObserver._itemMovedNewParent, homeFolder);
- Assert.equal(bookmarksObserver._itemMovedNewIndex, 1);
-
- // test that the new index is properly stored
- Assert.equal(bs.getFolderIdForItem(workFolder), homeFolder);
-
- // XXX expose FolderCount, and check that the old parent has one less child?
- Assert.equal(getChildCount(testRoot), oldParentCC - 1);
-
- // move item, appending, to different folder
- bs.moveItem(newId5, testRoot, bs.DEFAULT_INDEX);
- Assert.equal(bookmarksObserver._itemMovedId, newId5);
- Assert.equal(bookmarksObserver._itemMovedOldParent, homeFolder);
- Assert.equal(bookmarksObserver._itemMovedOldIndex, 0);
- Assert.equal(bookmarksObserver._itemMovedNewParent, testRoot);
- Assert.equal(bookmarksObserver._itemMovedNewIndex, 3);
-
// test get folder's index
let tmpFolder = bs.createFolder(testRoot, "tmp", 2);
// test removeFolderChildren
// 1) add/remove each child type (bookmark, folder)
tmpFolder = bs.createFolder(testRoot, "removeFolderChildren",
bs.DEFAULT_INDEX);
bs.insertBookmark(tmpFolder, uri("http://foo9.com/"), bs.DEFAULT_INDEX, "");
--- a/toolkit/components/places/tests/legacy/test_protectRoots.js
+++ b/toolkit/components/places/tests/legacy/test_protectRoots.js
@@ -15,21 +15,16 @@ function run_test() {
Assert.ok(PlacesUtils.isRootItem(root));
try {
PlacesUtils.bookmarks.removeItem(root);
do_throw("Trying to remove a root should throw");
} catch (ex) {}
try {
- PlacesUtils.bookmarks.moveItem(root, PlacesUtils.placesRootId, 0);
- do_throw("Trying to move a root should throw");
- } catch (ex) {}
-
- try {
PlacesUtils.bookmarks.removeFolderChildren(root);
if (root == PlacesUtils.placesRootId)
do_throw("Trying to remove children of the main root should throw");
} catch (ex) {
if (root != PlacesUtils.placesRootId)
do_throw("Trying to remove children of other roots should not throw");
}
}
--- a/toolkit/components/places/tests/unit/test_sync_utils.js
+++ b/toolkit/components/places/tests/unit/test_sync_utils.js
@@ -1691,27 +1691,16 @@ add_task(async function test_move_orphan
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
});
let orphanGuids = await PlacesSyncUtils.bookmarks.fetchGuidsWithAnno(
SYNC_PARENT_ANNO, nonexistentRecordId);
deepEqual(orphanGuids, [tbBmk.recordId],
"Should remove orphan annos from updated bookmark");
}
- info("Move synced orphan using sync API");
- {
- let tbId = await recordIdToId(tbBmk.recordId);
- PlacesUtils.bookmarks.moveItem(tbId, PlacesUtils.toolbarFolderId,
- PlacesUtils.bookmarks.DEFAULT_INDEX);
- let orphanGuids = await PlacesSyncUtils.bookmarks.fetchGuidsWithAnno(
- SYNC_PARENT_ANNO, nonexistentRecordId);
- deepEqual(orphanGuids, [],
- "Should remove orphan annos from moved bookmark");
- }
-
await PlacesUtils.bookmarks.eraseEverything();
await PlacesSyncUtils.bookmarks.reset();
});
add_task(async function test_reorder_orphans() {
let nonexistentRecordId = makeGuid();
let fxBmk = await PlacesSyncUtils.bookmarks.insert({
kind: "bookmark",
@@ -1803,19 +1792,22 @@ add_task(async function test_unsynced_or
syncStatus: PlacesUtils.bookmarks.SYNC_STATUS.NEW,
}, {
guid: unknownBmk.recordId,
syncStatus: PlacesUtils.bookmarks.SYNC_STATUS.UNKNOWN,
});
info("Move unsynced orphan");
{
- let unknownId = await recordIdToId(unknownBmk.recordId);
- PlacesUtils.bookmarks.moveItem(unknownId, PlacesUtils.toolbarFolderId,
- PlacesUtils.bookmarks.DEFAULT_INDEX);
+ let unknownGuid = await PlacesSyncUtils.bookmarks.recordIdToGuid(unknownBmk.recordId);
+ await PlacesUtils.bookmarks.update({
+ guid: unknownGuid,
+ parentGuid: PlacesUtils.bookmarks.toolbarGuid,
+ index: PlacesUtils.bookmarks.DEFAULT_INDEX
+ });
let orphanGuids = await PlacesSyncUtils.bookmarks.fetchGuidsWithAnno(
SYNC_PARENT_ANNO, nonexistentRecordId);
deepEqual(orphanGuids.sort(), [newBmk.recordId].sort(),
"Should remove orphan annos from moved unsynced bookmark");
}
info("Reorder unsynced orphans");
{
@@ -2585,31 +2577,40 @@ add_task(async function test_separator()
recordId: separatorRecordId
});
await PlacesSyncUtils.bookmarks.insert({
kind: "bookmark",
parentRecordId: "menu",
recordId: makeGuid(),
url: "https://bar.foo",
});
- let child2Id = await recordIdToId(childBmk.recordId);
- let parentId = await recordIdToId("menu");
- let separatorId = await recordIdToId(separator.recordId);
+
+ let child2Guid = await PlacesSyncUtils.bookmarks.recordIdToGuid(childBmk.recordId);
+ let parentGuid = await await PlacesSyncUtils.bookmarks.recordIdToGuid("menu");
let separatorGuid = PlacesSyncUtils.bookmarks.recordIdToGuid(separatorRecordId);
info("Move a bookmark around the separator");
- PlacesUtils.bookmarks.moveItem(child2Id, parentId, separator + 1);
+ await PlacesUtils.bookmarks.update({
+ guid: child2Guid,
+ parentGuid,
+ index: 2
+ });
let changes = await PlacesSyncUtils.bookmarks.pullChanges();
deepEqual(Object.keys(changes).sort(),
[separator.recordId, "menu"].sort());
await setChangesSynced(changes);
info("Move a separator around directly");
- PlacesUtils.bookmarks.moveItem(separatorId, parentId, 0);
+ await PlacesUtils.bookmarks.update({
+ guid: separatorGuid,
+ parentGuid,
+ index: 0
+ });
+
changes = await PlacesSyncUtils.bookmarks.pullChanges();
deepEqual(Object.keys(changes).sort(),
[separator.recordId, "menu"].sort());
await setChangesSynced(changes);
info("Move a separator around directly using update");
await PlacesUtils.bookmarks.update({ guid: separatorGuid, index: 2 });