Skip to content

Commit

Permalink
Bug 1913976 - mobileBookmarks folder is missing in Bookmarks menu. a=…
Browse files Browse the repository at this point in the history
  • Loading branch information
mak77 committed Aug 29, 2024
1 parent cd60239 commit f0d9363
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 15 deletions.
30 changes: 15 additions & 15 deletions browser/base/content/browser-places.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ XPCOMUtils.defineLazyPreferenceGetter(
}, console.error);
}
);

// Set by sync after syncing bookmarks successfully once.
XPCOMUtils.defineLazyPreferenceGetter(
this,
"SHOW_MOBILE_BOOKMARKS",
"browser.bookmarks.showMobileBookmarks",
false
);

ChromeUtils.defineESModuleGetters(this, {
PanelMultiView: "resource:///modules/PanelMultiView.sys.mjs",
RecentlyClosedTabsAndWindowsMenuUtils:
Expand Down Expand Up @@ -1343,7 +1352,7 @@ var BookmarkingUI = {

onPopupShowing: function BUI_onPopupShowing(event) {
// Don't handle events for submenus.
if (event.target != event.currentTarget) {
if (event.target.id != "BMB_bookmarksPopup") {
return;
}

Expand Down Expand Up @@ -1374,7 +1383,8 @@ var BookmarkingUI = {
return;
}

this._initMobileBookmarks(document.getElementById("BMB_mobileBookmarks"));
document.getElementById("BMB_mobileBookmarks").hidden =
!SHOW_MOBILE_BOOKMARKS;

this.updateLabel(
"BMB_viewBookmarksSidebar",
Expand Down Expand Up @@ -1582,17 +1592,6 @@ var BookmarkingUI = {
}
},

// Set by sync after syncing bookmarks successfully once.
MOBILE_BOOKMARKS_PREF: "browser.bookmarks.showMobileBookmarks",

_shouldShowMobileBookmarks() {
return Services.prefs.getBoolPref(this.MOBILE_BOOKMARKS_PREF, false);
},

_initMobileBookmarks(mobileMenuItem) {
mobileMenuItem.hidden = !this._shouldShowMobileBookmarks();
},

_uninitView: function BUI__uninitView() {
// When an element with a placesView attached is removed and re-inserted,
// XBL reapplies the binding causing any kind of issues and possible leaks,
Expand Down Expand Up @@ -1938,11 +1937,12 @@ var BookmarkingUI = {

onMainMenuPopupShowing: function BUI_onMainMenuPopupShowing(event) {
// Don't handle events for submenus.
if (event.target != event.currentTarget) {
if (event.target.id != "bookmarksMenuPopup") {
return;
}

this._initMobileBookmarks(document.getElementById("menu_mobileBookmarks"));
document.getElementById("menu_mobileBookmarks").hidden =
!SHOW_MOBILE_BOOKMARKS;
},

showSubView(anchor) {
Expand Down
2 changes: 2 additions & 0 deletions browser/components/places/tests/browser/browser.toml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ skip-if = ["verify && debug && os == 'win'"]

["browser_markPageAsFollowedLink.js"]

["browser_mobile_root_on_bookmark_menus.js"]

["browser_panelview_bookmarks_delete.js"]

["browser_paste_bookmarks.js"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

let { PlacesSyncUtils } = ChromeUtils.importESModule(
"resource://gre/modules/PlacesSyncUtils.sys.mjs"
);

add_setup(async function () {
// There should be at least one bookmark in the mobile root.
await PlacesUtils.bookmarks.insert({
url: "https://www.mozilla.org/",
parentGuid: PlacesUtils.bookmarks.mobileGuid,
});
await PlacesSyncUtils.bookmarks.ensureMobileQuery();
CustomizableUI.addWidgetToArea(
"bookmarks-menu-button",
CustomizableUI.AREA_NAVBAR,
4
);

registerCleanupFunction(async function () {
CustomizableUI.reset();
await PlacesUtils.bookmarks.eraseEverything();
});
});

add_task(async function test() {
for (let { popup, mobileMenuitem } of [
{
popup: document.getElementById("BMB_bookmarksPopup"),
mobileMenuitem: document.getElementById("BMB_mobileBookmarks"),
},
{
popup: document.getElementById("bookmarksMenuPopup"),
mobileMenuitem: document.getElementById("menu_mobileBookmarks"),
},
]) {
info("Open bookmarks popup.");
let shownPromise = BrowserTestUtils.waitForEvent(
popup,
"popupshowing",
false,
e => e.target == popup
);
// Simulates popup opening causing it to populate. We cannot just open
// normally since it would not work on Mac native menubar.
popup.dispatchEvent(
new MouseEvent("popupshowing", {
bubbles: true,
})
);
await shownPromise;

Assert.ok(!mobileMenuitem.hidden, "Check mobile root is not hidden.");
}
});

0 comments on commit f0d9363

Please sign in to comment.