Bug 1659736 - Move tracking of bookmark roots during IE migration later so the source is clearer. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D88059
This commit is contained in:
Jared Wein 2020-08-27 20:45:23 +00:00
Родитель eeaa6d826f
Коммит f2e65e077b
3 изменённых файлов: 30 добавлений и 8 удалений

Просмотреть файл

@ -415,8 +415,6 @@ Bookmarks.prototype = {
migrate: function B_migrate(aCallback) {
return (async () => {
// Import to the bookmarks menu.
this._histogramBookmarkRoots |=
MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_MENU;
let folderGuid = PlacesUtils.bookmarks.menuGuid;
await this._migrateFolder(this._favoritesFolder, folderGuid);
Services.telemetry
@ -441,6 +439,15 @@ Bookmarks.prototype = {
if (!bookmarks.length) {
return;
}
if (aDestFolderGuid == PlacesUtils.bookmarks.menuGuid) {
this._histogramBookmarkRoots |=
MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_MENU;
} else if (aDestFolderGuid == PlacesUtils.bookmarks.toolbarGuid) {
this._histogramBookmarkRoots |=
MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_TOOLBAR;
}
if (
!MigrationUtils.isStartupMigration &&
PlacesUtils.getChildCountForFolder(aDestFolderGuid) >
@ -474,8 +481,6 @@ Bookmarks.prototype = {
entry.parent.equals(this._favoritesFolder);
if (isBookmarksFolder && entry.isReadable()) {
// Import to the bookmarks toolbar.
this._histogramBookmarkRoots |=
MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_TOOLBAR;
let folderGuid = PlacesUtils.bookmarks.toolbarGuid;
await this._migrateFolder(entry, folderGuid);
PlacesUIUtils.maybeToggleBookmarkToolbarVisibilityAfterMigration();

Просмотреть файл

@ -13,10 +13,18 @@ add_task(async function() {
// on the actual favorites stored on the local machine's IE favorites database.
// As such, we can't assert that bookmarks were migrated to both the bookmarks
// menu and the bookmarks toolbar.
let bookmarkRoots = 0;
let itemCount = 0;
let listener = events => {
for (let event of events) {
if (event.itemType == PlacesUtils.bookmarks.TYPE_BOOKMARK) {
if (event.parentGuid == PlacesUtils.bookmarks.toolbarGuid) {
bookmarkRoots |=
MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_TOOLBAR;
} else if (event.parentGuid == PlacesUtils.bookmarks.menuGuid) {
bookmarkRoots |= MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_MENU;
}
info("bookmark added: " + event.parentGuid);
itemCount++;
}
}
@ -45,6 +53,17 @@ add_task(async function() {
itemCount,
"Ensure telemetry matches actual number of imported items."
);
await TestUtils.waitForCondition(() => {
let snapshot = Services.telemetry.getSnapshotForKeyedHistograms(
"main",
false
).parent.FX_MIGRATION_BOOKMARKS_ROOTS;
if (!snapshot || !snapshot.ie) {
return false;
}
info(`Expected ${bookmarkRoots}, got ${snapshot.ie.sum}`);
return snapshot.ie.sum == bookmarkRoots;
}, "Wait until telemetry is updated");
// Check the bookmarks have been imported to all the expected parents.
Assert.ok(observerNotified, "The observer should be notified upon migration");

Просмотреть файл

@ -90,10 +90,8 @@ add_task(async function() {
if (!snapshot || !snapshot.safari) {
return false;
}
let sum = arr => Object.values(arr).reduce((a, b) => a + b, 0);
let sumOfValues = sum(snapshot.safari.values);
info(`Expected ${bookmarkRoots}, got ${sumOfValues}`);
return sumOfValues == bookmarkRoots;
info(`Expected ${bookmarkRoots}, got ${snapshot.safari.sum}`);
return snapshot.safari.sum == bookmarkRoots;
},
"Wait until telemetry is updated"
);