Bug 1432614 - Remove now unnecessary updating and maintenance of Places' root folder titles. r=kitcambridge,mak

The titles for the root bookmark folders in the database will now never get updated. This
avoids doing maintenance and changing them if the locale changes.

The UI is now responsible for displaying the correct title.

WebExtensions API will get the UI visible names.

MozReview-Commit-ID: ErPPJXxy2d3

--HG--
extra : rebase_source : f08caa5b0d00ae81ffabf4a1076bd56b66414418
This commit is contained in:
Mark Banner 2018-01-04 16:35:56 +00:00
parent 9846046d93
commit d6729b8d28
22 changed files with 159 additions and 274 deletions

View File

@ -47,7 +47,7 @@ const getTree = (rootGuid, onlyChildren) => {
function convert(node, parent) {
let treenode = {
id: node.guid,
title: node.title || "",
title: PlacesUtils.bookmarks.getLocalizedTitle(node) || "",
index: node.index,
dateAdded: node.dateAdded / 1000,
type: BOOKMARKS_TYPES_TO_API_TYPES_MAP.get(node.typeCode),
@ -91,7 +91,7 @@ const getTree = (rootGuid, onlyChildren) => {
const convertBookmarks = result => {
let node = {
id: result.guid,
title: result.title || "",
title: PlacesUtils.bookmarks.getLocalizedTitle(result) || "",
index: result.index,
dateAdded: result.dateAdded.getTime(),
type: BOOKMARKS_TYPES_TO_API_TYPES_MAP.get(result.type),

View File

@ -435,7 +435,10 @@ var gEditItemOverlay = {
var lastUsed =
PlacesUtils.annotations.getItemAnnotation(folderId, LAST_USED_ANNO);
let guid = await PlacesUtils.promiseItemGuid(folderId);
let title = (await PlacesUtils.bookmarks.fetch(guid)).title;
let bm = await PlacesUtils.bookmarks.fetch(guid);
// Since this could be a root mobile folder, we should get the proper
// title.
let title = PlacesUtils.bookmarks.getLocalizedTitle(bm);
this._recentFolders.push({ folderId, guid, title, lastUsed });
}
this._recentFolders.sort(function(a, b) {

View File

@ -23,12 +23,8 @@ add_task(async function() {
// Check that name picker is read only
let namepicker = dialogWin.document.getElementById("editBMPanel_namePicker");
Assert.ok(namepicker.readOnly, "Name field is read-only");
let bookmark = await PlacesUtils.bookmarks.fetch(PlacesUtils.bookmarks.unfiledGuid);
Assert.equal(namepicker.value, bookmark.title, "Node title is correct");
// Blur the field and ensure root's name has not been changed.
namepicker.blur();
bookmark = await PlacesUtils.bookmarks.fetch(PlacesUtils.bookmarks.unfiledGuid);
Assert.equal(namepicker.value, bookmark.title, "Root title is correct");
Assert.equal(namepicker.value,
PlacesUtils.getString("OtherBookmarksFolderTitle"), "Node title is correct");
}
);
});

View File

@ -18,8 +18,6 @@ function onLibraryReady(organizer) {
// Check titles have been fixed.
for (var i = 0; i < leftPaneQueries.length; i++) {
var query = leftPaneQueries[i];
is(PlacesUtils.bookmarks.getItemTitle(query.itemId),
query.correctTitle, "Title is correct for query " + query.name);
if ("concreteId" in query) {
is(PlacesUtils.bookmarks.getItemTitle(query.concreteId),
query.concreteTitle, "Concrete title is correct for query " + query.name);

View File

@ -8,6 +8,7 @@ ChromeUtils.import("resource://services-sync/service.js");
ChromeUtils.import("resource://services-sync/util.js");
ChromeUtils.import("resource://services-sync/bookmark_validator.js");
const BookmarksToolbarTitle = "toolbar";
const bms = PlacesUtils.bookmarks;
add_task(async function setup() {
@ -631,7 +632,7 @@ add_task(async function test_dupe_empty_folder() {
id: newFolderGUID,
type: "folder",
title: "Folder 1",
parentName: "Bookmarks Toolbar",
parentName: BookmarksToolbarTitle,
parentid: "toolbar",
children: [],
}), Date.now() / 1000 + 500);

View File

@ -7,6 +7,8 @@ ChromeUtils.import("resource://services-sync/engines/bookmarks.js");
ChromeUtils.import("resource://services-sync/service.js");
ChromeUtils.import("resource://services-sync/util.js");
const BookmarksToolbarTitle = "toolbar";
add_task(async function test_ignore_specials() {
_("Ensure that we can't delete bookmark roots.");
@ -60,7 +62,7 @@ add_task(async function test_bookmark_create() {
fxrecord.tags = ["firefox", "awesome", "browser"];
fxrecord.keyword = "awesome";
fxrecord.loadInSidebar = false;
fxrecord.parentName = "Bookmarks Toolbar";
fxrecord.parentName = BookmarksToolbarTitle;
fxrecord.parentid = "toolbar";
await store.applyIncoming(fxrecord);
@ -93,7 +95,7 @@ add_task(async function test_bookmark_create() {
_("Create a record with some values missing.");
let tbrecord = new Bookmark("bookmarks", "thunderbird1");
tbrecord.bmkUri = "http://getthunderbird.com/";
tbrecord.parentName = "Bookmarks Toolbar";
tbrecord.parentName = BookmarksToolbarTitle;
tbrecord.parentid = "toolbar";
await store.applyIncoming(tbrecord);
@ -195,7 +197,7 @@ add_task(async function test_folder_create() {
try {
_("Create a folder.");
let folder = new BookmarkFolder("bookmarks", "testfolder-1");
folder.parentName = "Bookmarks Toolbar";
folder.parentName = BookmarksToolbarTitle;
folder.parentid = "toolbar";
folder.title = "Test Folder";
await store.applyIncoming(folder);
@ -251,7 +253,7 @@ add_task(async function test_folder_createRecord() {
Assert.ok(record instanceof BookmarkFolder);
Assert.equal(record.title, "Folder1");
Assert.equal(record.parentid, "toolbar");
Assert.equal(record.parentName, "Bookmarks Toolbar");
Assert.equal(record.parentName, BookmarksToolbarTitle);
_("Verify the folder's children. Ensures that the bookmarks were given GUIDs.");
Assert.deepEqual(record.children, [bmk1.guid, bmk2.guid]);
@ -487,7 +489,7 @@ add_task(async function test_delete_buffering() {
try {
_("Create a folder with two bookmarks.");
let folder = new BookmarkFolder("bookmarks", "testfolder-1");
folder.parentName = "Bookmarks Toolbar";
folder.parentName = BookmarksToolbarTitle;
folder.parentid = "toolbar";
folder.title = "Test Folder";
await store.applyIncoming(folder);

View File

@ -920,8 +920,12 @@ function BookmarkExporter(aBookmarksTree) {
// Create a map of the roots.
let rootsMap = new Map();
for (let child of aBookmarksTree.children) {
if (child.root)
if (child.root) {
rootsMap.set(child.root, child);
// Also take the opportunity to get the correctly localised title for the
// root.
child.title = PlacesUtils.bookmarks.getLocalizedTitle(child);
}
}
// For backwards compatibility reasons the bookmarks menu is the root, while

View File

@ -172,6 +172,38 @@ var Bookmarks = Object.freeze({
guid == PlacesUtils.bookmarks.virtualUnfiledGuid;
},
/**
* Returns the title to use on the UI for a bookmark item. Root folders
* in the database don't store fully localised versions of the title. To
* get those this function should be called.
*
* Hence, this function should only be called if a root folder object is
* likely to be displayed to the user.
*
* @param {Object} info An object representing a bookmark-item.
* @returns {String} The correct string.
* @throws {Error} If the guid in PlacesUtils.bookmarks.userContentRoots is
* not supported.
*/
getLocalizedTitle(info) {
if (!PlacesUtils.bookmarks.userContentRoots.includes(info.guid)) {
return info.title;
}
switch (info.guid) {
case PlacesUtils.bookmarks.toolbarGuid:
return PlacesUtils.getString("BookmarksToolbarFolderTitle");
case PlacesUtils.bookmarks.menuGuid:
return PlacesUtils.getString("BookmarksMenuFolderTitle");
case PlacesUtils.bookmarks.unfiledGuid:
return PlacesUtils.getString("OtherBookmarksFolderTitle");
case PlacesUtils.bookmarks.mobileGuid:
return PlacesUtils.getString("MobileBookmarksFolderTitle");
default:
throw new Error(`Unsupported guid ${info.guid} passed to getLocalizedTitle!`);
}
},
/**
* Inserts a bookmark-item into the bookmarks tree.
*

View File

@ -226,7 +226,7 @@ SetJournalMode(nsCOMPtr<mozIStorageConnection>& aDBConn,
nsresult
CreateRoot(nsCOMPtr<mozIStorageConnection>& aDBConn,
const nsCString& aRootName, const nsCString& aGuid,
const nsAString& titleString)
const nsCString& titleString)
{
MOZ_ASSERT(NS_IsMainThread());
@ -258,7 +258,7 @@ CreateRoot(nsCOMPtr<mozIStorageConnection>& aDBConn,
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("item_position"), itemPosition);
if (NS_FAILED(rv)) return rv;
rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("item_title"),
NS_ConvertUTF16toUTF8(titleString));
titleString);
if (NS_FAILED(rv)) return rv;
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("date_added"), timestamp);
if (NS_FAILED(rv)) return rv;
@ -1227,11 +1227,6 @@ Database::InitSchema(bool* aDatabaseMigrated)
// CONNECTION AND CAUSE FURTHER STEPS TO FAIL.
// In case, set a bool and do the async work in the ScopeExit guard just
// before the migration steps.
rv = UpdateBookmarkRootTitles();
// We don't want a broken localization to cause us to think
// the database is corrupt and needs to be replaced.
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
}
else {
@ -1334,42 +1329,29 @@ Database::CreateBookmarkRoots()
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIStringBundleService> bundleService =
services::GetStringBundleService();
NS_ENSURE_STATE(bundleService);
nsCOMPtr<nsIStringBundle> bundle;
nsresult rv = bundleService->CreateBundle(PLACES_BUNDLE, getter_AddRefs(bundle));
if (NS_FAILED(rv)) return rv;
nsAutoString rootTitle;
// The first root's title is an empty string.
rv = CreateRoot(mMainConn, NS_LITERAL_CSTRING("places"),
NS_LITERAL_CSTRING("root________"), rootTitle);
nsresult rv = CreateRoot(mMainConn, NS_LITERAL_CSTRING("places"),
NS_LITERAL_CSTRING("root________"), EmptyCString());
if (NS_FAILED(rv)) return rv;
// Fetch the internationalized folder name from the string bundle.
rv = bundle->GetStringFromName("BookmarksMenuFolderTitle", rootTitle);
if (NS_FAILED(rv)) return rv;
// For the other roots, the UI doesn't rely on the value in the database, so
// just set it to something simple to make it easier for humans to read.
rv = CreateRoot(mMainConn, NS_LITERAL_CSTRING("menu"),
NS_LITERAL_CSTRING("menu________"), rootTitle);
NS_LITERAL_CSTRING("menu________"), NS_LITERAL_CSTRING("menu"));
if (NS_FAILED(rv)) return rv;
rv = bundle->GetStringFromName("BookmarksToolbarFolderTitle", rootTitle);
if (NS_FAILED(rv)) return rv;
rv = CreateRoot(mMainConn, NS_LITERAL_CSTRING("toolbar"),
NS_LITERAL_CSTRING("toolbar_____"), rootTitle);
NS_LITERAL_CSTRING("toolbar_____"), NS_LITERAL_CSTRING("toolbar"));
if (NS_FAILED(rv)) return rv;
rv = bundle->GetStringFromName("TagsFolderTitle", rootTitle);
if (NS_FAILED(rv)) return rv;
rv = CreateRoot(mMainConn, NS_LITERAL_CSTRING("tags"),
NS_LITERAL_CSTRING("tags________"), rootTitle);
NS_LITERAL_CSTRING("tags________"), NS_LITERAL_CSTRING("tags"));
if (NS_FAILED(rv)) return rv;
rv = bundle->GetStringFromName("OtherBookmarksFolderTitle", rootTitle);
if (NS_FAILED(rv)) return rv;
rv = CreateRoot(mMainConn, NS_LITERAL_CSTRING("unfiled"),
NS_LITERAL_CSTRING("unfiled_____"), rootTitle);
NS_LITERAL_CSTRING("unfiled_____"), NS_LITERAL_CSTRING("unfiled"));
if (NS_FAILED(rv)) return rv;
int64_t mobileRootId = CreateMobileRoot();
@ -1487,69 +1469,6 @@ Database::InitTempEntities()
return NS_OK;
}
nsresult
Database::UpdateBookmarkRootTitles()
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIStringBundleService> bundleService =
services::GetStringBundleService();
NS_ENSURE_STATE(bundleService);
nsCOMPtr<nsIStringBundle> bundle;
nsresult rv = bundleService->CreateBundle(PLACES_BUNDLE, getter_AddRefs(bundle));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<mozIStorageAsyncStatement> stmt;
rv = mMainConn->CreateAsyncStatement(NS_LITERAL_CSTRING(
"UPDATE moz_bookmarks SET title = :new_title WHERE guid = :guid"
), getter_AddRefs(stmt));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<mozIStorageBindingParamsArray> paramsArray;
rv = stmt->NewBindingParamsArray(getter_AddRefs(paramsArray));
if (NS_FAILED(rv)) return rv;
const char *rootGuids[] = { "menu________"
, "toolbar_____"
, "tags________"
, "unfiled_____"
, "mobile______"
};
const char *titleStringIDs[] = { "BookmarksMenuFolderTitle"
, "BookmarksToolbarFolderTitle"
, "TagsFolderTitle"
, "OtherBookmarksFolderTitle"
, "MobileBookmarksFolderTitle"
};
for (uint32_t i = 0; i < ArrayLength(rootGuids); ++i) {
nsAutoString title;
rv = bundle->GetStringFromName(titleStringIDs[i], title);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<mozIStorageBindingParams> params;
rv = paramsArray->NewBindingParams(getter_AddRefs(params));
if (NS_FAILED(rv)) return rv;
rv = params->BindUTF8StringByName(NS_LITERAL_CSTRING("guid"),
nsDependentCString(rootGuids[i]));
if (NS_FAILED(rv)) return rv;
rv = params->BindUTF8StringByName(NS_LITERAL_CSTRING("new_title"),
NS_ConvertUTF16toUTF8(title));
if (NS_FAILED(rv)) return rv;
rv = paramsArray->AddParams(params);
if (NS_FAILED(rv)) return rv;
}
rv = stmt->BindParameters(paramsArray);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<mozIStoragePendingStatement> pendingStmt;
rv = stmt->ExecuteAsync(nullptr, getter_AddRefs(pendingStmt));
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
nsresult
Database::MigrateV31Up() {
nsresult rv = mMainConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(

View File

@ -227,8 +227,6 @@ this.PlacesDBUtils = {
},
async _getCoherenceStatements() {
let updateRootTitleSql = `UPDATE moz_bookmarks SET title = :title
WHERE id = :root_id AND title <> :title`;
let cleanupStatements = [
// MOZ_ANNO_ATTRIBUTES
// A.1 remove obsolete annotations from moz_annos.
@ -285,47 +283,6 @@ this.PlacesDBUtils = {
)`
},
// MOZ_BOOKMARKS
// C.2 fix roots titles
// Some alpha version has wrong roots title, and this also fixes them if
// locale has changed.
{ query: updateRootTitleSql,
params: {
root_id: PlacesUtils.placesRootId,
title: "",
}
},
{ query: updateRootTitleSql,
params: {
root_id: PlacesUtils.bookmarksMenuFolderId,
title: PlacesUtils.getString("BookmarksMenuFolderTitle"),
}
},
{ query: updateRootTitleSql,
params: {
root_id: PlacesUtils.bookmarksMenuFolderId,
title: PlacesUtils.getString("BookmarksMenuFolderTitle"),
}
},
{ query: updateRootTitleSql,
params: {
root_id: PlacesUtils.toolbarFolderId,
title: PlacesUtils.getString("BookmarksToolbarFolderTitle"),
}
},
{ query: updateRootTitleSql,
params: {
root_id: PlacesUtils.unfiledBookmarksFolderId,
title: PlacesUtils.getString("OtherBookmarksFolderTitle"),
}
},
{ query: updateRootTitleSql,
params: {
root_id: PlacesUtils.tagsFolderId,
title: PlacesUtils.getString("TagsFolderTitle"),
}
},
// D.1 remove items without a valid place
// If fk IS NULL we fix them in D.7
{ query:

View File

@ -1057,16 +1057,6 @@ const BookmarkSyncUtils = PlacesSyncUtils.bookmarks = Object.freeze({
let hasMobileBookmarks = mobileChildGuids.length > 0;
Services.prefs.setBoolPref(MOBILE_BOOKMARKS_PREF, hasMobileBookmarks);
if (hasMobileBookmarks) {
let mobileTitle = PlacesUtils.getString("MobileBookmarksFolderTitle");
// Make sure the mobile root title matches the query.
await PlacesUtils.bookmarks.update({
guid: PlacesUtils.bookmarks.mobileGuid,
title: mobileTitle,
source: SOURCE_SYNC,
});
}
},
/**

View File

@ -10,6 +10,12 @@ ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://testing-common/PlacesTestUtils.jsm");
ChromeUtils.import("resource://testing-common/httpd.js");
// These titles are defined in Database::CreateBookmarkRoots
const BookmarksMenuTitle = "menu";
const BookmarksToolbarTitle = "toolbar";
const UnfiledBookmarksTitle = "unfiled";
const MobileBookmarksTitle = "mobile";
function run_test() {
let bufLog = Log.repository.getLogger("Sync.Engine.Bookmarks.Mirror");
bufLog.level = Log.Level.Error;

View File

@ -29,7 +29,7 @@ add_task(async function test_missing_children() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "bookmarkCCCC",
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -68,7 +68,7 @@ add_task(async function test_missing_children() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "bookmarkBBBB",
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -114,7 +114,7 @@ add_task(async function test_missing_children() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "bookmarkBBBB",
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -192,7 +192,7 @@ add_task(async function test_new_orphan_without_local_parent() {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
children: [{
guid: "bookmarkBBBB",
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -239,7 +239,7 @@ add_task(async function test_new_orphan_without_local_parent() {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
children: [{
guid: "folderAAAAAA",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
@ -291,7 +291,7 @@ add_task(async function test_new_orphan_without_local_parent() {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
children: [{
guid: "folderEEEEEE",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
@ -352,7 +352,7 @@ add_task(async function test_new_orphan_without_local_parent() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "folderEEEEEE",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
@ -388,17 +388,17 @@ add_task(async function test_new_orphan_without_local_parent() {
guid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 1,
title: "Bookmarks Toolbar",
title: BookmarksToolbarTitle,
}, {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
}, {
guid: PlacesUtils.bookmarks.mobileGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 4,
title: "mobile",
title: MobileBookmarksTitle,
}],
}, "Should form complete tree after applying E");
@ -525,7 +525,7 @@ add_task(async function test_move_into_orphaned() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
// A remains in its original place, since we don't use the `parentid`,
// and we don't have a record for G.
@ -578,17 +578,17 @@ add_task(async function test_move_into_orphaned() {
guid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 1,
title: "Bookmarks Toolbar",
title: BookmarksToolbarTitle,
}, {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
}, {
guid: PlacesUtils.bookmarks.mobileGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 4,
title: "mobile",
title: MobileBookmarksTitle,
}],
}, "Should treat local tree as canonical if server is missing new parent");
@ -676,7 +676,7 @@ add_task(async function test_new_orphan_with_local_parent() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "folderAAAAAA",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
@ -700,12 +700,12 @@ add_task(async function test_new_orphan_with_local_parent() {
guid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 1,
title: "Bookmarks Toolbar",
title: BookmarksToolbarTitle,
}, {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
children: [{
guid: "bookmarkCCCC",
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -723,7 +723,7 @@ add_task(async function test_new_orphan_with_local_parent() {
guid: PlacesUtils.bookmarks.mobileGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 4,
title: "mobile",
title: MobileBookmarksTitle,
}],
}, "Should move (C D) to unfiled");
@ -870,17 +870,17 @@ add_task(async function test_partial_cycle() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
}, {
guid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 1,
title: "Bookmarks Toolbar",
title: BookmarksToolbarTitle,
}, {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
children: [{
guid: "folderBBBBBB",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
@ -904,7 +904,7 @@ add_task(async function test_partial_cycle() {
guid: PlacesUtils.bookmarks.mobileGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 4,
title: "mobile",
title: MobileBookmarksTitle,
}],
}, "Should move A and B to unfiled");
@ -969,22 +969,22 @@ add_task(async function test_complete_cycle() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
}, {
guid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 1,
title: "Bookmarks Toolbar",
title: BookmarksToolbarTitle,
}, {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
}, {
guid: PlacesUtils.bookmarks.mobileGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 4,
title: "mobile",
title: MobileBookmarksTitle,
}],
}, "Should not be confused into creating a cycle");

View File

@ -140,7 +140,7 @@ add_task(async function test_duping() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "folderAAAAAA",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
@ -221,17 +221,17 @@ add_task(async function test_duping() {
guid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 1,
title: "Bookmarks Toolbar",
title: BookmarksToolbarTitle,
}, {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
}, {
guid: PlacesUtils.bookmarks.mobileGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 4,
title: "mobile",
title: MobileBookmarksTitle,
}],
}, "Should dedupe matching NEW bookmarks");

View File

@ -117,7 +117,7 @@ add_task(async function test_complex_orphaning() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "folderGGGGGG",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
@ -142,7 +142,7 @@ add_task(async function test_complex_orphaning() {
guid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 1,
title: "Bookmarks Toolbar",
title: BookmarksToolbarTitle,
children: [{
guid: "folderAAAAAA",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
@ -161,12 +161,12 @@ add_task(async function test_complex_orphaning() {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
}, {
guid: PlacesUtils.bookmarks.mobileGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 4,
title: "mobile",
title: MobileBookmarksTitle,
}],
}, "Should move orphans to closest surviving parent");
@ -292,7 +292,7 @@ add_task(async function test_locally_modified_remotely_deleted() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "bookmarkAAAA",
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -427,7 +427,7 @@ add_task(async function test_locally_deleted_remotely_modified() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "bookmarkAAAA",
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -549,7 +549,7 @@ add_task(async function test_move_to_new_then_delete() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "bookmarkCCCC",
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -561,17 +561,17 @@ add_task(async function test_move_to_new_then_delete() {
guid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 1,
title: "Bookmarks Toolbar",
title: BookmarksToolbarTitle,
}, {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
}, {
guid: PlacesUtils.bookmarks.mobileGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 4,
title: "mobile",
title: MobileBookmarksTitle,
}],
}, "Should move C to closest surviving parent");
@ -633,7 +633,7 @@ add_task(async function test_nonexistent_on_one_side() {
hasDupe: false,
parentName: "",
dateAdded: menuDateAdded.getTime(),
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [],
},
},
@ -748,7 +748,7 @@ add_task(async function test_clear_folder_then_delete() {
let idsToUpload = inspectChangeRecords(changesToUpload);
deepEqual(idsToUpload, {
updated: ["bookmarkEEEE", "bookmarkFFFF", "menu", "mobile"],
updated: ["bookmarkEEEE", "bookmarkFFFF", "menu", MobileBookmarksTitle],
deleted: ["bookmarkDDDD"],
}, "Should upload locally moved and deleted items");
@ -761,7 +761,7 @@ add_task(async function test_clear_folder_then_delete() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "bookmarkBBBB",
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -779,12 +779,12 @@ add_task(async function test_clear_folder_then_delete() {
guid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 1,
title: "Bookmarks Toolbar",
title: BookmarksToolbarTitle,
}, {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
children: [{
guid: "bookmarkCCCC",
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -796,7 +796,7 @@ add_task(async function test_clear_folder_then_delete() {
guid: PlacesUtils.bookmarks.mobileGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 4,
title: "mobile",
title: MobileBookmarksTitle,
children: [{
guid: "bookmarkFFFF",
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -934,7 +934,7 @@ add_task(async function test_newer_move_to_deleted() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "bookmarkEEEE",
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -952,7 +952,7 @@ add_task(async function test_newer_move_to_deleted() {
guid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 1,
title: "Bookmarks Toolbar",
title: BookmarksToolbarTitle,
children: [{
guid: "bookmarkDDDD",
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -970,12 +970,12 @@ add_task(async function test_newer_move_to_deleted() {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
}, {
guid: PlacesUtils.bookmarks.mobileGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 4,
title: "mobile",
title: MobileBookmarksTitle,
}],
}, "Should not decide to keep newly moved items in deleted parents");

View File

@ -95,7 +95,7 @@ add_task(async function test_livemarks() {
type: "livemark",
parentid: "menu",
hasDupe: false,
parentName: "Bookmarks Menu",
parentName: BookmarksMenuTitle,
dateAdded: PlacesUtils.toDate(livemarkD.dateAdded).getTime(),
title: "D",
feedUri: site + "/feed/d",
@ -143,7 +143,7 @@ add_task(async function test_livemarks() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "livemarkAAAA",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
@ -176,7 +176,7 @@ add_task(async function test_livemarks() {
guid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 1,
title: "Bookmarks Toolbar",
title: BookmarksToolbarTitle,
children: [{
guid: "livemarkCCCC",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
@ -204,7 +204,7 @@ add_task(async function test_livemarks() {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
children: [{
guid: "livemarkEEEE",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
@ -226,7 +226,7 @@ add_task(async function test_livemarks() {
guid: PlacesUtils.bookmarks.mobileGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 4,
title: "mobile",
title: MobileBookmarksTitle,
}],
}, "Should apply and dedupe livemarks");

View File

@ -137,7 +137,7 @@ add_task(async function test_value_structure_conflict() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "folderAAAAAA",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
@ -358,12 +358,12 @@ add_task(async function test_move() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
}, {
guid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 1,
title: "Bookmarks Toolbar",
title: BookmarksToolbarTitle,
children: [{
guid: "devFolder___",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
@ -387,7 +387,7 @@ add_task(async function test_move() {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
children: [{
guid: "mozFolder___",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
@ -417,7 +417,7 @@ add_task(async function test_move() {
guid: PlacesUtils.bookmarks.mobileGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 4,
title: "mobile",
title: MobileBookmarksTitle,
}],
}, "Should move and reorder bookmarks to match remote");
@ -517,7 +517,7 @@ add_task(async function test_move_into_parent_sibling() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "folderAAAAAA",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
@ -673,7 +673,7 @@ add_task(async function test_complex_move_with_additions() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "bookmarkCCCC",
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -685,7 +685,7 @@ add_task(async function test_complex_move_with_additions() {
guid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 1,
title: "Bookmarks Toolbar",
title: BookmarksToolbarTitle,
children: [{
// We can guarantee child order (B E D), since we always walk remote
// children first, and the remote folder A record is newer than the
@ -719,12 +719,12 @@ add_task(async function test_complex_move_with_additions() {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
}, {
guid: PlacesUtils.bookmarks.mobileGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 4,
title: "mobile",
title: MobileBookmarksTitle,
}],
}, "Should take remote order and preserve local children");
@ -882,7 +882,7 @@ add_task(async function test_reorder_and_insert() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "bookmarkCCCC",
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -918,7 +918,7 @@ add_task(async function test_reorder_and_insert() {
guid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 1,
title: "Bookmarks Toolbar",
title: BookmarksToolbarTitle,
children: [{
guid: "bookmarkFFFF",
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
@ -954,12 +954,12 @@ add_task(async function test_reorder_and_insert() {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
}, {
guid: PlacesUtils.bookmarks.mobileGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 4,
title: "mobile",
title: MobileBookmarksTitle,
}],
}, "Should use timestamps to decide base folder order");

View File

@ -82,7 +82,7 @@ add_task(async function test_value_combo() {
type: "bookmark",
parentid: "toolbar",
hasDupe: false,
parentName: "Bookmarks Toolbar",
parentName: BookmarksToolbarTitle,
dateAdded: bzBmk.dateAdded.getTime(),
bmkUri: "https://bugzilla.mozilla.org/",
title: "Bugzilla",
@ -100,7 +100,7 @@ add_task(async function test_value_combo() {
hasDupe: false,
parentName: "",
dateAdded: menuInfo.dateAdded.getTime(),
title: "Bookmarks Toolbar",
title: BookmarksToolbarTitle,
children: ["fxBmk_______", "tFolder_____", "bzBmk_______"],
},
},
@ -356,7 +356,7 @@ add_task(async function test_value_only_changes() {
guid: PlacesUtils.bookmarks.menuGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 0,
title: "Bookmarks Menu",
title: BookmarksMenuTitle,
children: [{
guid: "folderAAAAAA",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
@ -428,17 +428,17 @@ add_task(async function test_value_only_changes() {
guid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 1,
title: "Bookmarks Toolbar",
title: BookmarksToolbarTitle,
}, {
guid: PlacesUtils.bookmarks.unfiledGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 3,
title: "Other Bookmarks",
title: UnfiledBookmarksTitle,
}, {
guid: PlacesUtils.bookmarks.mobileGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
index: 4,
title: "mobile",
title: MobileBookmarksTitle,
}],
}, "Should not change structure for value-only changes");

View File

@ -1,10 +1,18 @@
// Test that result node for folder shortcuts get the target folder title if
// the shortcut itself has no title set.
add_task(async function() {
let folder = await PlacesUtils.bookmarks.insert({
type: PlacesUtils.bookmarks.TYPE_FOLDER,
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
title: "fake"
});
let folderId = await PlacesUtils.promiseItemId(folder.guid);
let shortcutInfo = await PlacesUtils.bookmarks.insert({
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: "place:folder=TOOLBAR"
url: `place:folder=${folderId}`
});
let unfiledRoot =
@ -12,9 +20,7 @@ add_task(async function() {
let shortcutNode = unfiledRoot.getChild(unfiledRoot.childCount - 1);
Assert.equal(shortcutNode.bookmarkGuid, shortcutInfo.guid);
let toolbarInfo =
await PlacesUtils.bookmarks.fetch(PlacesUtils.bookmarks.toolbarGuid);
Assert.equal(shortcutNode.title, toolbarInfo.title);
Assert.equal(shortcutNode.title, folder.title);
unfiledRoot.containerOpen = false;
});

View File

@ -71,7 +71,7 @@ add_task(async function() {
break;
case Ci.nsIDOMNode.TEXT_NODE:
// Check Title and description.
if (!current.data.startsWith("\n") && !current.data.includes("Bookmarks")) {
if (!current.data.startsWith("\n") && current.data.includes("test")) {
Assert.equal(current.data.trim(), unescaped, "Text node should be complete");
checksCount--;
}

View File

@ -372,35 +372,6 @@ tests.push({
}
});
// ------------------------------------------------------------------------------
tests.push({
name: "C.2",
desc: "Fix roots titles",
setup() {
// Sanity check: ensure that roots titles are correct. We can use our check.
this.check();
// Change some roots' titles.
bs.setItemTitle(bs.placesRoot, "bad title");
Assert.equal(bs.getItemTitle(bs.placesRoot), "bad title");
bs.setItemTitle(bs.unfiledBookmarksFolder, "bad title");
Assert.equal(bs.getItemTitle(bs.unfiledBookmarksFolder), "bad title");
},
check() {
// Ensure all roots titles are correct.
Assert.equal(bs.getItemTitle(bs.placesRoot), "");
Assert.equal(bs.getItemTitle(bs.bookmarksMenuFolder),
PlacesUtils.getString("BookmarksMenuFolderTitle"));
Assert.equal(bs.getItemTitle(bs.tagsFolder),
PlacesUtils.getString("TagsFolderTitle"));
Assert.equal(bs.getItemTitle(bs.unfiledBookmarksFolder),
PlacesUtils.getString("OtherBookmarksFolderTitle"));
Assert.equal(bs.getItemTitle(bs.toolbarFolder),
PlacesUtils.getString("BookmarksToolbarFolderTitle"));
}
});
// ------------------------------------------------------------------------------
tests.push({

View File

@ -1894,7 +1894,7 @@ add_task(async function test_fetch() {
parentRecordId: "menu",
description: "Folder description",
childRecordIds: [folderBmk.recordId, folderSep.recordId],
parentTitle: "Bookmarks Menu",
parentTitle: "menu",
dateAdded: item.dateAdded,
title: "",
}, "Should include description, children, title, and parent title in folder");
@ -1912,7 +1912,7 @@ add_task(async function test_fetch() {
deepEqual(item.tags, ["taggy"], "Should return tags");
equal(item.description, "Bookmark description", "Should return bookmark description");
strictEqual(item.loadInSidebar, true, "Should return sidebar anno");
equal(item.parentTitle, "Bookmarks Menu", "Should return parent title");
equal(item.parentTitle, "menu", "Should return parent title");
strictEqual(item.title, "", "Should return empty title");
}