mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 1318414 - Default to empty strings for titles and parent titles if not set. r=rnewman,tcsc
MozReview-Commit-ID: DppxJuVrbAM --HG-- extra : rebase_source : 649bc0b945c8a2dd69dade682bf80c874053bc92
This commit is contained in:
parent
bf271af4ea
commit
96702bd1f2
@ -347,12 +347,12 @@ BookmarksEngine.prototype = {
|
|||||||
if (query && query.value) {
|
if (query && query.value) {
|
||||||
key = "q" + query.value;
|
key = "q" + query.value;
|
||||||
} else {
|
} else {
|
||||||
key = "b" + node.uri + ":" + node.title;
|
key = "b" + node.uri + ":" + (node.title || "");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER:
|
case PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER:
|
||||||
// Folder
|
// Folder
|
||||||
key = "f" + node.title;
|
key = "f" + (node.title || "");
|
||||||
break;
|
break;
|
||||||
case PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR:
|
case PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR:
|
||||||
// Separator
|
// Separator
|
||||||
@ -363,7 +363,7 @@ BookmarksEngine.prototype = {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let parentName = parent.title;
|
let parentName = parent.title || "";
|
||||||
if (guidMap[parentName] == null)
|
if (guidMap[parentName] == null)
|
||||||
guidMap[parentName] = {};
|
guidMap[parentName] = {};
|
||||||
|
|
||||||
@ -391,17 +391,17 @@ BookmarksEngine.prototype = {
|
|||||||
// hack should get them to dupe correctly.
|
// hack should get them to dupe correctly.
|
||||||
if (item.queryId) {
|
if (item.queryId) {
|
||||||
key = "q" + item.queryId;
|
key = "q" + item.queryId;
|
||||||
altKey = "b" + item.bmkUri + ":" + item.title;
|
altKey = "b" + item.bmkUri + ":" + (item.title || "");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// No queryID? Fall through to the regular bookmark case.
|
// No queryID? Fall through to the regular bookmark case.
|
||||||
case "bookmark":
|
case "bookmark":
|
||||||
case "microsummary":
|
case "microsummary":
|
||||||
key = "b" + item.bmkUri + ":" + item.title;
|
key = "b" + item.bmkUri + ":" + (item.title || "");
|
||||||
break;
|
break;
|
||||||
case "folder":
|
case "folder":
|
||||||
case "livemark":
|
case "livemark":
|
||||||
key = "f" + item.title;
|
key = "f" + (item.title || "");
|
||||||
break;
|
break;
|
||||||
case "separator":
|
case "separator":
|
||||||
key = "s" + item.pos;
|
key = "s" + item.pos;
|
||||||
@ -415,8 +415,9 @@ BookmarksEngine.prototype = {
|
|||||||
let guidMap = this._guidMap;
|
let guidMap = this._guidMap;
|
||||||
|
|
||||||
// Give the GUID if we have the matching pair.
|
// Give the GUID if we have the matching pair.
|
||||||
this._log.trace("Finding mapping: " + item.parentName + ", " + key);
|
let parentName = item.parentName || "";
|
||||||
let parent = guidMap[item.parentName];
|
this._log.trace("Finding mapping: " + parentName + ", " + key);
|
||||||
|
let parent = guidMap[parentName];
|
||||||
|
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
this._log.trace("No parent => no dupe.");
|
this._log.trace("No parent => no dupe.");
|
||||||
|
@ -279,7 +279,9 @@ const BookmarkSyncUtils = PlacesSyncUtils.bookmarks = Object.freeze({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert the Places bookmark object to a Sync bookmark and add
|
// Convert the Places bookmark object to a Sync bookmark and add
|
||||||
// kind-specific properties.
|
// kind-specific properties. Titles are required for bookmarks,
|
||||||
|
// folders, and livemarks; optional for queries, and omitted for
|
||||||
|
// separators.
|
||||||
let kind = yield getKindForItem(bookmarkItem);
|
let kind = yield getKindForItem(bookmarkItem);
|
||||||
let item;
|
let item;
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
@ -309,12 +311,11 @@ const BookmarkSyncUtils = PlacesSyncUtils.bookmarks = Object.freeze({
|
|||||||
throw new Error(`Unknown bookmark kind: ${kind}`);
|
throw new Error(`Unknown bookmark kind: ${kind}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync uses the parent title for de-duping.
|
// Sync uses the parent title for de-duping. All Sync bookmark objects
|
||||||
|
// except the Places root should have this property.
|
||||||
if (bookmarkItem.parentGuid) {
|
if (bookmarkItem.parentGuid) {
|
||||||
let parent = yield PlacesUtils.bookmarks.fetch(bookmarkItem.parentGuid);
|
let parent = yield PlacesUtils.bookmarks.fetch(bookmarkItem.parentGuid);
|
||||||
if ("title" in parent) {
|
item.parentTitle = parent.title || "";
|
||||||
item.parentTitle = parent.title;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
@ -1040,6 +1041,10 @@ function syncBookmarkToPlacesBookmark(info) {
|
|||||||
var fetchBookmarkItem = Task.async(function* (bookmarkItem) {
|
var fetchBookmarkItem = Task.async(function* (bookmarkItem) {
|
||||||
let item = yield placesBookmarkToSyncBookmark(bookmarkItem);
|
let item = yield placesBookmarkToSyncBookmark(bookmarkItem);
|
||||||
|
|
||||||
|
if (!item.title) {
|
||||||
|
item.title = "";
|
||||||
|
}
|
||||||
|
|
||||||
item.tags = PlacesUtils.tagging.getTagsForURI(
|
item.tags = PlacesUtils.tagging.getTagsForURI(
|
||||||
PlacesUtils.toURI(bookmarkItem.url), {});
|
PlacesUtils.toURI(bookmarkItem.url), {});
|
||||||
|
|
||||||
@ -1067,6 +1072,10 @@ var fetchBookmarkItem = Task.async(function* (bookmarkItem) {
|
|||||||
var fetchFolderItem = Task.async(function* (bookmarkItem) {
|
var fetchFolderItem = Task.async(function* (bookmarkItem) {
|
||||||
let item = yield placesBookmarkToSyncBookmark(bookmarkItem);
|
let item = yield placesBookmarkToSyncBookmark(bookmarkItem);
|
||||||
|
|
||||||
|
if (!item.title) {
|
||||||
|
item.title = "";
|
||||||
|
}
|
||||||
|
|
||||||
let description = yield getAnno(bookmarkItem.guid,
|
let description = yield getAnno(bookmarkItem.guid,
|
||||||
BookmarkSyncUtils.DESCRIPTION_ANNO);
|
BookmarkSyncUtils.DESCRIPTION_ANNO);
|
||||||
if (description) {
|
if (description) {
|
||||||
@ -1087,6 +1096,10 @@ var fetchFolderItem = Task.async(function* (bookmarkItem) {
|
|||||||
var fetchLivemarkItem = Task.async(function* (bookmarkItem) {
|
var fetchLivemarkItem = Task.async(function* (bookmarkItem) {
|
||||||
let item = yield placesBookmarkToSyncBookmark(bookmarkItem);
|
let item = yield placesBookmarkToSyncBookmark(bookmarkItem);
|
||||||
|
|
||||||
|
if (!item.title) {
|
||||||
|
item.title = "";
|
||||||
|
}
|
||||||
|
|
||||||
let description = yield getAnno(bookmarkItem.guid,
|
let description = yield getAnno(bookmarkItem.guid,
|
||||||
BookmarkSyncUtils.DESCRIPTION_ANNO);
|
BookmarkSyncUtils.DESCRIPTION_ANNO);
|
||||||
if (description) {
|
if (description) {
|
||||||
|
@ -1058,14 +1058,15 @@ add_task(function* test_fetch() {
|
|||||||
description: "Folder description",
|
description: "Folder description",
|
||||||
childSyncIds: [folderBmk.syncId, folderSep.syncId],
|
childSyncIds: [folderBmk.syncId, folderSep.syncId],
|
||||||
parentTitle: "Bookmarks Menu",
|
parentTitle: "Bookmarks Menu",
|
||||||
}, "Should include description, children, and parent title in folder");
|
title: "",
|
||||||
|
}, "Should include description, children, title, and parent title in folder");
|
||||||
}
|
}
|
||||||
|
|
||||||
do_print("Fetch bookmark with description, sidebar anno, and tags");
|
do_print("Fetch bookmark with description, sidebar anno, and tags");
|
||||||
{
|
{
|
||||||
let item = yield PlacesSyncUtils.bookmarks.fetch(bmk.syncId);
|
let item = yield PlacesSyncUtils.bookmarks.fetch(bmk.syncId);
|
||||||
deepEqual(Object.keys(item).sort(), ["syncId", "kind", "parentSyncId", "url",
|
deepEqual(Object.keys(item).sort(), ["syncId", "kind", "parentSyncId",
|
||||||
"tags", "description", "loadInSidebar", "parentTitle"].sort(),
|
"url", "tags", "description", "loadInSidebar", "parentTitle", "title"].sort(),
|
||||||
"Should include bookmark-specific properties");
|
"Should include bookmark-specific properties");
|
||||||
equal(item.syncId, bmk.syncId, "Sync ID should match");
|
equal(item.syncId, bmk.syncId, "Sync ID should match");
|
||||||
equal(item.url.href, "https://example.com/", "Should return URL");
|
equal(item.url.href, "https://example.com/", "Should return URL");
|
||||||
@ -1074,17 +1075,20 @@ add_task(function* test_fetch() {
|
|||||||
equal(item.description, "Bookmark description", "Should return bookmark description");
|
equal(item.description, "Bookmark description", "Should return bookmark description");
|
||||||
strictEqual(item.loadInSidebar, true, "Should return sidebar anno");
|
strictEqual(item.loadInSidebar, true, "Should return sidebar anno");
|
||||||
equal(item.parentTitle, "Bookmarks Menu", "Should return parent title");
|
equal(item.parentTitle, "Bookmarks Menu", "Should return parent title");
|
||||||
|
strictEqual(item.title, "", "Should return empty title");
|
||||||
}
|
}
|
||||||
|
|
||||||
do_print("Fetch bookmark with keyword; without parent title or annos");
|
do_print("Fetch bookmark with keyword; without parent title or annos");
|
||||||
{
|
{
|
||||||
let item = yield PlacesSyncUtils.bookmarks.fetch(folderBmk.syncId);
|
let item = yield PlacesSyncUtils.bookmarks.fetch(folderBmk.syncId);
|
||||||
deepEqual(Object.keys(item).sort(), ["syncId", "kind", "parentSyncId",
|
deepEqual(Object.keys(item).sort(), ["syncId", "kind", "parentSyncId",
|
||||||
"url", "keyword", "tags", "loadInSidebar"].sort(),
|
"url", "keyword", "tags", "loadInSidebar", "parentTitle", "title"].sort(),
|
||||||
"Should omit blank bookmark-specific properties");
|
"Should omit blank bookmark-specific properties");
|
||||||
strictEqual(item.loadInSidebar, false, "Should not load bookmark in sidebar");
|
strictEqual(item.loadInSidebar, false, "Should not load bookmark in sidebar");
|
||||||
deepEqual(item.tags, [], "Tags should be empty");
|
deepEqual(item.tags, [], "Tags should be empty");
|
||||||
equal(item.keyword, "kw", "Should return keyword");
|
equal(item.keyword, "kw", "Should return keyword");
|
||||||
|
strictEqual(item.parentTitle, "", "Should include parent title even if empty");
|
||||||
|
strictEqual(item.title, "", "Should include bookmark title even if empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
do_print("Fetch separator");
|
do_print("Fetch separator");
|
||||||
@ -1132,11 +1136,12 @@ add_task(function* test_fetch_livemark() {
|
|||||||
do_print("Fetch livemark");
|
do_print("Fetch livemark");
|
||||||
let item = yield PlacesSyncUtils.bookmarks.fetch(livemark.guid);
|
let item = yield PlacesSyncUtils.bookmarks.fetch(livemark.guid);
|
||||||
deepEqual(Object.keys(item).sort(), ["syncId", "kind", "parentSyncId",
|
deepEqual(Object.keys(item).sort(), ["syncId", "kind", "parentSyncId",
|
||||||
"description", "feed", "site", "parentTitle"].sort(),
|
"description", "feed", "site", "parentTitle", "title"].sort(),
|
||||||
"Should include livemark-specific properties");
|
"Should include livemark-specific properties");
|
||||||
equal(item.description, "Livemark description", "Should return description");
|
equal(item.description, "Livemark description", "Should return description");
|
||||||
equal(item.feed.href, site + "/feed/1", "Should return feed URL");
|
equal(item.feed.href, site + "/feed/1", "Should return feed URL");
|
||||||
equal(item.site.href, site + "/", "Should return site URL");
|
equal(item.site.href, site + "/", "Should return site URL");
|
||||||
|
strictEqual(item.title, "", "Should include livemark title even if empty");
|
||||||
} finally {
|
} finally {
|
||||||
yield stopServer();
|
yield stopServer();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user