Skip to content

Commit

Permalink
Bug 1674091 - Don't update the state of the Other Bookmarks shortcut …
Browse files Browse the repository at this point in the history
…folder if the personal-bookmarks item has been placed in the palette. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D96764
  • Loading branch information
msujaws committed Nov 12, 2020
1 parent 6e98b1d commit 9ca7a54
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
8 changes: 5 additions & 3 deletions browser/base/content/browser-places.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 9ca7a54

Please sign in to comment.