Bug 1467996 - Remove all the code adding a description annotation. r=mak,lina

MozReview-Commit-ID: CRBSxJtJELp

Differential Revision: https://phabricator.services.mozilla.com/D1748
This commit is contained in:
Mark Banner 2018-06-26 12:33:45 +00:00
parent 6060756652
commit 1808cc5dec
19 changed files with 49 additions and 438 deletions

View File

@ -152,15 +152,6 @@ DistributionCustomizer.prototype = {
await this._parseBookmarksSection(folder.guid,
"BookmarksFolder-" + item.folderId);
if (item.description) {
let folderId = await PlacesUtils.promiseItemId(folder.guid);
PlacesUtils.annotations.setItemAnnotation(folderId,
"bookmarkProperties/description",
item.description, 0,
PlacesUtils.annotations.EXPIRE_NEVER);
}
break;
case "separator":
@ -191,18 +182,10 @@ DistributionCustomizer.prototype = {
if (itemIndex < defaultIndex)
index = prependIndex++;
let bm = await PlacesUtils.bookmarks.insert({
await PlacesUtils.bookmarks.insert({
parentGuid, index, title: item.title, url: item.link
});
if (item.description) {
let bmId = await PlacesUtils.promiseItemId(bm.guid);
PlacesUtils.annotations.setItemAnnotation(bmId,
"bookmarkProperties/description",
item.description, 0,
PlacesUtils.annotations.EXPIRE_NEVER);
}
if (item.icon && item.iconData) {
try {
let faviconURI = Services.io.newURI(item.icon);

View File

@ -209,7 +209,6 @@ let InternalFaviconLoader = {
};
var PlacesUIUtils = {
DESCRIPTION_ANNO: "bookmarkProperties/description",
LAST_USED_FOLDERS_META_KEY: "bookmarks/lastusedfolders",
/**

View File

@ -31,7 +31,6 @@ XPCOMUtils.defineLazyGetter(this, "PlacesBundle", () => {
});
XPCOMUtils.defineLazyGetter(this, "ANNOS_TO_TRACK", () => [
PlacesSyncUtils.bookmarks.DESCRIPTION_ANNO,
PlacesUtils.LMANNO_FEEDURI,
PlacesUtils.LMANNO_SITEURI,
]);

View File

@ -8,8 +8,6 @@ ChromeUtils.import("resource://services-sync/engines/bookmarks.js");
ChromeUtils.import("resource://services-sync/util.js");
ChromeUtils.import("resource://services-sync/service.js");
const DESCRIPTION_ANNO = "bookmarkProperties/description";
// Record borrowed from Bug 631361.
const record631361 = {
id: "M5bwUKK8hPyF",
@ -59,34 +57,6 @@ function makeLivemark(p, mintGUID) {
return b;
}
add_task(async function test_livemark_descriptions() {
let engine = new BookmarksEngine(Service);
await engine.initialize();
let store = engine._store;
let record = record631361.payload;
async function doRecord(r) {
store._childrenToOrder = {};
await store.applyIncoming(r);
await store._orderChildren();
delete store._childrenToOrder;
}
// Attempt to provoke an error by messing around with the description.
record.description = null;
await doRecord(makeLivemark(record));
record.description = "";
await doRecord(makeLivemark(record));
// Attempt to provoke an error by adding a bad description anno.
let id = await PlacesUtils.promiseItemId(record.id);
PlacesUtils.annotations.setItemAnnotation(id, DESCRIPTION_ANNO, "", 0,
PlacesUtils.annotations.EXPIRE_NEVER);
await engine.finalize();
});
add_task(async function test_livemark_invalid() {
let engine = new BookmarksEngine(Service);
await engine.initialize();

View File

@ -57,7 +57,6 @@ add_task(async function test_bookmark_create() {
_("Let's create a new record.");
let fxrecord = new Bookmark("bookmarks", "get-firefox1");
fxrecord.bmkUri = "http://getfirefox.com/";
fxrecord.description = "Firefox is awesome.";
fxrecord.title = "Get Firefox!";
fxrecord.tags = ["firefox", "awesome", "browser"];
fxrecord.keyword = "awesome";
@ -70,10 +69,6 @@ add_task(async function test_bookmark_create() {
Assert.equal(item.type, PlacesUtils.bookmarks.TYPE_BOOKMARK);
Assert.equal(item.url.href, "http://getfirefox.com/");
Assert.equal(item.title, fxrecord.title);
let id = await PlacesUtils.promiseItemId(item.guid);
let description = PlacesUtils.annotations.getItemAnnotation(id,
PlacesSyncUtils.bookmarks.DESCRIPTION_ANNO);
Assert.equal(description, fxrecord.description);
Assert.equal(item.parentGuid, PlacesUtils.bookmarks.toolbarGuid);
let keyword = await PlacesUtils.keywords.fetch(fxrecord.keyword);
Assert.equal(keyword.url.href, "http://getfirefox.com/");
@ -81,7 +76,7 @@ add_task(async function test_bookmark_create() {
_("Have the store create a new record object. Verify that it has the same data.");
let newrecord = await store.createRecord(fxrecord.id);
Assert.ok(newrecord instanceof Bookmark);
for (let property of ["type", "bmkUri", "description", "title",
for (let property of ["type", "bmkUri", "title",
"keyword", "parentName", "parentid"]) {
Assert.equal(newrecord[property], fxrecord[property]);
}
@ -100,14 +95,9 @@ add_task(async function test_bookmark_create() {
_("Verify it has been created correctly.");
item = await PlacesUtils.bookmarks.fetch(tbrecord.id);
id = await PlacesUtils.promiseItemId(item.guid);
Assert.equal(item.type, PlacesUtils.bookmarks.TYPE_BOOKMARK);
Assert.equal(item.url.href, "http://getthunderbird.com/");
Assert.equal(item.title, "");
do_check_throws(function() {
PlacesUtils.annotations.getItemAnnotation(id,
PlacesSyncUtils.bookmarks.DESCRIPTION_ANNO);
}, Cr.NS_ERROR_NOT_AVAILABLE);
Assert.equal(item.parentGuid, PlacesUtils.bookmarks.toolbarGuid);
keyword = await PlacesUtils.keywords.fetch({
url: "http://getthunderbird.com/",
@ -131,10 +121,6 @@ add_task(async function test_bookmark_update() {
url: "http://getfirefox.com/",
title: "Get Firefox!",
});
let bmk1_id = await PlacesUtils.promiseItemId(bmk1.guid);
PlacesUtils.annotations.setItemAnnotation(
bmk1_id, PlacesSyncUtils.bookmarks.DESCRIPTION_ANNO,
"Firefox is awesome.", 0, PlacesUtils.annotations.EXPIRE_NEVER);
await PlacesUtils.keywords.insert({
url: "http://getfirefox.com/",
keyword: "firefox",
@ -143,16 +129,11 @@ add_task(async function test_bookmark_update() {
_("Update the record with some null values.");
let record = await store.createRecord(bmk1.guid);
record.title = null;
record.description = null;
record.keyword = null;
record.tags = null;
await store.applyIncoming(record);
_("Verify that the values have been cleared.");
do_check_throws(function() {
PlacesUtils.annotations.getItemAnnotation(
bmk1_id, PlacesSyncUtils.bookmarks.DESCRIPTION_ANNO);
}, Cr.NS_ERROR_NOT_AVAILABLE);
let item = await PlacesUtils.bookmarks.fetch(bmk1.guid);
Assert.equal(item.title, "");
let keyword = await PlacesUtils.keywords.fetch({
@ -171,7 +152,7 @@ add_task(async function test_bookmark_createRecord() {
let store = engine._store;
try {
_("Create a bookmark without a description or title.");
_("Create a bookmark without a title.");
let bmk1 = await PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
url: "http://getfirefox.com/",
@ -180,7 +161,6 @@ add_task(async function test_bookmark_createRecord() {
_("Verify that the record is created accordingly.");
let record = await store.createRecord(bmk1.guid);
Assert.equal(record.title, "");
Assert.equal(record.description, null);
Assert.equal(record.keyword, null);
} finally {

View File

@ -683,41 +683,6 @@ add_task(async function test_async_onItemKeywordDeleted() {
}
});
add_task(async function test_onItemAnnoChanged() {
_("Item annotations should be tracked");
try {
await tracker.stop();
let folder = PlacesUtils.bookmarks.createFolder(
PlacesUtils.bookmarks.bookmarksMenuFolder, "Parent",
PlacesUtils.bookmarks.DEFAULT_INDEX);
_("Track changes to annos.");
let b = PlacesUtils.bookmarks.insertBookmark(
folder, CommonUtils.makeURI("http://getfirefox.com"),
PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!");
let bGUID = await PlacesUtils.promiseItemGuid(b);
_("New item is " + b);
_("GUID: " + bGUID);
await startTracking();
PlacesUtils.annotations.setItemAnnotation(
b, PlacesSyncUtils.bookmarks.DESCRIPTION_ANNO, "A test description", 0,
PlacesUtils.annotations.EXPIRE_NEVER);
// bookmark should be tracked, folder should not.
await verifyTrackedItems([bGUID]);
Assert.equal(tracker.score, SCORE_INCREMENT_XLARGE);
await resetTracker();
PlacesUtils.annotations.removeItemAnnotation(b,
PlacesSyncUtils.bookmarks.DESCRIPTION_ANNO);
await verifyTrackedItems([bGUID]);
Assert.equal(tracker.score, SCORE_INCREMENT_XLARGE);
} finally {
_("Clean up.");
await cleanup();
}
});
add_task(async function test_onItemAdded_filtered_root() {
_("Items outside the change roots should not be tracked");

View File

@ -36,7 +36,6 @@ function PlacesItemProps(props) {
this.uri = null;
this.keyword = null;
this.title = null;
this.description = null;
this.after = null;
this.before = null;
this.folder = null;
@ -260,31 +259,6 @@ PlacesItem.prototype = {
return parentGuid;
},
/**
* CheckDescription
*
* Compares the description of this places item with an expected
* description.
*
* @param expectedDescription The description this places item is
* expected to have
* @return true if the actual and expected descriptions match, or if
* there is no expected description; otherwise false
*/
async CheckDescription(expectedDescription) {
if (expectedDescription != null) {
// Use PlacesSyncUtils as it gives us the description.
let info = await PlacesSyncUtils.bookmarks.fetch(this.props.guid);
if (info.description != expectedDescription) {
Logger.logPotentialError("Invalid description, expected: " +
expectedDescription + ", actual: " + info.description + " for " +
this.toString());
return false;
}
}
return true;
},
/**
* CheckPosition
*
@ -339,31 +313,6 @@ PlacesItem.prototype = {
}
},
/**
* SetDescription
*
* Updates the description for this places item.
*
* @param description The new description to set; if null, no changes are
* made
* @return nothing
*/
async SetDescription(description) {
let itemId = await PlacesUtils.promiseItemId(this.props.guid);
if (description != null) {
if (description != "")
PlacesUtils.annotations.setItemAnnotation(itemId,
"bookmarkProperties/description",
description,
0,
PlacesUtils.annotations.EXPIRE_NEVER);
else
PlacesUtils.annotations.removeItemAnnotation(itemId,
"bookmarkProperties/description");
}
},
/**
* SetPosition
*
@ -495,7 +444,6 @@ Bookmark.prototype = {
title: this.props.title});
this.props.guid = guid;
await this.SetKeyword(this.props.keyword);
await this.SetDescription(this.props.description);
await this.SetTags(this.props.tags);
return this.props.guid;
},
@ -510,7 +458,6 @@ Bookmark.prototype = {
*/
async Update() {
Logger.AssertTrue(this.props.guid, "Invalid guid during Update");
await this.SetDescription(this.updateProps.description);
await this.SetTitle(this.updateProps.title);
await this.SetUri(this.updateProps.uri);
await this.SetKeyword(this.updateProps.keyword);
@ -543,9 +490,6 @@ Bookmark.prototype = {
Logger.logPotentialError(this.toString() + " not found");
return null;
}
if (!(await this.CheckDescription(this.props.description))) {
return null;
}
if (this.props.keyword != null) {
let {keyword} = await PlacesSyncUtils.bookmarks.fetch(this.props.guid);
if (keyword != this.props.keyword) {
@ -624,7 +568,6 @@ BookmarkFolder.prototype = {
type: PlacesUtils.bookmarks.TYPE_FOLDER,
});
this.props.guid = guid;
await this.SetDescription(this.props.description);
return this.props.parentGuid;
},
@ -649,9 +592,6 @@ BookmarkFolder.prototype = {
if (this.props.guid == null) {
return null;
}
if (!(await this.CheckDescription(this.props.description))) {
return null;
}
if (!(await this.CheckPosition(this.props.before,
this.props.after,
this.props.last_item_pos))) {
@ -686,7 +626,6 @@ BookmarkFolder.prototype = {
await this.SetLocation(this.updateProps.location);
await this.SetPosition(this.updateProps.position);
await this.SetTitle(this.updateProps.folder);
await this.SetDescription(this.updateProps.description);
},
};

View File

@ -685,25 +685,10 @@ BookmarkImporter.prototype = {
_closeContainer: function closeContainer(aElt) {
let frame = this._curFrame;
// see the comment for the definition of inDescription. Basically, we commit
// any text in previousText to the description of the node/folder if there
// is any.
// Although we no longer support importing descriptions, we still need to
// clear any previous text, so that it doesn't get swallowed into other elements.
if (frame.inDescription) {
// NOTE ES5 trim trims more than the previous C++ trim.
frame.previousText = frame.previousText.trim(); // important
if (frame.previousText) {
let item = frame.previousLink ? frame.previousItem : frame.folder;
if (!item.hasOwnProperty("annos")) {
item.annos = [];
}
item.annos.push({
"name": DESCRIPTION_ANNO,
"flags": 0,
"expires": 4,
"value": frame.previousText
});
frame.previousText = "";
}
frame.previousText = "";
frame.inDescription = false;
}

View File

@ -92,6 +92,14 @@ const MATCH_ANYWHERE_UNMODIFIED = Ci.mozIPlacesAutoComplete.MATCH_ANYWHERE_UNMOD
const BEHAVIOR_BOOKMARK = Ci.mozIPlacesAutoComplete.BEHAVIOR_BOOKMARK;
const SQLITE_MAX_VARIABLE_NUMBER = 999;
// Annotations which insertTree currently accepts. These should be going away
// soon, see bug 1460577.
const ACCEPTED_ANNOTATIONS = [
PlacesUtils.LMANNO_FEEDURI,
PlacesUtils.LMANNO_SITEURI,
"Places/SmartBookmark",
];
var Bookmarks = Object.freeze({
/**
* Item's type constants.
@ -419,7 +427,8 @@ var Bookmarks = Object.freeze({
(b.dateAdded && b.lastModified >= b.dateAdded) },
index: { replaceWith: indexToUse++ },
source: { replaceWith: source },
annos: {},
annos: { validIf: b => false,
fixup: b => b.annos = b.annos.filter(anno => ACCEPTED_ANNOTATIONS.includes(anno.name))},
keyword: { validIf: b => b.type == TYPE_BOOKMARK },
charset: { validIf: b => b.type == TYPE_BOOKMARK },
postData: { validIf: b => b.type == TYPE_BOOKMARK },

View File

@ -378,7 +378,6 @@ const HistorySyncUtils = PlacesSyncUtils.history = Object.freeze({
const BookmarkSyncUtils = PlacesSyncUtils.bookmarks = Object.freeze({
SMART_BOOKMARKS_ANNO: "Places/SmartBookmark",
DESCRIPTION_ANNO: "bookmarkProperties/description",
SYNC_PARENT_ANNO: "sync/parent",
SYNC_ID_META_KEY: "sync/bookmarks/syncId",
@ -1114,7 +1113,6 @@ const BookmarkSyncUtils = PlacesSyncUtils.bookmarks = Object.freeze({
* - url: Optional.
* - tags: Optional; replaces all existing tags.
* - keyword: Optional.
* - description: Optional.
* - query: Optional.
*
* @param info
@ -1145,7 +1143,6 @@ const BookmarkSyncUtils = PlacesSyncUtils.bookmarks = Object.freeze({
* - query: A smart bookmark query string, optional.
* - tags: An optional array of tag strings.
* - keyword: An optional keyword string.
* - description: An optional description string.
*
* Sync doesn't set the index, since it appends and reorders children
* after applying all incoming items.
@ -1181,8 +1178,6 @@ const BookmarkSyncUtils = PlacesSyncUtils.bookmarks = Object.freeze({
* - url ("bookmark", "query"): The item's URL.
* - tags ("bookmark", "query"): An array containing the item's tags.
* - keyword ("bookmark"): The bookmark's keyword, if one exists.
* - description ("bookmark", "folder", "livemark"): The item's description.
* Omitted if one isn't set.
* - feed ("livemark"): A `URL` object pointing to the livemark's feed URL.
* - site ("livemark"): A `URL` object pointing to the livemark's site URL,
* or `null` if one isn't set.
@ -1602,14 +1597,6 @@ async function insertBookmarkMetadata(db, bookmarkItem, insertInfo) {
newItem.keyword = insertInfo.keyword;
}
if (insertInfo.description) {
PlacesUtils.annotations.setItemAnnotation(itemId,
BookmarkSyncUtils.DESCRIPTION_ANNO, insertInfo.description, 0,
PlacesUtils.annotations.EXPIRE_NEVER,
SOURCE_SYNC);
newItem.description = insertInfo.description;
}
return newItem;
}
@ -1823,19 +1810,6 @@ async function updateBookmarkMetadata(db, oldBookmarkItem,
newItem.keyword = updateInfo.keyword;
}
if (updateInfo.hasOwnProperty("description")) {
if (updateInfo.description) {
PlacesUtils.annotations.setItemAnnotation(itemId,
BookmarkSyncUtils.DESCRIPTION_ANNO, updateInfo.description, 0,
PlacesUtils.annotations.EXPIRE_NEVER,
SOURCE_SYNC);
} else {
PlacesUtils.annotations.removeItemAnnotation(itemId,
BookmarkSyncUtils.DESCRIPTION_ANNO, SOURCE_SYNC);
}
newItem.description = updateInfo.description;
}
if (updateInfo.hasOwnProperty("query")) {
PlacesUtils.annotations.setItemAnnotation(itemId,
BookmarkSyncUtils.SMART_BOOKMARKS_ANNO, updateInfo.query, 0,
@ -1867,10 +1841,6 @@ function validateNewBookmark(name, info) {
BookmarkSyncUtils.KINDS.QUERY ].includes(b.kind) },
keyword: { validIf: b => [ BookmarkSyncUtils.KINDS.BOOKMARK,
BookmarkSyncUtils.KINDS.QUERY ].includes(b.kind) },
description: { validIf: b => [ BookmarkSyncUtils.KINDS.BOOKMARK,
BookmarkSyncUtils.KINDS.QUERY,
BookmarkSyncUtils.KINDS.FOLDER,
BookmarkSyncUtils.KINDS.LIVEMARK ].includes(b.kind) },
feed: { validIf: b => b.kind == BookmarkSyncUtils.KINDS.LIVEMARK },
site: { validIf: b => b.kind == BookmarkSyncUtils.KINDS.LIVEMARK },
dateAdded: { required: false }
@ -1985,9 +1955,8 @@ async function placesBookmarkToSyncBookmark(db, bookmarkItem) {
// Converts a Sync bookmark object to a Places bookmark or livemark object.
// This function maps record IDs to Places GUIDs, and filters out extra Sync
// properties like keywords, tags, and descriptions. Returns an object that can
// be passed to `PlacesUtils.livemarks.addLivemark` or
// `PlacesUtils.bookmarks.{insert, update}`.
// properties like keywords, tags. Returns an object that can be passed to
// `PlacesUtils.livemarks.addLivemark` or `PlacesUtils.bookmarks.{insert, update}`.
function syncBookmarkToPlacesBookmark(info) {
let bookmarkInfo = {
source: SOURCE_SYNC,
@ -2040,7 +2009,7 @@ function syncBookmarkToPlacesBookmark(info) {
}
// Creates and returns a Sync bookmark object containing the bookmark's
// tags, keyword, description.
// tags, keyword.
var fetchBookmarkItem = async function(db, bookmarkItem) {
let item = await placesBookmarkToSyncBookmark(db, bookmarkItem);
@ -2058,17 +2027,10 @@ var fetchBookmarkItem = async function(db, bookmarkItem) {
item.keyword = keywordEntry.keyword;
}
let description = await getAnno(db, bookmarkItem.guid,
BookmarkSyncUtils.DESCRIPTION_ANNO);
if (description) {
item.description = description;
}
return item;
};
// Creates and returns a Sync bookmark object containing the folder's
// description and children.
// Creates and returns a Sync bookmark object containing the folder's children.
async function fetchFolderItem(db, bookmarkItem) {
let item = await placesBookmarkToSyncBookmark(db, bookmarkItem);
@ -2076,12 +2038,6 @@ async function fetchFolderItem(db, bookmarkItem) {
item.title = "";
}
let description = await getAnno(db, bookmarkItem.guid,
BookmarkSyncUtils.DESCRIPTION_ANNO);
if (description) {
item.description = description;
}
let childGuids = await fetchChildGuids(db, bookmarkItem.guid);
item.childRecordIds = childGuids.map(guid =>
BookmarkSyncUtils.guidToRecordId(guid)
@ -2091,7 +2047,7 @@ async function fetchFolderItem(db, bookmarkItem) {
}
// Creates and returns a Sync bookmark object containing the livemark's
// description, children (none), feed URI, and site URI.
// children (none), feed URI, and site URI.
async function fetchLivemarkItem(db, bookmarkItem) {
let item = await placesBookmarkToSyncBookmark(db, bookmarkItem);
@ -2099,12 +2055,6 @@ async function fetchLivemarkItem(db, bookmarkItem) {
item.title = "";
}
let description = await getAnno(db, bookmarkItem.guid,
BookmarkSyncUtils.DESCRIPTION_ANNO);
if (description) {
item.description = description;
}
let feedAnno = await getAnno(db, bookmarkItem.guid,
PlacesUtils.LMANNO_FEEDURI);
item.feed = new URL(feedAnno);
@ -2123,12 +2073,6 @@ async function fetchLivemarkItem(db, bookmarkItem) {
async function fetchQueryItem(db, bookmarkItem) {
let item = await placesBookmarkToSyncBookmark(db, bookmarkItem);
let description = await getAnno(db, bookmarkItem.guid,
BookmarkSyncUtils.DESCRIPTION_ANNO);
if (description) {
item.description = description;
}
let params = new URLSearchParams(bookmarkItem.url.pathname);
let tags = params.getAll("tag");
if (tags.length == 1) {

View File

@ -284,7 +284,6 @@ const SYNC_BOOKMARK_VALIDATORS = Object.freeze({
return v;
},
keyword: simpleValidateFunc(v => v === null || typeof v == "string"),
description: simpleValidateFunc(v => v === null || typeof v == "string"),
dateAdded: simpleValidateFunc(v => typeof v === "number"
&& v > PlacesSyncUtils.bookmarks.EARLIEST_BOOKMARK_TIMESTAMP),
feed: v => v === null ? v : BOOKMARK_VALIDATORS.url(v),

View File

@ -112,7 +112,6 @@ XPCOMUtils.defineLazyGetter(this, "LocalItemsSQLFragment", () => `
// 1375896).
const DB_URL_LENGTH_MAX = 65536;
const DB_TITLE_LENGTH_MAX = 4096;
const DB_DESCRIPTION_LENGTH_MAX = 256;
const SQLITE_MAX_VARIABLE_NUMBER = 999;
@ -131,9 +130,9 @@ function yieldingIterator(collection) {
* It is persistent.
*
* The mirror schema is a hybrid of how Sync and Places represent bookmarks.
* The `items` table contains item attributes (title, kind, description,
* URL, etc.), while the `structure` table stores parent-child relationships and
* position. This is similar to how iOS encodes "value" and "structure" state,
* The `items` table contains item attributes (title, kind, URL, etc.), while
* the `structure` table stores parent-child relationships and position.
* This is similar to how iOS encodes "value" and "structure" state,
* though we handle these differently when merging. See `BookmarkMerger` for
* details.
*
@ -671,21 +670,19 @@ class SyncedBookmarksMirror {
let dateAdded = determineDateAdded(record);
let title = validateTitle(record.title);
let keyword = validateKeyword(record.keyword);
let description = validateDescription(record.description);
await this.db.executeCached(`
REPLACE INTO items(guid, serverModified, needsMerge, kind,
dateAdded, title, keyword,
urlId, description)
urlId)
VALUES(:guid, :serverModified, :needsMerge, :kind,
:dateAdded, NULLIF(:title, ""), :keyword,
(SELECT id FROM urls
WHERE hash = hash(:url) AND
url = :url),
:description)`,
url = :url))`,
{ guid, serverModified, needsMerge,
kind: SyncedBookmarksMirror.KIND.BOOKMARK, dateAdded, title, keyword,
url: url.href, description });
url: url.href });
let tags = record.tags;
if (tags && Array.isArray(tags)) {
@ -745,23 +742,21 @@ class SyncedBookmarksMirror {
let serverModified = determineServerModified(record);
let dateAdded = determineDateAdded(record);
let title = validateTitle(record.title);
let description = validateDescription(record.description);
let smartBookmarkName = typeof record.queryId == "string" ?
record.queryId : null;
await this.db.executeCached(`
REPLACE INTO items(guid, serverModified, needsMerge, kind,
dateAdded, title, urlId, description,
smartBookmarkName)
dateAdded, title, urlId, smartBookmarkName)
VALUES(:guid, :serverModified, :needsMerge, :kind,
:dateAdded, NULLIF(:title, ""),
(SELECT id FROM urls
WHERE hash = hash(:url) AND
url = :url),
:description, :smartBookmarkName)`,
:smartBookmarkName)`,
{ guid, serverModified, needsMerge,
kind: SyncedBookmarksMirror.KIND.QUERY, dateAdded, title,
url: url.href, description, smartBookmarkName });
url: url.href, smartBookmarkName });
}
async storeRemoteFolder(record, { needsMerge }) {
@ -778,16 +773,14 @@ class SyncedBookmarksMirror {
let serverModified = determineServerModified(record);
let dateAdded = determineDateAdded(record);
let title = validateTitle(record.title);
let description = validateDescription(record.description);
await this.db.executeCached(`
REPLACE INTO items(guid, serverModified, needsMerge, kind,
dateAdded, title, description)
dateAdded, title)
VALUES(:guid, :serverModified, :needsMerge, :kind,
:dateAdded, NULLIF(:title, ""),
:description)`,
:dateAdded, NULLIF(:title, ""))`,
{ guid, serverModified, needsMerge, kind: SyncedBookmarksMirror.KIND.FOLDER,
dateAdded, title, description });
dateAdded, title });
let children = record.children;
if (children && Array.isArray(children)) {
@ -845,17 +838,16 @@ class SyncedBookmarksMirror {
let serverModified = determineServerModified(record);
let dateAdded = determineDateAdded(record);
let title = validateTitle(record.title);
let description = validateDescription(record.description);
let siteURL = validateURL(record.siteUri);
await this.db.executeCached(`
REPLACE INTO items(guid, serverModified, needsMerge, kind, dateAdded,
title, description, feedURL, siteURL)
title, feedURL, siteURL)
VALUES(:guid, :serverModified, :needsMerge, :kind, :dateAdded,
NULLIF(:title, ""), :description, :feedURL, :siteURL)`,
NULLIF(:title, ""), :feedURL, :siteURL)`,
{ guid, serverModified, needsMerge,
kind: SyncedBookmarksMirror.KIND.LIVEMARK,
dateAdded, title, description, feedURL: feedURL.href,
dateAdded, title, feedURL: feedURL.href,
siteURL: siteURL ? siteURL.href : null });
}
@ -1572,7 +1564,7 @@ class SyncedBookmarksMirror {
${LocalItemsSQLFragment}
INSERT INTO itemsToUpload(id, guid, syncChangeCounter, parentGuid,
parentTitle, dateAdded, type, title, isQuery,
url, tags, description,
url, tags,
smartBookmarkName, keyword, feedURL, siteURL,
position, tagFolderName)
SELECT s.id, s.guid, s.syncChangeCounter, s.parentGuid, s.parentTitle,
@ -1585,11 +1577,6 @@ class SyncedBookmarksMirror {
WHERE s.type = :bookmarkType AND
r.guid = :tagsGuid AND
e.fk = h.id),
(SELECT a.content FROM moz_items_annos a
JOIN moz_anno_attributes n ON n.id = a.anno_attribute_id
WHERE s.type IN (:bookmarkType, :folderType) AND
a.item_id = s.id AND
n.name = :descriptionAnno),
(SELECT a.content FROM moz_items_annos a
JOIN moz_anno_attributes n ON n.id = a.anno_attribute_id
WHERE a.item_id = s.id AND
@ -1615,7 +1602,6 @@ class SyncedBookmarksMirror {
w.id NOT NULL`,
{ bookmarkType: PlacesUtils.bookmarks.TYPE_BOOKMARK,
tagsGuid: PlacesUtils.bookmarks.tagsGuid,
descriptionAnno: PlacesSyncUtils.bookmarks.DESCRIPTION_ANNO,
smartBookmarkAnno: PlacesSyncUtils.bookmarks.SMART_BOOKMARKS_ANNO,
folderType: PlacesUtils.bookmarks.TYPE_FOLDER,
feedURLAnno: PlacesUtils.LMANNO_FEEDURI,
@ -1666,7 +1652,7 @@ class SyncedBookmarksMirror {
SELECT id, syncChangeCounter, guid, isDeleted, type, isQuery,
smartBookmarkName, tagFolderName,
keyword, tags, url, IFNULL(title, "") AS title,
description, feedURL, siteURL, position, parentGuid,
feedURL, siteURL, position, parentGuid,
IFNULL(parentTitle, "") AS parentTitle, dateAdded
FROM itemsToUpload`);
@ -1717,10 +1703,6 @@ class SyncedBookmarksMirror {
// folderName should never be an empty string or null
folderName: row.getResultByName("tagFolderName") || undefined,
};
let description = row.getResultByName("description");
if (description) {
queryCleartext.description = description;
}
changeRecords[recordId] = new BookmarkChangeRecord(
syncChangeCounter, queryCleartext);
continue;
@ -1736,10 +1718,6 @@ class SyncedBookmarksMirror {
bmkUri: row.getResultByName("url"),
title: row.getResultByName("title"),
};
let description = row.getResultByName("description");
if (description) {
bookmarkCleartext.description = description;
}
let keyword = row.getResultByName("keyword");
if (keyword) {
bookmarkCleartext.keyword = keyword;
@ -1768,10 +1746,6 @@ class SyncedBookmarksMirror {
title: row.getResultByName("title"),
feedUri: feedURLHref,
};
let description = row.getResultByName("description");
if (description) {
livemarkCleartext.description = description;
}
let siteURLHref = row.getResultByName("siteURL");
if (siteURLHref) {
livemarkCleartext.siteUri = siteURLHref;
@ -1790,10 +1764,6 @@ class SyncedBookmarksMirror {
dateAdded: row.getResultByName("dateAdded") || undefined,
title: row.getResultByName("title"),
};
let description = row.getResultByName("description");
if (description) {
folderCleartext.description = description;
}
let localId = row.getResultByName("id");
let childRecordIds = childRecordIdsByLocalParentId.get(localId);
folderCleartext.children = childRecordIds || [];
@ -1961,8 +1931,8 @@ async function initializeMirrorDatabase(db) {
value NOT NULL
)`);
// Note: loadInSidebar is not used as of Firefox 63, but remains to avoid
// rebuilding the database if the user happens to downgrade.
// Note: description and loadInSidebar are not used as of Firefox 63, but
// remain to avoid rebuilding the database if the user happens to downgrade.
await db.execute(`CREATE TABLE mirror.items(
id INTEGER PRIMARY KEY,
guid TEXT UNIQUE NOT NULL,
@ -2077,10 +2047,6 @@ async function initializeTempMirrorEntities(db) {
// We use this table to build SQL fragments for the `insertNewLocalItems` and
// `updateExistingLocalItems` triggers below.
const syncedAnnoTriggers = [{
annoName: PlacesSyncUtils.bookmarks.DESCRIPTION_ANNO,
columnName: "newDescription",
type: PlacesUtils.annotations.TYPE_STRING,
}, {
annoName: PlacesSyncUtils.bookmarks.SMART_BOOKMARKS_ANNO,
columnName: "newSmartBookmarkName",
type: PlacesUtils.annotations.TYPE_STRING,
@ -2187,7 +2153,6 @@ async function initializeTempMirrorEntities(db) {
oldGuid, newGuid, newType,
newDateAddedMicroseconds, newTitle,
oldPlaceId, newPlaceId, newKeyword,
newDescription,
newSmartBookmarkName, newFeedURL,
newSiteURL) AS
SELECT b.id, v.id, r.valueState = ${BookmarkMergeState.TYPE.REMOTE},
@ -2205,7 +2170,7 @@ async function initializeTempMirrorEntities(db) {
"v.dateAdded" is in milliseconds. */
(CASE WHEN b.dateAdded / 1000 < v.dateAdded THEN b.dateAdded
ELSE v.dateAdded * 1000 END),
v.title, h.id, u.newPlaceId, v.keyword, v.description,
v.title, h.id, u.newPlaceId, v.keyword,
v.smartBookmarkName, v.feedURL, v.siteURL
FROM items v
JOIN mergeStates r ON r.mergedGuid = v.guid
@ -2683,7 +2648,6 @@ async function initializeTempMirrorEntities(db) {
isQuery BOOLEAN NOT NULL DEFAULT 0,
url TEXT,
tags TEXT,
description TEXT,
smartBookmarkName TEXT,
tagFolderName TEXT,
keyword TEXT,
@ -2748,13 +2712,6 @@ function validateURL(rawURL) {
return url;
}
function validateDescription(rawDescription) {
if (typeof rawDescription != "string" || !rawDescription) {
return null;
}
return rawDescription.slice(0, DB_DESCRIPTION_LENGTH_MAX);
}
function validateKeyword(rawKeyword) {
if (typeof rawKeyword != "string") {
return null;

View File

@ -135,7 +135,6 @@ async function fetchLocalTree(rootGuid) {
let itemInfo = { guid, index, title, type };
if (node.annos) {
let syncableAnnos = node.annos.filter(anno => [
PlacesSyncUtils.bookmarks.DESCRIPTION_ANNO,
PlacesSyncUtils.bookmarks.SMART_BOOKMARKS_ANNO,
PlacesUtils.LMANNO_FEEDURI,
PlacesUtils.LMANNO_SITEURI,

View File

@ -5,7 +5,6 @@ ChromeUtils.defineModuleGetter(this, "Preferences",
"resource://gre/modules/Preferences.jsm");
Cu.importGlobalProperties(["URLSearchParams"]);
const DESCRIPTION_ANNO = "bookmarkProperties/description";
const SYNC_PARENT_ANNO = "sync/parent";
var makeGuid = PlacesUtils.history.makeGuid;
@ -970,45 +969,6 @@ add_task(async function test_conflicting_keywords() {
await PlacesSyncUtils.bookmarks.reset();
});
add_task(async function test_update_annos() {
let guids = await populateTree(PlacesUtils.bookmarks.menuGuid, {
kind: "folder",
title: "folder",
}, {
kind: "bookmark",
title: "bmk",
url: "https://example.com",
});
info("Add folder description");
{
let updatedItem = await PlacesSyncUtils.bookmarks.update({
recordId: guids.folder,
description: "Folder description",
});
equal(updatedItem.description, "Folder description",
"Should return new description");
let id = await recordIdToId(updatedItem.recordId);
equal(PlacesUtils.annotations.getItemAnnotation(id, DESCRIPTION_ANNO),
"Folder description", "Should set description anno");
}
info("Clear folder description");
{
let updatedItem = await PlacesSyncUtils.bookmarks.update({
recordId: guids.folder,
description: null,
});
ok(!updatedItem.description, "Should not return cleared description");
let id = await recordIdToId(updatedItem.recordId);
ok(!PlacesUtils.annotations.itemHasAnnotation(id, DESCRIPTION_ANNO),
"Should remove description anno");
}
await PlacesUtils.bookmarks.eraseEverything();
await PlacesSyncUtils.bookmarks.reset();
});
add_task(async function test_update_move_root() {
info("Move root to same parent");
{
@ -1437,42 +1397,6 @@ add_task(async function test_insert_keyword() {
await PlacesSyncUtils.bookmarks.reset();
});
add_task(async function test_insert_annos() {
info("Bookmark with description");
let descBmk = await PlacesSyncUtils.bookmarks.insert({
kind: "bookmark",
url: "https://example.com",
recordId: makeGuid(),
parentRecordId: "menu",
description: "Bookmark description",
});
{
equal(descBmk.description, "Bookmark description",
"Should return new bookmark description");
let id = await recordIdToId(descBmk.recordId);
equal(PlacesUtils.annotations.getItemAnnotation(id, DESCRIPTION_ANNO),
"Bookmark description", "Should set new bookmark description");
}
info("Folder with description");
let descFolder = await PlacesSyncUtils.bookmarks.insert({
kind: "folder",
recordId: makeGuid(),
parentRecordId: "menu",
description: "Folder description",
});
{
equal(descFolder.description, "Folder description",
"Should return new folder description");
let id = await recordIdToId(descFolder.recordId);
equal(PlacesUtils.annotations.getItemAnnotation(id, DESCRIPTION_ANNO),
"Folder description", "Should set new folder description");
}
await PlacesUtils.bookmarks.eraseEverything();
await PlacesSyncUtils.bookmarks.reset();
});
add_task(async function test_insert_tag_query() {
info("Use the public tagging API to ensure we added the tag correctly");
await PlacesUtils.bookmarks.insert({
@ -1759,14 +1683,12 @@ add_task(async function test_fetch() {
recordId: makeGuid(),
parentRecordId: "menu",
kind: "folder",
description: "Folder description",
});
let bmk = await PlacesSyncUtils.bookmarks.insert({
recordId: makeGuid(),
parentRecordId: "menu",
kind: "bookmark",
url: "https://example.com",
description: "Bookmark description",
tags: ["taggy"],
});
let folderBmk = await PlacesSyncUtils.bookmarks.insert({
@ -1798,32 +1720,30 @@ add_task(async function test_fetch() {
title: "Bookmarks toolbar query",
});
info("Fetch empty folder with description");
info("Fetch empty folder");
{
let item = await PlacesSyncUtils.bookmarks.fetch(folder.recordId);
deepEqual(item, {
recordId: folder.recordId,
kind: "folder",
parentRecordId: "menu",
description: "Folder description",
childRecordIds: [folderBmk.recordId, folderSep.recordId],
parentTitle: "menu",
dateAdded: item.dateAdded,
title: "",
}, "Should include description, children, title, and parent title in folder");
}, "Should include children, title, and parent title in folder");
}
info("Fetch bookmark with description and tags");
info("Fetch bookmark with tags");
{
let item = await PlacesSyncUtils.bookmarks.fetch(bmk.recordId);
deepEqual(Object.keys(item).sort(), ["recordId", "kind", "parentRecordId",
"url", "tags", "description", "parentTitle", "title", "dateAdded"].sort(),
"url", "tags", "parentTitle", "title", "dateAdded"].sort(),
"Should include bookmark-specific properties");
equal(item.recordId, bmk.recordId, "Sync ID should match");
equal(item.url.href, "https://example.com/", "Should return URL");
equal(item.parentRecordId, "menu", "Should return parent sync ID");
deepEqual(item.tags, ["taggy"], "Should return tags");
equal(item.description, "Bookmark description", "Should return bookmark description");
equal(item.parentTitle, "menu", "Should return parent title");
strictEqual(item.title, "", "Should return empty title");
}
@ -1880,15 +1800,12 @@ add_task(async function test_fetch_livemark() {
siteURI: uri(site),
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
});
PlacesUtils.annotations.setItemAnnotation(livemark.id, DESCRIPTION_ANNO,
"Livemark description", 0, PlacesUtils.annotations.EXPIRE_NEVER);
info("Fetch livemark");
let item = await PlacesSyncUtils.bookmarks.fetch(livemark.guid);
deepEqual(Object.keys(item).sort(), ["recordId", "kind", "parentRecordId",
"description", "feed", "site", "parentTitle", "title", "dateAdded"].sort(),
"feed", "site", "parentTitle", "title", "dateAdded"].sort(),
"Should include livemark-specific properties");
equal(item.description, "Livemark description", "Should return description");
equal(item.feed.href, site + "/feed/1", "Should return feed URL");
equal(item.site.href, site + "/", "Should return site URL");
strictEqual(item.title, "", "Should include livemark title even if empty");

View File

@ -1,5 +1,3 @@
const DESCRIPTION_ANNO = "bookmarkProperties/description";
var tagData = [
{ uri: uri("http://slint.us"), tags: ["indie", "kentucky", "music"] },
{ uri: uri("http://en.wikipedia.org/wiki/Diplodocus"), tags: ["dinosaur", "dj", "rad word"] }
@ -93,10 +91,6 @@ async function testMenuBookmarks() {
Assert.equal(PlacesUtils.asQuery(folderNode).hasChildren, true);
Assert.equal("folder test comment",
PlacesUtils.annotations.getItemAnnotation(folderNode.itemId,
DESCRIPTION_ANNO));
// open test folder, and test the children
folderNode.containerOpen = true;
Assert.equal(folderNode.childCount, 1);
@ -112,9 +106,6 @@ async function testMenuBookmarks() {
Assert.equal("ISO-8859-1",
(await PlacesUtils.getCharsetForURI(NetUtil.newURI(bookmarkNode.uri))));
Assert.equal("item description",
PlacesUtils.annotations.getItemAnnotation(bookmarkNode.itemId,
DESCRIPTION_ANNO));
folderNode.containerOpen = false;
root.containerOpen = false;

View File

@ -4,12 +4,12 @@
"use strict";
const TEST_ANNOTATIONS = [{
name: "fake/annotation1",
name: PlacesUtils.LMANNO_FEEDURI,
value: "test",
flags: 0,
expires: Ci.nsIAnnotationService.EXPIRE_MONTHS,
}, {
name: "fake/annotation2",
name: PlacesUtils.LMANNO_SITEURI,
value: "test2",
flags: 0,
expires: Ci.nsIAnnotationService.EXPIRE_DAYS,

View File

@ -4,8 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const DESCRIPTION_ANNO = "bookmarkProperties/description";
// An object representing the contents of bookmarks.preplaces.html.
var test_bookmarks = {
menu: [
@ -33,12 +31,10 @@ var test_bookmarks = {
type: Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR
},
{ title: "test",
description: "folder test comment",
dateAdded: 1177541020000000,
lastModified: 1177541050000000,
children: [
{ title: "test post keyword",
description: "item description",
dateAdded: 1177375336000000,
lastModified: 1177375423000000,
keyword: "test",
@ -292,11 +288,6 @@ function checkItem(aExpected, aNode) {
case "title":
Assert.equal(aNode.title, aExpected.title);
break;
case "description":
Assert.equal(PlacesUtils.annotations
.getItemAnnotation(id, DESCRIPTION_ANNO),
aExpected.description);
break;
case "dateAdded":
Assert.equal(PlacesUtils.toPRTime(bookmark.dateAdded),
aExpected.dateAdded);

View File

@ -3,8 +3,6 @@
* if a malformed uri is found.
*/
const DESCRIPTION_ANNO = "bookmarkProperties/description";
const TEST_FAVICON_PAGE_URL = "http://en-US.www.mozilla.com/en-US/firefox/central/";
const TEST_FAVICON_DATA_SIZE = 580;
@ -64,9 +62,7 @@ var database_check = async function() {
});
Assert.equal(PlacesUtils.toPRTime(bookmark.dateAdded), 1177541020000000);
Assert.equal(PlacesUtils.toPRTime(bookmark.lastModified), 1177541050000000);
Assert.equal("folder test comment",
PlacesUtils.annotations.getItemAnnotation(folderNode.itemId,
DESCRIPTION_ANNO));
// open test folder, and test the children
PlacesUtils.asQuery(folderNode);
Assert.equal(folderNode.hasChildren, true);
@ -87,10 +83,6 @@ var database_check = async function() {
Assert.equal((await PlacesUtils.getCharsetForURI(NetUtil.newURI(bookmarkNode.uri))),
"ISO-8859-1");
Assert.equal("item description",
PlacesUtils.annotations.getItemAnnotation(bookmarkNode.itemId,
DESCRIPTION_ANNO));
// clean up
folderNode.containerOpen = false;
root.containerOpen = false;

View File

@ -4,8 +4,6 @@
ChromeUtils.import("resource://gre/modules/BookmarkJSONUtils.jsm");
const DESCRIPTION_ANNO = "bookmarkProperties/description";
// An object representing the contents of bookmarks.json.
var test_bookmarks = {
menu: [
@ -45,13 +43,11 @@ var test_bookmarks = {
{
guid: "OCyeUO5uu9FL",
title: "test",
description: "folder test comment",
dateAdded: 1177541020000000,
lastModified: 1177541050000000,
children: [
{ guid: "OCyeUO5uu9GX",
title: "test post keyword",
description: "item description",
dateAdded: 1177375336000000,
lastModified: 1177375423000000,
keyword: "test",
@ -185,10 +181,6 @@ async function checkItem(aExpected, aNode) {
case "title":
Assert.equal(aNode.title, aExpected.title);
break;
case "description":
Assert.equal(PlacesUtils.annotations.getItemAnnotation(
id, DESCRIPTION_ANNO), aExpected.description);
break;
case "dateAdded":
Assert.equal(PlacesUtils.toPRTime(bookmark.dateAdded),
aExpected.dateAdded);