зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 4b75dda634bc (bug 1473382)for presumed ES lint failures on request of lin
This commit is contained in:
Родитель
f560e183d5
Коммит
d4ce7cc9fe
|
@ -1482,24 +1482,16 @@ class SyncedBookmarksMirror {
|
|||
|
||||
MirrorLog.trace("Recording observer notifications for changed annos");
|
||||
let annoRows = await this.db.execute(`
|
||||
SELECT b.id, b.guid, b.lastModified, b.type, p.id AS parentId,
|
||||
p.guid AS parentGuid, c.annoName, c.wasRemoved
|
||||
FROM annosChanged c
|
||||
JOIN moz_bookmarks b ON b.id = c.itemId
|
||||
JOIN moz_bookmarks p ON p.id = b.parent
|
||||
LEFT JOIN moz_places h ON h.id = b.fk
|
||||
ORDER BY p.id, b.position, c.wasRemoved <> 1`);
|
||||
SELECT itemId, annoName, wasRemoved FROM annosChanged
|
||||
ORDER BY itemId`);
|
||||
for await (let row of yieldingIterator(annoRows)) {
|
||||
observersToNotify.noteAnnoChanged({
|
||||
id: row.getResultByName("id"),
|
||||
name: row.getResultByName("annoName"),
|
||||
wasRemoved: !!row.getResultByName("wasRemoved"),
|
||||
guid: row.getResultByName("guid"),
|
||||
lastModified: row.getResultByName("lastModified"),
|
||||
type: row.getResultByName("type"),
|
||||
parentId: row.getResultByName("parentId"),
|
||||
parentGuid: row.getResultByName("parentGuid"),
|
||||
});
|
||||
let id = row.getResultByName("itemId");
|
||||
let name = row.getResultByName("annoName");
|
||||
if (row.getResultByName("wasRemoved")) {
|
||||
observersToNotify.noteAnnoRemoved(id, name);
|
||||
} else {
|
||||
observersToNotify.noteAnnoSet(id, name);
|
||||
}
|
||||
}
|
||||
|
||||
MirrorLog.trace("Recording notifications for changed keywords");
|
||||
|
@ -4443,6 +4435,7 @@ class BookmarkObserverRecorder {
|
|||
this.bookmarkObserverNotifications = [];
|
||||
this.annoObserverNotifications = [];
|
||||
this.shouldInvalidateKeywords = false;
|
||||
this.shouldInvalidateLivemarks = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4456,7 +4449,9 @@ class BookmarkObserverRecorder {
|
|||
}
|
||||
await this.notifyBookmarkObservers();
|
||||
await this.notifyAnnoObservers();
|
||||
await PlacesUtils.livemarks.invalidateCachedLivemarks();
|
||||
if (this.shouldInvalidateLivemarks) {
|
||||
await PlacesUtils.livemarks.invalidateCachedLivemarks();
|
||||
}
|
||||
await this.updateFrecencies();
|
||||
}
|
||||
|
||||
|
@ -4533,30 +4528,23 @@ class BookmarkObserverRecorder {
|
|||
});
|
||||
}
|
||||
|
||||
noteAnnoChanged(info) {
|
||||
if (info.name != PlacesUtils.LMANNO_FEEDURI &&
|
||||
info.name != PlacesUtils.LMANNO_SITEURI) {
|
||||
throw new TypeError("Can't record change for unsupported anno");
|
||||
noteAnnoSet(id, name) {
|
||||
if (isLivemarkAnno(name)) {
|
||||
this.shouldInvalidateLivemarks = true;
|
||||
}
|
||||
if (info.wasRemoved) {
|
||||
this.annoObserverNotifications.push({
|
||||
name: "onItemAnnotationRemoved",
|
||||
args: [info.id, info.name, PlacesUtils.bookmarks.SOURCES.SYNC],
|
||||
});
|
||||
} else {
|
||||
this.annoObserverNotifications.push({
|
||||
name: "onItemAnnotationSet",
|
||||
args: [info.id, info.name, PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
/* dontUpdateLastModified */ true],
|
||||
});
|
||||
this.annoObserverNotifications.push({
|
||||
name: "onItemAnnotationSet",
|
||||
args: [id, name, PlacesUtils.bookmarks.SOURCES.SYNC],
|
||||
});
|
||||
}
|
||||
|
||||
noteAnnoRemoved(id, name) {
|
||||
if (isLivemarkAnno(name)) {
|
||||
this.shouldInvalidateLivemarks = true;
|
||||
}
|
||||
this.bookmarkObserverNotifications.push({
|
||||
name: "onItemChanged",
|
||||
isTagging: false,
|
||||
args: [info.id, info.name, /* isAnnotationProperty */ true,
|
||||
/* newValue */ "", info.lastModified, info.type, info.parentId,
|
||||
info.guid, info.parentGuid, /* oldValue */ "",
|
||||
PlacesUtils.bookmarks.SOURCES.SYNC],
|
||||
this.annoObserverNotifications.push({
|
||||
name: "onItemAnnotationRemoved",
|
||||
args: [id, name, PlacesUtils.bookmarks.SOURCES.SYNC],
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -4595,6 +4583,11 @@ class BookmarkObserverRecorder {
|
|||
}
|
||||
}
|
||||
|
||||
function isLivemarkAnno(name) {
|
||||
return name == PlacesUtils.LMANNO_FEEDURI ||
|
||||
name == PlacesUtils.LMANNO_SITEURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds Sync metadata and the cleartext for a locally changed record. The
|
||||
* bookmarks engine inflates a Sync record from the cleartext, and updates the
|
||||
|
|
|
@ -258,30 +258,12 @@ BookmarkObserver.prototype = {
|
|||
});
|
||||
},
|
||||
|
||||
onPageAnnotationSet() {},
|
||||
onItemAnnotationSet(itemId, name, source, dontUpdateLastModified) {
|
||||
this.notifications.push({
|
||||
name: "onItemAnnotationSet",
|
||||
params: { itemId, name, source, dontUpdateLastModified },
|
||||
})
|
||||
},
|
||||
|
||||
onPageAnnotationRemoved() {},
|
||||
onItemAnnotationRemoved(itemId, name, source) {
|
||||
this.notifications.push({
|
||||
name: "onItemAnnotationRemoved",
|
||||
params: { itemId, name, source },
|
||||
});
|
||||
},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI([
|
||||
Ci.nsINavBookmarkObserver,
|
||||
Ci.nsIAnnotationObserver,
|
||||
]),
|
||||
|
||||
check(expectedNotifications) {
|
||||
PlacesUtils.bookmarks.removeObserver(this);
|
||||
PlacesUtils.annotations.removeObserver(this);
|
||||
if (!ObjectUtils.deepEqual(this.notifications, expectedNotifications)) {
|
||||
info(`Expected notifications: ${JSON.stringify(expectedNotifications)}`);
|
||||
info(`Actual notifications: ${JSON.stringify(this.notifications)}`);
|
||||
|
@ -296,7 +278,6 @@ BookmarkObserver.prototype = {
|
|||
function expectBookmarkChangeNotifications(options) {
|
||||
let observer = new BookmarkObserver(options);
|
||||
PlacesUtils.bookmarks.addObserver(observer);
|
||||
PlacesUtils.annotations.addObserver(observer);
|
||||
return observer;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,6 @@ add_task(async function test_livemarks() {
|
|||
}]));
|
||||
|
||||
info("Apply remote");
|
||||
let observer = expectBookmarkChangeNotifications();
|
||||
let changesToUpload = await buf.apply();
|
||||
deepEqual(await buf.fetchUnmergedGuids(), [], "Should merge all items");
|
||||
|
||||
|
@ -234,169 +233,20 @@ add_task(async function test_livemarks() {
|
|||
}],
|
||||
}, "Should apply and dedupe livemarks");
|
||||
|
||||
let livemarkA = await PlacesUtils.livemarks.getLivemark({
|
||||
guid: "livemarkAAAA",
|
||||
});
|
||||
let livemarkB = await PlacesUtils.livemarks.getLivemark({
|
||||
guid: "livemarkB111",
|
||||
});
|
||||
let livemarkC = await PlacesUtils.livemarks.getLivemark({
|
||||
let cLivemark = await PlacesUtils.livemarks.getLivemark({
|
||||
guid: "livemarkCCCC",
|
||||
});
|
||||
let livemarkE = await PlacesUtils.livemarks.getLivemark({
|
||||
guid: "livemarkEEEE",
|
||||
});
|
||||
equal(cLivemark.title, "C (remote)", "Should set livemark C title");
|
||||
ok(cLivemark.feedURI.equals(Services.io.newURI(site + "/feed/c-remote")),
|
||||
"Should set livemark C feed URL");
|
||||
|
||||
observer.check([{
|
||||
name: "onItemChanged",
|
||||
params: { itemId: livemarkB.id, property: "guid", isAnnoProperty: false,
|
||||
newValue: "livemarkB111", parentId: PlacesUtils.toolbarFolderId,
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER, guid: "livemarkB111",
|
||||
parentGuid: "toolbar_____", oldValue: "livemarkBBBB",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
}, {
|
||||
name: "onItemAdded",
|
||||
params: { itemId: livemarkC.id, parentId: PlacesUtils.toolbarFolderId,
|
||||
index: 0, type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
urlHref: null, title: "C (remote)", guid: "livemarkCCCC",
|
||||
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
}, {
|
||||
name: "onItemAdded",
|
||||
params: { itemId: livemarkE.id,
|
||||
parentId: PlacesUtils.unfiledBookmarksFolderId,
|
||||
index: 0, type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
urlHref: null, title: "E", guid: "livemarkEEEE",
|
||||
parentGuid: "unfiled_____",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
}, {
|
||||
name: "onItemMoved",
|
||||
params: { itemId: livemarkB.id, oldParentId: PlacesUtils.toolbarFolderId,
|
||||
oldIndex: 0, newParentId: PlacesUtils.toolbarFolderId,
|
||||
newIndex: 1, type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
guid: "livemarkB111", uri: null,
|
||||
oldParentGuid: PlacesUtils.bookmarks.toolbarGuid,
|
||||
newParentGuid: PlacesUtils.bookmarks.toolbarGuid,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
}, {
|
||||
name: "onItemChanged",
|
||||
params: { itemId: livemarkA.id, property: "title", isAnnoProperty: false,
|
||||
newValue: "A (remote)", type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
parentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
guid: "livemarkAAAA",
|
||||
parentGuid: PlacesUtils.bookmarks.menuGuid, oldValue: "A",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
}, {
|
||||
name: "onItemChanged",
|
||||
params: { itemId: livemarkA.id, property: PlacesUtils.LMANNO_FEEDURI,
|
||||
isAnnoProperty: true, newValue: "",
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
parentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
guid: "livemarkAAAA",
|
||||
parentGuid: PlacesUtils.bookmarks.menuGuid, oldValue: "",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
}, {
|
||||
name: "onItemChanged",
|
||||
params: { itemId: livemarkA.id, property: PlacesUtils.LMANNO_FEEDURI,
|
||||
isAnnoProperty: true, newValue: "",
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
parentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
guid: "livemarkAAAA",
|
||||
parentGuid: PlacesUtils.bookmarks.menuGuid, oldValue: "",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
}, {
|
||||
name: "onItemChanged",
|
||||
params: { itemId: livemarkC.id, property: "livemark/feedURI",
|
||||
isAnnoProperty: true, newValue: "",
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
parentId: PlacesUtils.toolbarFolderId, guid: "livemarkCCCC",
|
||||
parentGuid: PlacesUtils.bookmarks.toolbarGuid, oldValue: "",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
}, {
|
||||
name: "onItemChanged",
|
||||
params: { itemId: livemarkB.id, property: PlacesUtils.LMANNO_FEEDURI,
|
||||
isAnnoProperty: true, newValue: "",
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
parentId: PlacesUtils.toolbarFolderId,
|
||||
guid: "livemarkB111",
|
||||
parentGuid: PlacesUtils.bookmarks.toolbarGuid, oldValue: "",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
}, {
|
||||
name: "onItemChanged",
|
||||
params: { itemId: livemarkB.id, property: PlacesUtils.LMANNO_SITEURI,
|
||||
isAnnoProperty: true, newValue: "",
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
parentId: PlacesUtils.toolbarFolderId,
|
||||
guid: "livemarkB111",
|
||||
parentGuid: PlacesUtils.bookmarks.toolbarGuid, oldValue: "",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
}, {
|
||||
name: "onItemChanged",
|
||||
params: { itemId: livemarkB.id, property: PlacesUtils.LMANNO_FEEDURI,
|
||||
isAnnoProperty: true, newValue: "",
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
parentId: PlacesUtils.toolbarFolderId,
|
||||
guid: "livemarkB111",
|
||||
parentGuid: PlacesUtils.bookmarks.toolbarGuid, oldValue: "",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
}, {
|
||||
name: "onItemChanged",
|
||||
params: { itemId: livemarkE.id, property: PlacesUtils.LMANNO_FEEDURI,
|
||||
isAnnoProperty: true, newValue: "",
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
parentId: PlacesUtils.unfiledBookmarksFolderId,
|
||||
guid: "livemarkEEEE",
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
oldValue: "",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
}, {
|
||||
name: "onItemChanged",
|
||||
params: { itemId: livemarkE.id, property: PlacesUtils.LMANNO_SITEURI,
|
||||
isAnnoProperty: true, newValue: "",
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
parentId: PlacesUtils.unfiledBookmarksFolderId,
|
||||
guid: "livemarkEEEE",
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
oldValue: "",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
}, {
|
||||
name: "onItemAnnotationRemoved",
|
||||
params: { itemId: livemarkA.id, name: PlacesUtils.LMANNO_FEEDURI,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
}, {
|
||||
name: "onItemAnnotationSet",
|
||||
params: { itemId: livemarkA.id, name: PlacesUtils.LMANNO_FEEDURI,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
dontUpdateLastModified: true },
|
||||
}, {
|
||||
name: "onItemAnnotationSet",
|
||||
params: { itemId: livemarkC.id, name: PlacesUtils.LMANNO_FEEDURI,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
dontUpdateLastModified: true },
|
||||
}, {
|
||||
name: "onItemAnnotationRemoved",
|
||||
params: { itemId: livemarkB.id, name: PlacesUtils.LMANNO_FEEDURI,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
}, {
|
||||
name: "onItemAnnotationRemoved",
|
||||
params: { itemId: livemarkB.id, name: PlacesUtils.LMANNO_SITEURI,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC },
|
||||
}, {
|
||||
name: "onItemAnnotationSet",
|
||||
params: { itemId: livemarkB.id, name: PlacesUtils.LMANNO_FEEDURI,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
dontUpdateLastModified: true },
|
||||
}, {
|
||||
name: "onItemAnnotationSet",
|
||||
params: { itemId: livemarkE.id, name: PlacesUtils.LMANNO_FEEDURI,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
dontUpdateLastModified: true },
|
||||
}, {
|
||||
name: "onItemAnnotationSet",
|
||||
params: { itemId: livemarkE.id, name: PlacesUtils.LMANNO_SITEURI,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
dontUpdateLastModified: true },
|
||||
}]);
|
||||
let bLivemark = await PlacesUtils.livemarks.getLivemark({
|
||||
guid: "livemarkB111",
|
||||
});
|
||||
ok(bLivemark.feedURI.equals(Services.io.newURI(site + "/feed/b-remote")),
|
||||
"Should set deduped livemark B feed URL");
|
||||
strictEqual(bLivemark.siteURI, null,
|
||||
"Should remove deduped livemark B site URL");
|
||||
|
||||
await buf.finalize();
|
||||
} finally {
|
||||
|
|
Загрузка…
Ссылка в новой задаче