diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 553189a815fd..dd71b8d3ffc8 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -1805,12 +1805,6 @@ pref("dom.ipc.processPrelaunch.enabled", true); pref("browser.migrate.chrome.history.limit", 2000); pref("browser.migrate.chrome.history.maxAgeInDays", 180); -#ifdef EARLY_BETA_OR_EARLIER -pref("browser.migrate.showBookmarksToolbarAfterMigration", true); -#else -pref("browser.migrate.showBookmarksToolbarAfterMigration", false); -#endif - pref("extensions.pocket.api", "api.getpocket.com"); pref("extensions.pocket.enabled", true); pref("extensions.pocket.oAuthConsumerKey", "40249-e88c401e1b1f2242d9e441c4"); diff --git a/browser/components/BrowserGlue.jsm b/browser/components/BrowserGlue.jsm index ea2cdb699793..eb0ffd8492dd 100644 --- a/browser/components/BrowserGlue.jsm +++ b/browser/components/BrowserGlue.jsm @@ -23,6 +23,12 @@ ChromeUtils.defineModuleGetter( "resource://gre/modules/ActorManagerParent.jsm" ); +ChromeUtils.defineModuleGetter( + this, + "CustomizableUI", + "resource:///modules/CustomizableUI.jsm" +); + ChromeUtils.defineModuleGetter( this, "AboutNewTab", @@ -55,12 +61,6 @@ ChromeUtils.defineModuleGetter( "resource://featuregates/FeatureGate.jsm" ); -ChromeUtils.defineModuleGetter( - this, - "PlacesUIUtils", - "resource:///modules/PlacesUIUtils.jsm" -); - XPCOMUtils.defineLazyServiceGetter( this, "PushService", @@ -3028,7 +3028,7 @@ BrowserGlue.prototype = { // New profiles may have existing bookmarks (imported from another browser or // copied into the profile) and we want to show the bookmark toolbar for them // in some cases. - PlacesUIUtils.maybeToggleBookmarkToolbarVisibility(); + this._maybeToggleBookmarkToolbarVisibility(); } catch (ex) { Cu.reportError(ex); } @@ -3136,6 +3136,47 @@ BrowserGlue.prototype = { ); }, + /** + * Uncollapses PersonalToolbar if its collapsed status is not + * persisted, and user customized it or changed default bookmarks. + * + * If the user does not have a persisted value for the toolbar's + * "collapsed" attribute, try to determine whether it's customized. + */ + _maybeToggleBookmarkToolbarVisibility() { + const BROWSER_DOCURL = AppConstants.BROWSER_CHROME_URL; + const NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE = 3; + let xulStore = Services.xulStore; + + if (!xulStore.hasValue(BROWSER_DOCURL, "PersonalToolbar", "collapsed")) { + // We consider the toolbar customized if it has more than NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE + // children, or if it has a persisted currentset value. + let toolbarIsCustomized = xulStore.hasValue( + BROWSER_DOCURL, + "PersonalToolbar", + "currentset" + ); + let getToolbarFolderCount = () => { + let toolbarFolder = PlacesUtils.getFolderContents( + PlacesUtils.bookmarks.toolbarGuid + ).root; + let toolbarChildCount = toolbarFolder.childCount; + toolbarFolder.containerOpen = false; + return toolbarChildCount; + }; + + if ( + toolbarIsCustomized || + getToolbarFolderCount() > NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE + ) { + CustomizableUI.setToolbarVisibility( + CustomizableUI.AREA_BOOKMARKS, + true + ); + } + } + }, + _migrateXULStoreForDocument(fromURL, toURL) { Array.from(Services.xulStore.getIDsEnumerator(fromURL)).forEach(id => { Array.from(Services.xulStore.getAttributeEnumerator(fromURL, id)).forEach( diff --git a/browser/components/customizableui/CustomizableUI.jsm b/browser/components/customizableui/CustomizableUI.jsm index 8d0e43d694dc..517273b89c53 100644 --- a/browser/components/customizableui/CustomizableUI.jsm +++ b/browser/components/customizableui/CustomizableUI.jsm @@ -283,8 +283,6 @@ var CustomizableUIInternal = { ); SearchWidgetTracker.init(); - - Services.obs.addObserver(this, "browser-set-toolbar-visibility"); }, onEnabled(addon) { @@ -3365,13 +3363,6 @@ var CustomizableUIInternal = { } } }, - - observe(aSubject, aTopic, aData) { - if (aTopic == "browser-set-toolbar-visibility") { - let [toolbar, visibility] = JSON.parse(aData); - CustomizableUI.setToolbarVisibility(toolbar, visibility == "true"); - } - }, }; Object.freeze(CustomizableUIInternal); diff --git a/browser/components/migration/360seProfileMigrator.jsm b/browser/components/migration/360seProfileMigrator.jsm index 3ddc971fc6ef..1793dc65d44a 100644 --- a/browser/components/migration/360seProfileMigrator.jsm +++ b/browser/components/migration/360seProfileMigrator.jsm @@ -12,7 +12,6 @@ const { FileUtils } = ChromeUtils.import( "resource://gre/modules/FileUtils.jsm" ); const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm"); -const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { MigrationUtils, MigratorPrototype } = ChromeUtils.import( "resource:///modules/MigrationUtils.jsm" ); @@ -22,11 +21,6 @@ ChromeUtils.defineModuleGetter( "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm" ); -ChromeUtils.defineModuleGetter( - this, - "PlacesUIUtils", - "resource:///modules/PlacesUIUtils.jsm" -); ChromeUtils.defineModuleGetter( this, "Sqlite", @@ -144,7 +138,6 @@ Bookmarks.prototype = { path: this._file.path, }); - let histogramBookmarkRoots = 0; try { let rows = await connection.execute( `WITH RECURSIVE @@ -202,26 +195,15 @@ Bookmarks.prototype = { } if (toolbarBMs.length) { - histogramBookmarkRoots |= - MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_TOOLBAR; let parentGuid = PlacesUtils.bookmarks.toolbarGuid; - if ( - !MigrationUtils.isStartupMigration && - PlacesUtils.getChildCountForFolder( - PlacesUtils.bookmarks.toolbarGuid - ) > PlacesUIUtils.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE - ) { + if (!MigrationUtils.isStartupMigration) { parentGuid = await MigrationUtils.createImportedBookmarksFolder( "360se", parentGuid ); } await MigrationUtils.insertManyBookmarksWrapper(toolbarBMs, parentGuid); - PlacesUIUtils.maybeToggleBookmarkToolbarVisibilityAfterMigration(); } - Services.telemetry - .getKeyedHistogramById("FX_MIGRATION_BOOKMARKS_ROOTS") - .add("360se", histogramBookmarkRoots); })().then( () => aCallback(true), e => { diff --git a/browser/components/migration/ChromeProfileMigrator.jsm b/browser/components/migration/ChromeProfileMigrator.jsm index 416d06ead170..4343ed35de52 100644 --- a/browser/components/migration/ChromeProfileMigrator.jsm +++ b/browser/components/migration/ChromeProfileMigrator.jsm @@ -31,12 +31,6 @@ ChromeUtils.defineModuleGetter( "resource://gre/modules/PlacesUtils.jsm" ); -ChromeUtils.defineModuleGetter( - this, - "PlacesUIUtils", - "resource:///modules/PlacesUIUtils.jsm" -); - /** * Converts an array of chrome bookmark objects into one our own places code * understands. @@ -112,11 +106,7 @@ ChromeProfileMigrator.prototype.getResources = async function Chrome_getResource this.getBrowserKey() ).replace(/^source-name-/, ""); let possibleResourcePromises = [ - GetBookmarksResource( - profileFolder, - localePropertySuffix, - this.getBrowserKey() - ), + GetBookmarksResource(profileFolder, localePropertySuffix), GetHistoryResource(profileFolder), GetCookiesResource(profileFolder), ]; @@ -214,11 +204,7 @@ Object.defineProperty(ChromeProfileMigrator.prototype, "sourceLocked", { }, }); -async function GetBookmarksResource( - aProfileFolder, - aLocalePropertySuffix, - aBrowserKey -) { +async function GetBookmarksResource(aProfileFolder, aLocalePropertySuffix) { let bookmarksPath = OS.Path.join(aProfileFolder, "Bookmarks"); if (!(await OS.File.exists(bookmarksPath))) { return null; @@ -238,24 +224,16 @@ async function GetBookmarksResource( encoding: "UTF-8", }); let roots = JSON.parse(bookmarkJSON).roots; - let histogramBookmarkRoots = 0; // Importing bookmark bar items if (roots.bookmark_bar.children && roots.bookmark_bar.children.length) { // Toolbar - histogramBookmarkRoots |= - MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_TOOLBAR; let parentGuid = PlacesUtils.bookmarks.toolbarGuid; let bookmarks = convertBookmarks( roots.bookmark_bar.children, errorGatherer ); - if ( - !MigrationUtils.isStartupMigration && - PlacesUtils.getChildCountForFolder( - PlacesUtils.bookmarks.toolbarGuid - ) > PlacesUIUtils.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE - ) { + if (!MigrationUtils.isStartupMigration) { parentGuid = await MigrationUtils.createImportedBookmarksFolder( aLocalePropertySuffix, parentGuid @@ -265,21 +243,14 @@ async function GetBookmarksResource( bookmarks, parentGuid ); - PlacesUIUtils.maybeToggleBookmarkToolbarVisibilityAfterMigration(); } // Importing bookmark menu items if (roots.other.children && roots.other.children.length) { // Bookmark menu - histogramBookmarkRoots |= - MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_MENU; let parentGuid = PlacesUtils.bookmarks.menuGuid; let bookmarks = convertBookmarks(roots.other.children, errorGatherer); - if ( - !MigrationUtils.isStartupMigration && - PlacesUtils.getChildCountForFolder(PlacesUtils.bookmarks.menuGuid) > - PlacesUIUtils.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE - ) { + if (!MigrationUtils.isStartupMigration) { parentGuid = await MigrationUtils.createImportedBookmarksFolder( aLocalePropertySuffix, parentGuid @@ -293,9 +264,6 @@ async function GetBookmarksResource( if (gotErrors) { throw new Error("The migration included errors."); } - Services.telemetry - .getKeyedHistogramById("FX_MIGRATION_BOOKMARKS_ROOTS") - .add(aBrowserKey, histogramBookmarkRoots); })().then( () => aCallback(true), () => aCallback(false) diff --git a/browser/components/migration/EdgeProfileMigrator.jsm b/browser/components/migration/EdgeProfileMigrator.jsm index 3f138f2de82a..43cc1a1ecbe2 100644 --- a/browser/components/migration/EdgeProfileMigrator.jsm +++ b/browser/components/migration/EdgeProfileMigrator.jsm @@ -8,7 +8,6 @@ const { AppConstants } = ChromeUtils.import( "resource://gre/modules/AppConstants.jsm" ); const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm"); -const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { XPCOMUtils } = ChromeUtils.import( "resource://gre/modules/XPCOMUtils.jsm" ); @@ -23,11 +22,6 @@ ChromeUtils.defineModuleGetter( "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm" ); -ChromeUtils.defineModuleGetter( - this, - "PlacesUIUtils", - "resource:///modules/PlacesUIUtils.jsm" -); ChromeUtils.defineModuleGetter( this, "ESEDBReader", @@ -395,16 +389,9 @@ EdgeBookmarksMigrator.prototype = { throw new Error("Edge seems to be running - its database is locked."); } let { toplevelBMs, toolbarBMs } = this._fetchBookmarksFromDB(); - let histogramBookmarkRoots = 0; if (toplevelBMs.length) { - histogramBookmarkRoots |= - MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_MENU; let parentGuid = PlacesUtils.bookmarks.menuGuid; - if ( - !MigrationUtils.isStartupMigration && - PlacesUtils.getChildCountForFolder(parentGuid) > - PlacesUIUtils.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE - ) { + if (!MigrationUtils.isStartupMigration) { parentGuid = await MigrationUtils.createImportedBookmarksFolder( "Edge", parentGuid @@ -413,25 +400,15 @@ EdgeBookmarksMigrator.prototype = { await MigrationUtils.insertManyBookmarksWrapper(toplevelBMs, parentGuid); } if (toolbarBMs.length) { - histogramBookmarkRoots |= - MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_TOOLBAR; let parentGuid = PlacesUtils.bookmarks.toolbarGuid; - if ( - !MigrationUtils.isStartupMigration && - PlacesUtils.getChildCountForFolder(parentGuid) > - PlacesUIUtils.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE - ) { + if (!MigrationUtils.isStartupMigration) { parentGuid = await MigrationUtils.createImportedBookmarksFolder( "Edge", parentGuid ); } await MigrationUtils.insertManyBookmarksWrapper(toolbarBMs, parentGuid); - PlacesUIUtils.maybeToggleBookmarkToolbarVisibilityAfterMigration(); } - Services.telemetry - .getKeyedHistogramById("FX_MIGRATION_BOOKMARKS_ROOTS") - .add("edge", histogramBookmarkRoots); }, _fetchBookmarksFromDB() { diff --git a/browser/components/migration/MSMigrationUtils.jsm b/browser/components/migration/MSMigrationUtils.jsm index 87b936d662ad..872ed5ce89ac 100644 --- a/browser/components/migration/MSMigrationUtils.jsm +++ b/browser/components/migration/MSMigrationUtils.jsm @@ -24,11 +24,6 @@ ChromeUtils.defineModuleGetter( "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm" ); -ChromeUtils.defineModuleGetter( - this, - "PlacesUIUtils", - "resource:///modules/PlacesUIUtils.jsm" -); ChromeUtils.defineModuleGetter( this, "WindowsRegistry", @@ -411,22 +406,17 @@ Bookmarks.prototype = { return this.__toolbarFolderName; }, - _histogramBookmarkRoots: 0, 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 - .getKeyedHistogramById("FX_MIGRATION_BOOKMARKS_ROOTS") - .add( - this._migrationType == MSMigrationUtils.MIGRATION_TYPE_IE - ? "ie" - : "edge", - this._histogramBookmarkRoots + if (!MigrationUtils.isStartupMigration) { + folderGuid = await MigrationUtils.createImportedBookmarksFolder( + this.importedAppLabel, + folderGuid ); + } + await this._migrateFolder(this._favoritesFolder, folderGuid); })().then( () => aCallback(true), e => { @@ -438,20 +428,12 @@ Bookmarks.prototype = { async _migrateFolder(aSourceFolder, aDestFolderGuid) { let bookmarks = await this._getBookmarksInFolder(aSourceFolder); - if (!bookmarks.length) { - return; - } - if ( - !MigrationUtils.isStartupMigration && - PlacesUtils.getChildCountForFolder(aDestFolderGuid) > - PlacesUIUtils.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE - ) { - aDestFolderGuid = await MigrationUtils.createImportedBookmarksFolder( - this.importedAppLabel, + if (bookmarks.length) { + await MigrationUtils.insertManyBookmarksWrapper( + bookmarks, aDestFolderGuid ); } - await MigrationUtils.insertManyBookmarksWrapper(bookmarks, aDestFolderGuid); }, async _getBookmarksInFolder(aSourceFolder) { @@ -474,11 +456,14 @@ 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; + if (!MigrationUtils.isStartupMigration) { + folderGuid = await MigrationUtils.createImportedBookmarksFolder( + this.importedAppLabel, + folderGuid + ); + } await this._migrateFolder(entry, folderGuid); - PlacesUIUtils.maybeToggleBookmarkToolbarVisibilityAfterMigration(); } else if (entry.isReadable()) { let childBookmarks = await this._getBookmarksInFolder(entry); rv.push({ diff --git a/browser/components/migration/MigrationUtils.jsm b/browser/components/migration/MigrationUtils.jsm index ecaeca879cf4..a9cf5e440249 100644 --- a/browser/components/migration/MigrationUtils.jsm +++ b/browser/components/migration/MigrationUtils.jsm @@ -1306,11 +1306,4 @@ var MigrationUtils = Object.freeze({ getSourceIdForTelemetry(sourceName) { return this._sourceNameToIdMapping[sourceName] || 0; }, - - /* Enum of locations where bookmarks were found in the - source browser that we import from */ - SOURCE_BOOKMARK_ROOTS_BOOKMARKS_TOOLBAR: 1, - SOURCE_BOOKMARK_ROOTS_BOOKMARKS_MENU: 2, - SOURCE_BOOKMARK_ROOTS_READING_LIST: 4, - SOURCE_BOOKMARK_ROOTS_UNFILED: 8, }); diff --git a/browser/components/migration/SafariProfileMigrator.jsm b/browser/components/migration/SafariProfileMigrator.jsm index e1836e996a7a..5b2dd6afcad9 100644 --- a/browser/components/migration/SafariProfileMigrator.jsm +++ b/browser/components/migration/SafariProfileMigrator.jsm @@ -8,7 +8,6 @@ const { FileUtils } = ChromeUtils.import( "resource://gre/modules/FileUtils.jsm" ); const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm"); -const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { XPCOMUtils } = ChromeUtils.import( "resource://gre/modules/XPCOMUtils.jsm" ); @@ -26,11 +25,6 @@ ChromeUtils.defineModuleGetter( "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm" ); -ChromeUtils.defineModuleGetter( - this, - "PlacesUIUtils", - "resource:///modules/PlacesUIUtils.jsm" -); ChromeUtils.defineModuleGetter( this, "FormHistory", @@ -41,7 +35,6 @@ XPCOMUtils.defineLazyGlobalGetters(this, ["URL"]); function Bookmarks(aBookmarksFile) { this._file = aBookmarksFile; - this._histogramBookmarkRoots = 0; } Bookmarks.prototype = { type: MigrationUtils.resourceTypes.BOOKMARKS, @@ -59,22 +52,11 @@ Bookmarks.prototype = { throw new Error("Invalid Bookmarks.plist format"); } - let collection; - if (dict.get("Title") == "com.apple.ReadingList") { - collection = this.READING_LIST_COLLECTION; - } else { - collection = this.ROOT_COLLECTION; - } + let collection = + dict.get("Title") == "com.apple.ReadingList" + ? this.READING_LIST_COLLECTION + : this.ROOT_COLLECTION; await this._migrateCollection(children, collection); - if ( - this._histogramBookmarkRoots & - MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_TOOLBAR - ) { - PlacesUIUtils.maybeToggleBookmarkToolbarVisibilityAfterMigration(); - } - Services.telemetry - .getKeyedHistogramById("FX_MIGRATION_BOOKMARKS_ROOTS") - .add("safari", this._histogramBookmarkRoots); })().then( () => aCallback(true), e => { @@ -145,40 +127,26 @@ Bookmarks.prototype = { // Because the former is only an implementation detail in our UI, // the unfiled root seems to be the best choice. folderGuid = PlacesUtils.bookmarks.unfiledGuid; - this._histogramBookmarkRoots |= - MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_UNFILED; break; } case this.MENU_COLLECTION: { folderGuid = PlacesUtils.bookmarks.menuGuid; - if ( - !MigrationUtils.isStartupMigration && - PlacesUtils.getChildCountForFolder(folderGuid) > - PlacesUIUtils.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE - ) { + if (!MigrationUtils.isStartupMigration) { folderGuid = await MigrationUtils.createImportedBookmarksFolder( "Safari", folderGuid ); } - this._histogramBookmarkRoots |= - MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_MENU; break; } case this.TOOLBAR_COLLECTION: { folderGuid = PlacesUtils.bookmarks.toolbarGuid; - if ( - !MigrationUtils.isStartupMigration && - PlacesUtils.getChildCountForFolder(folderGuid) > - PlacesUIUtils.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE - ) { + if (!MigrationUtils.isStartupMigration) { folderGuid = await MigrationUtils.createImportedBookmarksFolder( "Safari", folderGuid ); } - this._histogramBookmarkRoots |= - MigrationUtils.SOURCE_BOOKMARK_ROOTS_BOOKMARKS_TOOLBAR; break; } case this.READING_LIST_COLLECTION: { @@ -195,8 +163,6 @@ Bookmarks.prototype = { title: readingListTitle, }) ).guid; - this._histogramBookmarkRoots |= - MigrationUtils.SOURCE_BOOKMARK_ROOTS_READING_LIST; break; } default: diff --git a/browser/components/migration/tests/unit/test_360se_bookmarks.js b/browser/components/migration/tests/unit/test_360se_bookmarks.js index e08959f50a1a..8ba2bb1f1a66 100644 --- a/browser/components/migration/tests/unit/test_360se_bookmarks.js +++ b/browser/components/migration/tests/unit/test_360se_bookmarks.js @@ -1,9 +1,5 @@ "use strict"; -const { CustomizableUI } = ChromeUtils.import( - "resource:///modules/CustomizableUI.jsm" -); - add_task(async function() { registerFakePath("AppData", do_get_file("AppData/Roaming/")); @@ -24,37 +20,37 @@ add_task(async function() { "Default user should be the last" ); - let importedToBookmarksToolbar = false; - let itemsSeen = { bookmarks: 0, folders: 0 }; + // Wait for the imported bookmarks. Check that "From 360 Secure Browser" + // folders are created on the toolbar. + let source = await MigrationUtils.getLocalizedString("source-name-360se"); + let label = await MigrationUtils.getLocalizedString( + "imported-bookmarks-source", + { source } + ); + let expectedParents = [PlacesUtils.toolbarFolderId]; + let itemCount = 0; + + let gotFolder = false; let listener = events => { for (let event of events) { - itemsSeen[ - event.itemType == PlacesUtils.bookmarks.TYPE_FOLDER - ? "folders" - : "bookmarks" - ]++; - if (event.parentId == PlacesUtils.toolbarFolderId) { - importedToBookmarksToolbar = true; + if (event.title != label) { + itemCount++; + } + if ( + event.itemType == PlacesUtils.bookmarks.TYPE_FOLDER && + event.title == "360 \u76f8\u5173" + ) { + gotFolder = true; + } + if (expectedParents.length && event.title == label) { + let index = expectedParents.indexOf(event.parentId); + Assert.ok(index != -1, "Found expected parent"); + expectedParents.splice(index, 1); } } }; PlacesUtils.observers.addListener(["bookmark-added"], listener); - let observerNotified = false; - Services.obs.addObserver((aSubject, aTopic, aData) => { - let [toolbar, visibility] = JSON.parse(aData); - Assert.equal( - toolbar, - CustomizableUI.AREA_BOOKMARKS, - "Notification should be received for bookmarks toolbar" - ); - Assert.equal( - visibility, - "true", - "Notification should say to reveal the bookmarks toolbar" - ); - observerNotified = true; - }, "browser-set-toolbar-visibility"); await promiseMigration(migrator, MigrationUtils.resourceTypes.BOOKMARKS, { id: "default", @@ -62,14 +58,13 @@ add_task(async function() { PlacesUtils.observers.removeListener(["bookmark-added"], listener); // Check the bookmarks have been imported to all the expected parents. - Assert.ok(importedToBookmarksToolbar, "Bookmarks imported in the toolbar"); - Assert.equal(itemsSeen.bookmarks, 8, "Should import all bookmarks."); - Assert.equal(itemsSeen.folders, 2, "Should import all folders."); + Assert.ok(!expectedParents.length, "No more expected parents"); + Assert.ok(gotFolder, "Should have seen the folder get imported"); + Assert.equal(itemCount, 10, "Should import all 10 items."); // Check that the telemetry matches: Assert.equal( MigrationUtils._importQuantities.bookmarks, - itemsSeen.bookmarks + itemsSeen.folders, + itemCount, "Telemetry reporting correct." ); - Assert.ok(observerNotified, "The observer should be notified upon migration"); }); diff --git a/browser/components/migration/tests/unit/test_Chrome_bookmarks.js b/browser/components/migration/tests/unit/test_Chrome_bookmarks.js index e6272dfe9dea..360a933ff4cf 100644 --- a/browser/components/migration/tests/unit/test_Chrome_bookmarks.js +++ b/browser/components/migration/tests/unit/test_Chrome_bookmarks.js @@ -3,9 +3,6 @@ const { AppConstants } = ChromeUtils.import( "resource://gre/modules/AppConstants.jsm" ); -const { CustomizableUI } = ChromeUtils.import( - "resource:///modules/CustomizableUI.jsm" -); let rootDir = do_get_file("chromefiles/", true); @@ -119,21 +116,6 @@ async function testBookmarks(migratorKey, subDirs, folderName) { id: "Default", name: "Default", }; - let observerNotified = false; - Services.obs.addObserver((aSubject, aTopic, aData) => { - let [toolbar, visibility] = JSON.parse(aData); - Assert.equal( - toolbar, - CustomizableUI.AREA_BOOKMARKS, - "Notification should be received for bookmarks toolbar" - ); - Assert.equal( - visibility, - "true", - "Notification should say to reveal the bookmarks toolbar" - ); - observerNotified = true; - }, "browser-set-toolbar-visibility"); await promiseMigration( migrator, MigrationUtils.resourceTypes.BOOKMARKS, @@ -148,7 +130,6 @@ async function testBookmarks(migratorKey, subDirs, folderName) { itemsSeen.bookmarks + itemsSeen.folders, "Telemetry reporting correct." ); - Assert.ok(observerNotified, "The observer should be notified upon migration"); } add_task(async function test_Chrome() { diff --git a/browser/components/migration/tests/unit/test_Edge_db_migration.js b/browser/components/migration/tests/unit/test_Edge_db_migration.js index 0ebd1b1fffc7..d419c7e5bd0e 100644 --- a/browser/components/migration/tests/unit/test_Edge_db_migration.js +++ b/browser/components/migration/tests/unit/test_Edge_db_migration.js @@ -594,8 +594,8 @@ add_task(async function() { Assert.ok(migrateResult, "Migration should succeed"); Assert.equal( seenBookmarks.length, - 5, - "Should have seen 5 items being bookmarked." + 7, + "Should have seen 7 items being bookmarked." ); Assert.equal( seenBookmarks.filter(bm => bm.title != sourceLabel).length, @@ -608,8 +608,8 @@ add_task(async function() { ); Assert.equal( menuParents.length, - 3, - "Bookmarks are added to the menu without a folder" + 1, + "Should have a single folder added to the menu" ); let toolbarParents = seenBookmarks.filter( item => item.parentGuid == PlacesUtils.bookmarks.toolbarGuid @@ -619,8 +619,8 @@ add_task(async function() { 1, "Should have a single item added to the toolbar" ); - let menuParentGuid = PlacesUtils.bookmarks.menuGuid; - let toolbarParentGuid = PlacesUtils.bookmarks.toolbarGuid; + let menuParentGuid = menuParents[0].guid; + let toolbarParentGuid = toolbarParents[0].guid; let expectedTitlesInMenu = bookmarkReferenceItems .filter(item => item.ParentId == kEdgeMenuParent) diff --git a/browser/components/migration/tests/unit/test_IE_bookmarks.js b/browser/components/migration/tests/unit/test_IE_bookmarks.js index 70e77e71e3ef..474f9b797060 100644 --- a/browser/components/migration/tests/unit/test_IE_bookmarks.js +++ b/browser/components/migration/tests/unit/test_IE_bookmarks.js @@ -1,13 +1,17 @@ "use strict"; -const { CustomizableUI } = ChromeUtils.import( - "resource:///modules/CustomizableUI.jsm" -); - add_task(async function() { let migrator = await MigrationUtils.getMigrator("ie"); // Sanity check for the source. - Assert.ok(await migrator.isSourceAvailable(), "Check migrator source"); + Assert.ok(await migrator.isSourceAvailable()); + + // Wait for the imported bookmarks. Check that "From Internet Explorer" + // folders are created in the menu and on the toolbar. + let source = await MigrationUtils.getLocalizedString("source-name-ie"); + let label = await MigrationUtils.getLocalizedString( + "imported-bookmarks-source", + { source } + ); let expectedParents = [ PlacesUtils.bookmarksMenuFolderId, @@ -17,31 +21,17 @@ add_task(async function() { let itemCount = 0; let listener = events => { for (let event of events) { - if (event.itemType == PlacesUtils.bookmarks.TYPE_BOOKMARK) { + if (event.title != label) { itemCount++; } - if (expectedParents.length && expectedParents.includes(event.parentId)) { + if (expectedParents.length && event.title == label) { let index = expectedParents.indexOf(event.parentId); + Assert.notEqual(index, -1); expectedParents.splice(index, 1); } } }; PlacesUtils.observers.addListener(["bookmark-added"], listener); - let observerNotified = false; - Services.obs.addObserver((aSubject, aTopic, aData) => { - let [toolbar, visibility] = JSON.parse(aData); - Assert.equal( - toolbar, - CustomizableUI.AREA_BOOKMARKS, - "Notification should be received for bookmarks toolbar" - ); - Assert.equal( - visibility, - "true", - "Notification should say to reveal the bookmarks toolbar" - ); - observerNotified = true; - }, "browser-set-toolbar-visibility"); await promiseMigration(migrator, MigrationUtils.resourceTypes.BOOKMARKS); PlacesUtils.observers.removeListener(["bookmark-added"], listener); @@ -53,5 +43,4 @@ add_task(async function() { // Check the bookmarks have been imported to all the expected parents. Assert.equal(expectedParents.length, 0, "Got all the expected parents"); - Assert.ok(observerNotified, "The observer should be notified upon migration"); }); diff --git a/browser/components/migration/tests/unit/test_Safari_bookmarks.js b/browser/components/migration/tests/unit/test_Safari_bookmarks.js index 9323c143f4ff..aa8c479acd82 100644 --- a/browser/components/migration/tests/unit/test_Safari_bookmarks.js +++ b/browser/components/migration/tests/unit/test_Safari_bookmarks.js @@ -1,9 +1,5 @@ "use strict"; -const { CustomizableUI } = ChromeUtils.import( - "resource:///modules/CustomizableUI.jsm" -); - add_task(async function() { registerFakePath("ULibDir", do_get_file("Library/")); @@ -42,21 +38,6 @@ add_task(async function() { } }; PlacesUtils.observers.addListener(["bookmark-added"], listener); - let observerNotified = false; - Services.obs.addObserver((aSubject, aTopic, aData) => { - let [toolbar, visibility] = JSON.parse(aData); - Assert.equal( - toolbar, - CustomizableUI.AREA_BOOKMARKS, - "Notification should be received for bookmarks toolbar" - ); - Assert.equal( - visibility, - "true", - "Notification should say to reveal the bookmarks toolbar" - ); - observerNotified = true; - }, "browser-set-toolbar-visibility"); await promiseMigration(migrator, MigrationUtils.resourceTypes.BOOKMARKS); PlacesUtils.observers.removeListener(["bookmark-added"], listener); @@ -71,5 +52,4 @@ add_task(async function() { itemCount, "Telemetry reporting correct." ); - Assert.ok(observerNotified, "The observer should be notified upon migration"); }); diff --git a/browser/components/places/PlacesUIUtils.jsm b/browser/components/places/PlacesUIUtils.jsm index 0db76659ca29..1bb87eca52d7 100644 --- a/browser/components/places/PlacesUIUtils.jsm +++ b/browser/components/places/PlacesUIUtils.jsm @@ -18,7 +18,6 @@ XPCOMUtils.defineLazyGlobalGetters(this, ["Element"]); XPCOMUtils.defineLazyModuleGetters(this, { AppConstants: "resource://gre/modules/AppConstants.jsm", BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm", - CustomizableUI: "resource:///modules/CustomizableUI.jsm", OpenInTabsUtils: "resource:///modules/OpenInTabsUtils.jsm", PlacesTransactions: "resource://gre/modules/PlacesTransactions.jsm", PlacesUtils: "resource://gre/modules/PlacesUtils.jsm", @@ -1161,58 +1160,6 @@ var PlacesUIUtils = { win.top.XULBrowserWindow.setOverLink(url); } }, - - /** - * Uncollapses PersonalToolbar if its collapsed status is not - * persisted, and user customized it or changed default bookmarks. - * - * If the user does not have a persisted value for the toolbar's - * "collapsed" attribute, try to determine whether it's customized. - * - * @param {Boolean} aForceVisible Set to true to ignore if the user had - * previously collapsed the toolbar manually. - */ - NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE: 3, - maybeToggleBookmarkToolbarVisibility(aForceVisible = false) { - const BROWSER_DOCURL = AppConstants.BROWSER_CHROME_URL; - let xulStore = Services.xulStore; - - if ( - aForceVisible || - !xulStore.hasValue(BROWSER_DOCURL, "PersonalToolbar", "collapsed") - ) { - // We consider the toolbar customized if it has more than NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE - // children, or if it has a persisted currentset value. - let toolbarIsCustomized = xulStore.hasValue( - BROWSER_DOCURL, - "PersonalToolbar", - "currentset" - ); - - if ( - aForceVisible || - toolbarIsCustomized || - PlacesUtils.getToolbarFolderCount(PlacesUtils.bookmarks.toolbarGuid) > - this.NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE - ) { - Services.obs.notifyObservers( - null, - "browser-set-toolbar-visibility", - JSON.stringify([CustomizableUI.AREA_BOOKMARKS, "true"]) - ); - } - } - }, - - maybeToggleBookmarkToolbarVisibilityAfterMigration() { - if ( - Services.prefs.getBoolPref( - "browser.migrate.showBookmarksToolbarAfterMigration" - ) - ) { - this.maybeToggleBookmarkToolbarVisibility(true); - } - }, }; // These are lazy getters to avoid importing PlacesUtils immediately. diff --git a/browser/components/tests/browser/browser_default_bookmark_toolbar_visibility.js b/browser/components/tests/browser/browser_default_bookmark_toolbar_visibility.js index 1a5ab009358b..5c3bcf7171f9 100644 --- a/browser/components/tests/browser/browser_default_bookmark_toolbar_visibility.js +++ b/browser/components/tests/browser/browser_default_bookmark_toolbar_visibility.js @@ -2,7 +2,7 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ /** - * Test PlacesUIUtils.maybeToggleBookmarkToolbarVisibility() code running for new profiles. + * Test _maybeToggleBookmarkToolbarVisibility() code running for new profiles. * Ensure that the bookmarks toolbar is hidden in a default configuration. * If new default bookmarks are added to the toolbar then the threshold of > 3 * in NUM_TOOLBAR_BOOKMARKS_TO_UNHIDE may need to be adjusted there. diff --git a/toolkit/components/places/PlacesUtils.jsm b/toolkit/components/places/PlacesUtils.jsm index dc2e98f290d2..1afcdfb6737a 100644 --- a/toolkit/components/places/PlacesUtils.jsm +++ b/toolkit/components/places/PlacesUtils.jsm @@ -1408,13 +1408,6 @@ var PlacesUtils = { return found; }, - getChildCountForFolder(guid) { - let folder = PlacesUtils.getFolderContents(guid).root; - let childCount = folder.childCount; - folder.containerOpen = false; - return childCount; - }, - /** * Returns an array containing all the uris in the first level of the * passed in container. diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 3e98762f7522..d136d5fbc794 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -7219,18 +7219,6 @@ "keyed": true, "description": "Accumulated timer delay (variance between when the timer was expected to fire and when it actually fired) in milliseconds as an indicator for decreased main-thread responsiveness while importing logins / passwords from another browser, keyed by the name of the browser (see gAvailableMigratorKeys in MigrationUtils.jsm). The import is happening on a background thread and should ideally not affect the UI noticeably. The time with the blocking Keychain dialog on macOS can skew this data." }, - "FX_MIGRATION_BOOKMARKS_ROOTS": { - "record_in_processes": ["main"], - "products": ["firefox"], - "bug_numbers": [1656277], - "alert_emails": ["jaws@mozilla.com", "rtestard@mozilla.com"], - "expires_in_version": "91", - "kind": "enumerated", - "n_values": 32, - "releaseChannelCollection": "opt-out", - "keyed": true, - "description": "Where bookmarks were stored in the other browser (1=bookmarks toolbar, 2=bookmarks menu, 4=reading list, 8=unfiled), keyed by the name of the browser. Note that migrating the reading list from classic Edge is supported but its root is not reported here." - }, "FX_MIGRATION_BOOKMARKS_QUANTITY": { "record_in_processes": ["main"], "products": ["firefox"],