зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1486808 - Remove nsINavBookmarksService::unfiledBookmarksFolder and PlacesUtils.unfiledBookmarksFolderId. r=mak
Differential Revision: https://phabricator.services.mozilla.com/D4456 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
0763373b0b
Коммит
23c68929d3
|
@ -65,7 +65,6 @@ async function run_drag_test(startBookmarkIndex, newParentGuid) {
|
|||
let bookmarkWithId = JSON.stringify(Object.assign({
|
||||
id: bookmarkId,
|
||||
itemGuid: dragBookmark.guid,
|
||||
parent: PlacesUtils.unfiledBookmarksFolderId,
|
||||
uri: dragBookmark.url,
|
||||
}, dragBookmark));
|
||||
|
||||
|
|
|
@ -455,7 +455,7 @@ var PlacesDBUtils = {
|
|||
// D.4 move orphan items to unsorted folder
|
||||
{ query:
|
||||
`UPDATE moz_bookmarks SET
|
||||
parent = :unsorted_folder
|
||||
parent = (SELECT id FROM moz_bookmarks WHERE guid = :unfiledGuid)
|
||||
WHERE guid NOT IN (
|
||||
:rootGuid, :menuGuid, :toolbarGuid, :unfiledGuid, :tagsGuid /* skip roots */
|
||||
) AND id IN (
|
||||
|
@ -464,7 +464,6 @@ var PlacesDBUtils = {
|
|||
(SELECT id FROM moz_bookmarks WHERE id = b.parent LIMIT 1)
|
||||
)`,
|
||||
params: {
|
||||
unsorted_folder: PlacesUtils.unfiledBookmarksFolderId,
|
||||
rootGuid: PlacesUtils.bookmarks.rootGuid,
|
||||
menuGuid: PlacesUtils.bookmarks.menuGuid,
|
||||
toolbarGuid: PlacesUtils.bookmarks.toolbarGuid,
|
||||
|
@ -530,7 +529,7 @@ var PlacesDBUtils = {
|
|||
// as parent, if they have bad parent move them to unsorted bookmarks.
|
||||
{ query:
|
||||
`UPDATE moz_bookmarks SET
|
||||
parent = :unsorted_folder
|
||||
parent = (SELECT id FROM moz_bookmarks WHERE guid = :unfiledGuid)
|
||||
WHERE guid NOT IN (
|
||||
:rootGuid, :menuGuid, :toolbarGuid, :unfiledGuid, :tagsGuid /* skip roots */
|
||||
) AND id IN (
|
||||
|
@ -541,7 +540,6 @@ var PlacesDBUtils = {
|
|||
LIMIT 1)
|
||||
)`,
|
||||
params: {
|
||||
unsorted_folder: PlacesUtils.unfiledBookmarksFolderId,
|
||||
bookmark_type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
separator_type: PlacesUtils.bookmarks.TYPE_SEPARATOR,
|
||||
rootGuid: PlacesUtils.bookmarks.rootGuid,
|
||||
|
|
|
@ -1278,11 +1278,6 @@ var PlacesUtils = {
|
|||
return this.tagsFolderId = this.bookmarks.tagsFolder;
|
||||
},
|
||||
|
||||
get unfiledBookmarksFolderId() {
|
||||
delete this.unfiledBookmarksFolderId;
|
||||
return this.unfiledBookmarksFolderId = this.bookmarks.unfiledBookmarksFolder;
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks if item is a root.
|
||||
*
|
||||
|
|
|
@ -286,11 +286,6 @@ interface nsINavBookmarksService : nsISupports
|
|||
*/
|
||||
readonly attribute long long tagsFolder;
|
||||
|
||||
/**
|
||||
* The item ID of the unfiled-bookmarks folder.
|
||||
*/
|
||||
readonly attribute long long unfiledBookmarksFolder;
|
||||
|
||||
/**
|
||||
* The item ID of the personal toolbar folder.
|
||||
*/
|
||||
|
|
|
@ -340,16 +340,6 @@ nsNavBookmarks::GetTagsFolder(int64_t* aRoot)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNavBookmarks::GetUnfiledBookmarksFolder(int64_t* aRoot)
|
||||
{
|
||||
int64_t id = mDB->GetUnfiledFolderId();
|
||||
NS_ENSURE_TRUE(id > 0, NS_ERROR_UNEXPECTED);
|
||||
*aRoot = id;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNavBookmarks::GetTotalSyncChanges(int64_t* aTotalSyncChanges)
|
||||
{
|
||||
|
|
|
@ -219,7 +219,7 @@ add_task(async function update_move_different_folder() {
|
|||
let folder = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid });
|
||||
let bmItemId = await PlacesUtils.promiseItemId(bm.guid);
|
||||
let bmOldParentId = PlacesUtils.unfiledBookmarksFolderId;
|
||||
let bmOldParentId = await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid);
|
||||
let bmOldIndex = bm.index;
|
||||
|
||||
let observer = expectNotifications();
|
||||
|
@ -512,14 +512,16 @@ add_task(async function reorder_notification() {
|
|||
sorted.map(bm => bm.guid));
|
||||
|
||||
let expectedNotifications = [];
|
||||
let unfiledBookmarksFolderId =
|
||||
await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid);
|
||||
for (let i = 0; i < sorted.length; ++i) {
|
||||
let child = sorted[i];
|
||||
let childId = await PlacesUtils.promiseItemId(child.guid);
|
||||
expectedNotifications.push({ name: "onItemMoved",
|
||||
arguments: [ childId,
|
||||
PlacesUtils.unfiledBookmarksFolderId,
|
||||
unfiledBookmarksFolderId,
|
||||
child.index,
|
||||
PlacesUtils.unfiledBookmarksFolderId,
|
||||
unfiledBookmarksFolderId,
|
||||
i,
|
||||
child.type,
|
||||
child.guid,
|
||||
|
|
|
@ -6,10 +6,12 @@ add_task(async function boookmarks_tree_cache() {
|
|||
// bookmarks methods - using, eg, PlacesUtils.bookmarks.insert() doesn't
|
||||
// demonstrate the problem as it indirectly arranges for the observers to
|
||||
// be added.
|
||||
let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
|
||||
uri("http://example.com"),
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
"A title");
|
||||
let id = PlacesUtils.bookmarks.insertBookmark(
|
||||
await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid),
|
||||
uri("http://example.com"),
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
"A title");
|
||||
|
||||
await PlacesUtils.promiseBookmarksTree();
|
||||
|
||||
PlacesUtils.bookmarks.removeItem(id);
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
// Tests that each nsINavBookmarksObserver method gets the correct input.
|
||||
|
||||
var gUnfiledFolderId;
|
||||
|
||||
var gBookmarksObserver = {
|
||||
expected: [],
|
||||
setup(expected) {
|
||||
|
@ -96,9 +98,11 @@ var gBookmarkSkipObserver = {
|
|||
};
|
||||
|
||||
|
||||
add_task(function setup() {
|
||||
add_task(async function setup() {
|
||||
PlacesUtils.bookmarks.addObserver(gBookmarksObserver);
|
||||
PlacesUtils.bookmarks.addObserver(gBookmarkSkipObserver);
|
||||
|
||||
gUnfiledFolderId = await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid);
|
||||
});
|
||||
|
||||
add_task(async function onItemAdded_bookmark() {
|
||||
|
@ -112,7 +116,7 @@ add_task(async function onItemAdded_bookmark() {
|
|||
{ name: "onItemAdded",
|
||||
args: [
|
||||
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
|
||||
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
|
||||
{ name: "parentId", check: v => v === gUnfiledFolderId },
|
||||
{ name: "index", check: v => v === 0 },
|
||||
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
|
||||
{ name: "uri", check: v => v instanceof Ci.nsIURI && v.equals(uri) },
|
||||
|
@ -140,7 +144,7 @@ add_task(async function onItemAdded_separator() {
|
|||
{ name: "onItemAdded",
|
||||
args: [
|
||||
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
|
||||
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
|
||||
{ name: "parentId", check: v => v === gUnfiledFolderId },
|
||||
{ name: "index", check: v => v === 1 },
|
||||
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_SEPARATOR },
|
||||
{ name: "uri", check: v => v === null },
|
||||
|
@ -168,7 +172,7 @@ add_task(async function onItemAdded_folder() {
|
|||
{ name: "onItemAdded",
|
||||
args: [
|
||||
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
|
||||
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
|
||||
{ name: "parentId", check: v => v === gUnfiledFolderId },
|
||||
{ name: "index", check: v => v === 2 },
|
||||
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_FOLDER },
|
||||
{ name: "uri", check: v => v === null },
|
||||
|
@ -206,7 +210,7 @@ add_task(async function onItemChanged_title_bookmark() {
|
|||
{ name: "newValue", check: v => v === title },
|
||||
{ name: "lastModified", check: v => typeof(v) == "number" && v > 0 },
|
||||
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
|
||||
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
|
||||
{ name: "parentId", check: v => v === gUnfiledFolderId },
|
||||
{ name: "guid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
|
||||
{ name: "parentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
|
||||
{ name: "oldValue", check: v => typeof(v) == "string" },
|
||||
|
@ -263,7 +267,7 @@ add_task(async function onItemChanged_tags_bookmark() {
|
|||
{ name: "newValue", check: v => v === "" },
|
||||
{ name: "lastModified", check: v => typeof(v) == "number" && v > 0 },
|
||||
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
|
||||
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
|
||||
{ name: "parentId", check: v => v === gUnfiledFolderId },
|
||||
{ name: "guid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
|
||||
{ name: "parentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
|
||||
{ name: "oldValue", check: v => typeof(v) == "string" },
|
||||
|
@ -299,7 +303,7 @@ add_task(async function onItemChanged_tags_bookmark() {
|
|||
{ name: "newValue", check: v => v === "" },
|
||||
{ name: "lastModified", check: v => typeof(v) == "number" && v > 0 },
|
||||
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
|
||||
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
|
||||
{ name: "parentId", check: v => v === gUnfiledFolderId },
|
||||
{ name: "guid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
|
||||
{ name: "parentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
|
||||
{ name: "oldValue", check: v => typeof(v) == "string" },
|
||||
|
@ -324,7 +328,7 @@ add_task(async function onItemMoved_bookmark() {
|
|||
{ name: "onItemMoved",
|
||||
args: [
|
||||
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
|
||||
{ name: "oldParentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
|
||||
{ name: "oldParentId", check: v => v === gUnfiledFolderId },
|
||||
{ name: "oldIndex", check: v => v === 0 },
|
||||
{ name: "newParentId", check: v => v === PlacesUtils.toolbarFolderId },
|
||||
{ name: "newIndex", check: v => v === 0 },
|
||||
|
@ -340,7 +344,7 @@ add_task(async function onItemMoved_bookmark() {
|
|||
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
|
||||
{ name: "oldParentId", check: v => v === PlacesUtils.toolbarFolderId },
|
||||
{ name: "oldIndex", check: v => v === 0 },
|
||||
{ name: "newParentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
|
||||
{ name: "newParentId", check: v => v === gUnfiledFolderId },
|
||||
{ name: "newIndex", check: v => v === 0 },
|
||||
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
|
||||
{ name: "guid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
|
||||
|
@ -381,7 +385,7 @@ add_task(async function onItemMoved_bookmark() {
|
|||
{ name: "time", check: v => typeof(v) == "number" && v > 0 },
|
||||
{ name: "transitionType", check: v => v === PlacesUtils.history.TRANSITION_TYPED },
|
||||
{ name: "uri", check: v => v instanceof Ci.nsIURI && v.equals(uri) },
|
||||
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
|
||||
{ name: "parentId", check: v => v === gUnfiledFolderId },
|
||||
{ name: "guid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
|
||||
{ name: "parentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
|
||||
] },
|
||||
|
@ -404,7 +408,7 @@ add_task(async function onItemRemoved_bookmark() {
|
|||
{ name: "onItemRemoved",
|
||||
args: [
|
||||
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
|
||||
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
|
||||
{ name: "parentId", check: v => v === gUnfiledFolderId },
|
||||
{ name: "index", check: v => v === 0 },
|
||||
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
|
||||
{ name: "uri", check: v => v instanceof Ci.nsIURI && v.equals(uri) },
|
||||
|
@ -482,7 +486,7 @@ add_task(async function onItemRemoved_folder_recursive() {
|
|||
{ name: "onItemAdded",
|
||||
args: [
|
||||
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
|
||||
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
|
||||
{ name: "parentId", check: v => v === gUnfiledFolderId },
|
||||
{ name: "index", check: v => v === 0 },
|
||||
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_FOLDER },
|
||||
{ name: "uri", check: v => v === null },
|
||||
|
|
|
@ -326,26 +326,6 @@ function visits_in_database(aURI) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that we don't have any bookmark
|
||||
*/
|
||||
function check_no_bookmarks() {
|
||||
let query = PlacesUtils.history.getNewQuery();
|
||||
let folders = [
|
||||
PlacesUtils.bookmarks.toolbarFolder,
|
||||
PlacesUtils.bookmarks.bookmarksMenuFolder,
|
||||
PlacesUtils.bookmarks.unfiledBookmarksFolder,
|
||||
];
|
||||
query.setFolders(folders, 3);
|
||||
let options = PlacesUtils.history.getNewQueryOptions();
|
||||
options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
|
||||
let root = PlacesUtils.history.executeQuery(query, options).root;
|
||||
root.containerOpen = true;
|
||||
if (root.childCount != 0)
|
||||
do_throw("Unable to remove all bookmarks");
|
||||
root.containerOpen = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows waiting for an observer notification once.
|
||||
*
|
||||
|
|
|
@ -83,7 +83,6 @@ add_task(async function test_bookmarks() {
|
|||
Assert.ok(bs.bookmarksMenuFolder > 0);
|
||||
Assert.ok(bs.tagsFolder > 0);
|
||||
Assert.ok(bs.toolbarFolder > 0);
|
||||
Assert.ok(bs.unfiledBookmarksFolder > 0);
|
||||
|
||||
// test getFolderIdForItem() with bogus item id will throw
|
||||
try {
|
||||
|
@ -101,7 +100,6 @@ add_task(async function test_bookmarks() {
|
|||
Assert.equal(bs.getFolderIdForItem(bs.bookmarksMenuFolder), bs.placesRoot);
|
||||
Assert.equal(bs.getFolderIdForItem(bs.tagsFolder), bs.placesRoot);
|
||||
Assert.equal(bs.getFolderIdForItem(bs.toolbarFolder), bs.placesRoot);
|
||||
Assert.equal(bs.getFolderIdForItem(bs.unfiledBookmarksFolder), bs.placesRoot);
|
||||
|
||||
// create a folder to hold all the tests
|
||||
// this makes the tests more tolerant of changes to default_places.html
|
||||
|
|
|
@ -18,7 +18,7 @@ var as = PlacesUtils.annotations;
|
|||
var fs = PlacesUtils.favicons;
|
||||
|
||||
var mDBConn = hs.DBConnection;
|
||||
|
||||
var gUnfiledFolderId;
|
||||
// ------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
|
||||
|
@ -87,7 +87,7 @@ function addBookmark(aPlaceId, aType, aParent, aKeywordId, aFolderType, aTitle,
|
|||
:guid, :sync_status, :change_counter)`);
|
||||
stmt.params.place_id = aPlaceId || null;
|
||||
stmt.params.type = aType || bs.TYPE_BOOKMARK;
|
||||
stmt.params.parent = aParent || bs.unfiledBookmarksFolder;
|
||||
stmt.params.parent = aParent || gUnfiledFolderId;
|
||||
stmt.params.keyword_id = aKeywordId || null;
|
||||
stmt.params.folder_type = aFolderType || null;
|
||||
stmt.params.title = typeof(aTitle) == "string" ? aTitle : null;
|
||||
|
@ -558,22 +558,22 @@ tests.push({
|
|||
// Check that bookmarks are now children of a real folder (unfiled)
|
||||
let expectedInfos = [{
|
||||
id: this._orphanBookmarkId,
|
||||
parent: bs.unfiledBookmarksFolder,
|
||||
parent: gUnfiledFolderId,
|
||||
syncChangeCounter: 1,
|
||||
}, {
|
||||
id: this._orphanSeparatorId,
|
||||
parent: bs.unfiledBookmarksFolder,
|
||||
parent: gUnfiledFolderId,
|
||||
syncChangeCounter: 1,
|
||||
}, {
|
||||
id: this._orphanFolderId,
|
||||
parent: bs.unfiledBookmarksFolder,
|
||||
parent: gUnfiledFolderId,
|
||||
syncChangeCounter: 1,
|
||||
}, {
|
||||
id: this._bookmarkId,
|
||||
parent: this._orphanFolderId,
|
||||
syncChangeCounter: 0,
|
||||
}, {
|
||||
id: bs.unfiledBookmarksFolder,
|
||||
id: gUnfiledFolderId,
|
||||
parent: bs.placesRoot,
|
||||
syncChangeCounter: 3,
|
||||
}];
|
||||
|
@ -692,14 +692,14 @@ tests.push({
|
|||
// Check that bookmarks are now children of a real folder (unfiled)
|
||||
let expectedInfos = [{
|
||||
id: this._bookmarkId1,
|
||||
parent: bs.unfiledBookmarksFolder,
|
||||
parent: gUnfiledFolderId,
|
||||
syncChangeCounter: 1,
|
||||
}, {
|
||||
id: this._bookmarkId2,
|
||||
parent: bs.unfiledBookmarksFolder,
|
||||
parent: gUnfiledFolderId,
|
||||
syncChangeCounter: 1,
|
||||
}, {
|
||||
id: bs.unfiledBookmarksFolder,
|
||||
id: gUnfiledFolderId,
|
||||
parent: bs.placesRoot,
|
||||
syncChangeCounter: 2,
|
||||
}];
|
||||
|
@ -749,7 +749,8 @@ tests.push({
|
|||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
});
|
||||
|
||||
function randomize_positions(aParent, aResultArray) {
|
||||
async function randomize_positions(aParent, aResultArray) {
|
||||
let parentId = await PlacesUtils.promiseItemId(aParent);
|
||||
let stmt = mDBConn.createStatement(
|
||||
`UPDATE moz_bookmarks SET position = :rand
|
||||
WHERE id IN (
|
||||
|
@ -758,7 +759,7 @@ tests.push({
|
|||
)`
|
||||
);
|
||||
for (let i = 0; i < (NUM_BOOKMARKS / 2); i++) {
|
||||
stmt.params.parent = aParent;
|
||||
stmt.params.parent = parentId;
|
||||
stmt.params.rand = Math.round(Math.random() * (NUM_BOOKMARKS - 1));
|
||||
stmt.execute();
|
||||
stmt.reset();
|
||||
|
@ -771,7 +772,7 @@ tests.push({
|
|||
FROM moz_bookmarks WHERE parent = :parent
|
||||
ORDER BY position ASC, ROWID ASC`
|
||||
);
|
||||
stmt.params.parent = aParent;
|
||||
stmt.params.parent = parentId;
|
||||
while (stmt.executeStep()) {
|
||||
aResultArray.push(stmt.row.id);
|
||||
print(stmt.row.id + "\t" + stmt.row.position + "\t" +
|
||||
|
@ -781,9 +782,10 @@ tests.push({
|
|||
}
|
||||
|
||||
// Set random positions for the added bookmarks.
|
||||
randomize_positions(PlacesUtils.unfiledBookmarksFolderId,
|
||||
this._unfiledBookmarks);
|
||||
randomize_positions(PlacesUtils.toolbarFolderId, this._toolbarBookmarks);
|
||||
await randomize_positions(PlacesUtils.bookmarks.unfiledGuid,
|
||||
this._unfiledBookmarks);
|
||||
await randomize_positions(PlacesUtils.bookmarks.toolbarGuid,
|
||||
this._toolbarBookmarks);
|
||||
|
||||
let syncInfos = await PlacesTestUtils.fetchBookmarkSyncFields(
|
||||
PlacesUtils.bookmarks.unfiledGuid, PlacesUtils.bookmarks.toolbarGuid);
|
||||
|
@ -794,12 +796,13 @@ tests.push({
|
|||
let db = await PlacesUtils.promiseDBConnection();
|
||||
|
||||
async function check_order(aParent, aResultArray) {
|
||||
let parentId = await PlacesUtils.promiseItemId(aParent);
|
||||
// Build the expected ordered list of bookmarks.
|
||||
let childRows = await db.executeCached(
|
||||
`SELECT id, position, syncChangeCounter FROM moz_bookmarks
|
||||
WHERE parent = :parent
|
||||
ORDER BY position ASC`,
|
||||
{ parent: aParent }
|
||||
{ parent: parentId }
|
||||
);
|
||||
for (let row of childRows) {
|
||||
let id = row.getResultByName("id");
|
||||
|
@ -813,15 +816,15 @@ tests.push({
|
|||
let parentRows = await db.executeCached(
|
||||
`SELECT syncChangeCounter FROM moz_bookmarks
|
||||
WHERE id = :parent`,
|
||||
{ parent: aParent });
|
||||
{ parent: parentId });
|
||||
for (let row of parentRows) {
|
||||
let actualChangeCounter = row.getResultByName("syncChangeCounter");
|
||||
Assert.ok(actualChangeCounter > 0);
|
||||
}
|
||||
}
|
||||
|
||||
await check_order(PlacesUtils.unfiledBookmarksFolderId, this._unfiledBookmarks);
|
||||
await check_order(PlacesUtils.toolbarFolderId, this._toolbarBookmarks);
|
||||
await check_order(PlacesUtils.bookmarks.unfiledGuid, this._unfiledBookmarks);
|
||||
await check_order(PlacesUtils.bookmarks.toolbarGuid, this._toolbarBookmarks);
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -1861,7 +1864,7 @@ tests.push({
|
|||
}, {
|
||||
guid: "bookmarkCCCC",
|
||||
placeId: null,
|
||||
parentId: bs.unfiledBookmarksFolder,
|
||||
parentId: gUnfiledFolderId,
|
||||
dateAdded: null,
|
||||
lastModified: null,
|
||||
}, {
|
||||
|
@ -1873,13 +1876,13 @@ tests.push({
|
|||
}, {
|
||||
guid: "bookmarkEEEE",
|
||||
placeId: placeIdWithVisits,
|
||||
parentId: bs.unfiledBookmarksFolder,
|
||||
parentId: gUnfiledFolderId,
|
||||
dateAdded: PlacesUtils.toPRTime(new Date(2017, 9, 3)),
|
||||
lastModified: PlacesUtils.toPRTime(new Date(2017, 9, 6)),
|
||||
}, {
|
||||
guid: "bookmarkFFFF",
|
||||
placeId: placeIdWithZeroVisit,
|
||||
parentId: bs.unfiledBookmarksFolder,
|
||||
parentId: gUnfiledFolderId,
|
||||
dateAdded: 0,
|
||||
lastModified: 0,
|
||||
});
|
||||
|
@ -1994,7 +1997,7 @@ tests.push({
|
|||
async setup() {
|
||||
this._bookmarksWithDates.push({
|
||||
guid: "bookmarkGGGG",
|
||||
parentId: bs.unfiledBookmarksFolder,
|
||||
parentId: gUnfiledFolderId,
|
||||
dateAdded: PlacesUtils.toPRTime(new Date(2017, 9, 6)),
|
||||
lastModified: PlacesUtils.toPRTime(new Date(2017, 9, 3)),
|
||||
});
|
||||
|
@ -2191,6 +2194,9 @@ tests.push({
|
|||
// ------------------------------------------------------------------------------
|
||||
|
||||
add_task(async function test_preventive_maintenance() {
|
||||
gUnfiledFolderId =
|
||||
await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid);
|
||||
|
||||
// Get current bookmarks max ID for cleanup
|
||||
let stmt = mDBConn.createStatement("SELECT MAX(id) FROM moz_bookmarks");
|
||||
stmt.executeStep();
|
||||
|
@ -2219,6 +2225,6 @@ add_task(async function test_preventive_maintenance() {
|
|||
Assert.equal(bs.getFolderIdForItem(bs.placesRoot), 0);
|
||||
Assert.equal(bs.getFolderIdForItem(bs.bookmarksMenuFolder), bs.placesRoot);
|
||||
Assert.equal(bs.getFolderIdForItem(bs.tagsFolder), bs.placesRoot);
|
||||
Assert.equal(bs.getFolderIdForItem(bs.unfiledBookmarksFolder), bs.placesRoot);
|
||||
Assert.equal(bs.getFolderIdForItem(gUnfiledFolderId), bs.placesRoot);
|
||||
Assert.equal(bs.getFolderIdForItem(bs.toolbarFolder), bs.placesRoot);
|
||||
});
|
||||
|
|
|
@ -7,6 +7,9 @@ add_task(async function test_livemarks() {
|
|||
try {
|
||||
let buf = await openMirror("livemarks");
|
||||
|
||||
let unfiledFolderId =
|
||||
await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid);
|
||||
|
||||
info("Set up mirror");
|
||||
await PlacesUtils.bookmarks.insertTree({
|
||||
guid: PlacesUtils.bookmarks.menuGuid,
|
||||
|
@ -264,7 +267,7 @@ add_task(async function test_livemarks() {
|
|||
}, {
|
||||
name: "onItemAdded",
|
||||
params: { itemId: livemarkE.id,
|
||||
parentId: PlacesUtils.unfiledBookmarksFolderId,
|
||||
parentId: unfiledFolderId,
|
||||
index: 0, type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
urlHref: null, title: "E", guid: "livemarkEEEE",
|
||||
parentGuid: "unfiled_____",
|
||||
|
@ -344,7 +347,7 @@ add_task(async function test_livemarks() {
|
|||
params: { itemId: livemarkE.id, property: PlacesUtils.LMANNO_FEEDURI,
|
||||
isAnnoProperty: true, newValue: "",
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
parentId: PlacesUtils.unfiledBookmarksFolderId,
|
||||
parentId: unfiledFolderId,
|
||||
guid: "livemarkEEEE",
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
oldValue: "",
|
||||
|
@ -354,7 +357,7 @@ add_task(async function test_livemarks() {
|
|||
params: { itemId: livemarkE.id, property: PlacesUtils.LMANNO_SITEURI,
|
||||
isAnnoProperty: true, newValue: "",
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
parentId: PlacesUtils.unfiledBookmarksFolderId,
|
||||
parentId: unfiledFolderId,
|
||||
guid: "livemarkEEEE",
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
oldValue: "",
|
||||
|
|
|
@ -297,7 +297,8 @@ add_task(async function test_move() {
|
|||
name: "onItemMoved",
|
||||
params: { itemId: localItemIds.get("mozFolder___"),
|
||||
oldParentId: localItemIds.get("devFolder___"),
|
||||
oldIndex: 1, newParentId: PlacesUtils.unfiledBookmarksFolderId,
|
||||
oldIndex: 1,
|
||||
newParentId: await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid),
|
||||
newIndex: 0, type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
guid: "mozFolder___",
|
||||
oldParentGuid: "devFolder___",
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
let unfiledFolderId;
|
||||
|
||||
add_task(async function setup() {
|
||||
unfiledFolderId =
|
||||
await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid);
|
||||
});
|
||||
|
||||
add_task(async function test_value_combo() {
|
||||
let buf = await openMirror("value_combo");
|
||||
|
||||
|
@ -689,7 +696,7 @@ add_task(async function test_keywords_complex() {
|
|||
}, {
|
||||
name: "onItemAdded",
|
||||
params: { itemId: localItemIds.get("bookmarkBBB1"),
|
||||
parentId: PlacesUtils.unfiledBookmarksFolderId, index: 0,
|
||||
parentId: unfiledFolderId, index: 0,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
urlHref: "http://example.com/b", title: "B",
|
||||
guid: "bookmarkBBB1",
|
||||
|
@ -1261,7 +1268,7 @@ add_task(async function test_duplicate_url_rows() {
|
|||
params: { itemId: localItemIds.get("bookmarkCCCC"), property: "title",
|
||||
isAnnoProperty: false, newValue: "C (remote)",
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
parentId: PlacesUtils.unfiledBookmarksFolderId,
|
||||
parentId: unfiledFolderId,
|
||||
guid: "bookmarkCCCC",
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid, oldValue: "C",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
|
|
|
@ -6,8 +6,13 @@
|
|||
const FEED_URI = NetUtil.newURI("http://feed.rss/");
|
||||
const SITE_URI = NetUtil.newURI("http://site.org/");
|
||||
|
||||
let unfiledFolderId;
|
||||
|
||||
// This test must be the first one, since it's testing the cache.
|
||||
add_task(async function test_livemark_cache() {
|
||||
unfiledFolderId =
|
||||
await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid);
|
||||
|
||||
// Add a livemark through other APIs.
|
||||
let folder = await PlacesUtils.bookmarks.insert({
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
|
@ -31,7 +36,7 @@ add_task(async function test_livemark_cache() {
|
|||
Assert.equal(folder.index, livemark.index);
|
||||
Assert.equal(folder.title, livemark.title);
|
||||
Assert.equal(id, livemark.id);
|
||||
Assert.equal(PlacesUtils.unfiledBookmarksFolderId, livemark.parentId);
|
||||
Assert.equal(unfiledFolderId, livemark.parentId);
|
||||
Assert.equal("http://example.com/feed", livemark.feedURI.spec);
|
||||
Assert.equal("http://example.com/site", livemark.siteURI.spec);
|
||||
|
||||
|
@ -77,7 +82,7 @@ add_task(async function test_addLivemark_invalidParentId_throws() {
|
|||
add_task(async function test_addLivemark_noIndex_throws() {
|
||||
try {
|
||||
await PlacesUtils.livemarks.addLivemark({
|
||||
parentId: PlacesUtils.unfiledBookmarksFolderId });
|
||||
parentId: unfiledFolderId });
|
||||
do_throw("Invoking addLivemark with no index should throw");
|
||||
} catch (ex) {
|
||||
Assert.equal(ex.result, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
@ -87,7 +92,7 @@ add_task(async function test_addLivemark_noIndex_throws() {
|
|||
add_task(async function test_addLivemark_badIndex_throws() {
|
||||
try {
|
||||
await PlacesUtils.livemarks.addLivemark(
|
||||
{ parentId: PlacesUtils.unfiledBookmarksFolderId,
|
||||
{ parentId: unfiledFolderId,
|
||||
index: "test" });
|
||||
do_throw("Invoking addLivemark with a bad index should throw");
|
||||
} catch (ex) {
|
||||
|
@ -98,7 +103,7 @@ add_task(async function test_addLivemark_badIndex_throws() {
|
|||
add_task(async function test_addLivemark_invalidIndex_throws() {
|
||||
try {
|
||||
await PlacesUtils.livemarks.addLivemark(
|
||||
{ parentId: PlacesUtils.unfiledBookmarksFolderId,
|
||||
{ parentId: unfiledFolderId,
|
||||
index: -2,
|
||||
});
|
||||
do_throw("Invoking addLivemark with an invalid index should throw");
|
||||
|
@ -160,7 +165,7 @@ add_task(async function test_addLivemark_parentId_succeeds() {
|
|||
aURI, aTitle) {
|
||||
onItemAddedCalled = true;
|
||||
PlacesUtils.bookmarks.removeObserver(this);
|
||||
Assert.equal(aParentId, PlacesUtils.unfiledBookmarksFolderId);
|
||||
Assert.equal(aParentId, unfiledFolderId);
|
||||
Assert.equal(aIndex, 0);
|
||||
Assert.equal(aItemType, Ci.nsINavBookmarksService.TYPE_FOLDER);
|
||||
Assert.equal(aTitle, "test");
|
||||
|
@ -169,7 +174,7 @@ add_task(async function test_addLivemark_parentId_succeeds() {
|
|||
|
||||
await PlacesUtils.livemarks.addLivemark(
|
||||
{ title: "test",
|
||||
parentId: PlacesUtils.unfiledBookmarksFolderId,
|
||||
parentId: unfiledFolderId,
|
||||
feedURI: FEED_URI });
|
||||
Assert.ok(onItemAddedCalled);
|
||||
});
|
||||
|
@ -184,7 +189,7 @@ add_task(async function test_addLivemark_noSiteURI_succeeds() {
|
|||
Assert.ok(livemark.id > 0);
|
||||
do_check_valid_places_guid(livemark.guid);
|
||||
Assert.equal(livemark.title, "test");
|
||||
Assert.equal(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
|
||||
Assert.equal(livemark.parentId, unfiledFolderId);
|
||||
Assert.equal(livemark.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
|
||||
Assert.ok(livemark.feedURI.equals(FEED_URI));
|
||||
Assert.equal(livemark.siteURI, null);
|
||||
|
@ -207,7 +212,7 @@ add_task(async function test_addLivemark_succeeds() {
|
|||
Assert.ok(livemark.id > 0);
|
||||
do_check_valid_places_guid(livemark.guid);
|
||||
Assert.equal(livemark.title, "test");
|
||||
Assert.equal(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
|
||||
Assert.equal(livemark.parentId, unfiledFolderId);
|
||||
Assert.equal(livemark.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
|
||||
Assert.ok(livemark.feedURI.equals(FEED_URI));
|
||||
Assert.ok(livemark.siteURI.equals(SITE_URI));
|
||||
|
@ -405,7 +410,7 @@ add_task(async function test_getLivemark_guid_succeeds() {
|
|||
await PlacesUtils.livemarks.getLivemark({ id: 789, guid: "34567890ABCD" });
|
||||
|
||||
Assert.equal(livemark.title, "test");
|
||||
Assert.equal(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
|
||||
Assert.equal(livemark.parentId, unfiledFolderId);
|
||||
Assert.equal(livemark.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
|
||||
Assert.ok(livemark.feedURI.equals(FEED_URI));
|
||||
Assert.equal(livemark.siteURI, null);
|
||||
|
@ -425,7 +430,7 @@ add_task(async function test_getLivemark_id_succeeds() {
|
|||
livemark = await PlacesUtils.livemarks.getLivemark({ id: livemark.id });
|
||||
|
||||
Assert.equal(livemark.title, "test");
|
||||
Assert.equal(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
|
||||
Assert.equal(livemark.parentId, unfiledFolderId);
|
||||
Assert.equal(livemark.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
|
||||
Assert.ok(livemark.feedURI.equals(FEED_URI));
|
||||
Assert.equal(livemark.siteURI, null);
|
||||
|
@ -451,7 +456,7 @@ add_task(async function test_getLivemark_removeItem_contention() {
|
|||
livemark = await PlacesUtils.livemarks.getLivemark({ guid: livemark.guid });
|
||||
|
||||
Assert.equal(livemark.title, "test");
|
||||
Assert.equal(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
|
||||
Assert.equal(livemark.parentId, unfiledFolderId);
|
||||
Assert.ok(livemark.feedURI.equals(FEED_URI));
|
||||
Assert.equal(livemark.siteURI, null);
|
||||
do_check_guid_for_bookmark(livemark.id, livemark.guid);
|
||||
|
|
Загрузка…
Ссылка в новой задаче