From 34cd6804d133eab6a359dd88f04b3d8d4d5156ac Mon Sep 17 00:00:00 2001 From: Jared Wein Date: Thu, 12 Nov 2020 21:23:54 +0000 Subject: [PATCH] Bug 1674091 - Don't update the state of the Other Bookmarks shortcut folder if the personal-bookmarks item has been placed in the palette. r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D96764 --- browser/base/content/browser-places.js | 8 ++++--- .../browser_toolbar_other_bookmarks.js | 24 +++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/browser/base/content/browser-places.js b/browser/base/content/browser-places.js index f3751f04bd60..5c8962afc7f2 100644 --- a/browser/base/content/browser-places.js +++ b/browser/base/content/browser-places.js @@ -2318,19 +2318,21 @@ var BookmarkingUI = { }, async maybeShowOtherBookmarksFolder() { + // otherBookmarks may be null if personal-bookmarks is in the palette. + let otherBookmarks = document.getElementById("OtherBookmarks"); + // Only show the "Other Bookmarks" folder in the toolbar if pref is enabled. - if (!gBookmarksToolbar2h2020) { + if (!gBookmarksToolbar2h2020 || !otherBookmarks) { return; } let unfiledGuid = PlacesUtils.bookmarks.unfiledGuid; let numberOfBookmarks = PlacesUtils.getChildCountForFolder(unfiledGuid); - let otherBookmarks = document.getElementById("OtherBookmarks"); let placement = CustomizableUI.getPlacementOfWidget("personal-bookmarks"); if ( numberOfBookmarks > 0 && - placement.area == CustomizableUI.AREA_BOOKMARKS + placement?.area == CustomizableUI.AREA_BOOKMARKS ) { let otherBookmarksPopup = document.getElementById("OtherBookmarksPopup"); let result = PlacesUtils.getFolderContents(unfiledGuid); diff --git a/browser/components/places/tests/browser/browser_toolbar_other_bookmarks.js b/browser/components/places/tests/browser/browser_toolbar_other_bookmarks.js index e8d3a4f00729..9a5b8e299c7c 100644 --- a/browser/components/places/tests/browser/browser_toolbar_other_bookmarks.js +++ b/browser/components/places/tests/browser/browser_toolbar_other_bookmarks.js @@ -219,6 +219,30 @@ add_task(async function testDeletingMenuItems() { await closeMenuPopup("#OtherBookmarksPopup"); }); +add_task(async function no_errors_when_bookmarks_placed_in_palette() { + CustomizableUI.removeWidgetFromArea("personal-bookmarks"); + + let consoleErrors = 0; + + let errorListener = { + observe(error) { + ok(false, error.message); + consoleErrors++; + }, + }; + Services.console.registerListener(errorListener); + + let bookmarks = await PlacesUtils.bookmarks.insertTree({ + guid: PlacesUtils.bookmarks.unfiledGuid, + children: bookmarksInfo, + }); + is(consoleErrors, 0, "There should be no console errors"); + + Services.console.unregisterListener(errorListener); + await PlacesUtils.bookmarks.remove(bookmarks); + CustomizableUI.reset(); +}); + /** * Tests whether or not the "Other Bookmarks" folder is visible. */