зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1674539) for bc failures on browser_toolbar_other_bookmarks.js . CLOSED TREE
Backed out changeset 63032f8390ea (bug 1674539) Backed out changeset 36ab7b9324d9 (bug 1674539)
This commit is contained in:
Родитель
7812fd2f0c
Коммит
7d6ce0d218
|
@ -2064,11 +2064,6 @@ pref("browser.toolbars.keyboard_navigation", true);
|
|||
// "always": Always show
|
||||
// "never": Never show
|
||||
pref("browser.toolbars.bookmarks.visibility", "newtab");
|
||||
|
||||
// Visibility of the "Show Other Bookmarks" menuitem in the
|
||||
// bookmarks toolbar contextmenu.
|
||||
pref("browser.toolbars.bookmarks.showOtherBookmarks", true);
|
||||
|
||||
// When true, this pref will always show the bookmarks bar on
|
||||
// the New Tab Page, allowing showing/hiding via keyboard shortcut,
|
||||
// and other functionality to improve the usage of the Bookmarks Toolbar.
|
||||
|
|
|
@ -2362,14 +2362,9 @@ var BookmarkingUI = {
|
|||
let unfiledGuid = PlacesUtils.bookmarks.unfiledGuid;
|
||||
let numberOfBookmarks = PlacesUtils.getChildCountForFolder(unfiledGuid);
|
||||
let placement = CustomizableUI.getPlacementOfWidget("personal-bookmarks");
|
||||
let showOtherBookmarksEnabled = Services.prefs.getBoolPref(
|
||||
"browser.toolbars.bookmarks.showOtherBookmarks",
|
||||
true
|
||||
);
|
||||
|
||||
if (
|
||||
numberOfBookmarks > 0 &&
|
||||
showOtherBookmarksEnabled &&
|
||||
placement?.area == CustomizableUI.AREA_BOOKMARKS
|
||||
) {
|
||||
let otherBookmarksPopup = document.getElementById("OtherBookmarksPopup");
|
||||
|
@ -2384,43 +2379,5 @@ var BookmarkingUI = {
|
|||
}
|
||||
},
|
||||
|
||||
buildShowOtherBookmarksMenuItem() {
|
||||
let unfiledGuid = PlacesUtils.bookmarks.unfiledGuid;
|
||||
let numberOfBookmarks = PlacesUtils.getChildCountForFolder(unfiledGuid);
|
||||
|
||||
if (!gBookmarksToolbar2h2020 || numberOfBookmarks < 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let showOtherBookmarksMenuItem = Services.prefs.getBoolPref(
|
||||
"browser.toolbars.bookmarks.showOtherBookmarks",
|
||||
true
|
||||
);
|
||||
|
||||
let menuItem = document.createXULElement("menuitem");
|
||||
|
||||
menuItem.setAttribute("id", "show-other-bookmarks_PersonalToolbar");
|
||||
menuItem.setAttribute("toolbarId", "PersonalToolbar");
|
||||
menuItem.setAttribute("type", "checkbox");
|
||||
menuItem.setAttribute("checked", showOtherBookmarksMenuItem);
|
||||
menuItem.setAttribute("selectiontype", "none|single");
|
||||
|
||||
MozXULElement.insertFTLIfNeeded("browser/toolbarContextMenu.ftl");
|
||||
document.l10n.setAttributes(
|
||||
menuItem,
|
||||
"toolbar-context-menu-bookmarks-show-other-bookmarks"
|
||||
);
|
||||
menuItem.addEventListener("command", () => {
|
||||
Services.prefs.setBoolPref(
|
||||
"browser.toolbars.bookmarks.showOtherBookmarks",
|
||||
!showOtherBookmarksMenuItem
|
||||
);
|
||||
|
||||
BookmarkingUI.maybeShowOtherBookmarksFolder();
|
||||
});
|
||||
|
||||
return menuItem;
|
||||
},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI(["nsINavBookmarkObserver"]),
|
||||
};
|
||||
|
|
|
@ -6303,15 +6303,6 @@ function onViewToolbarsPopupShowing(aEvent, aInsertPoint) {
|
|||
if (toolbar.id == "PersonalToolbar" && gBookmarksToolbar2h2020) {
|
||||
let menu = BookmarkingUI.buildBookmarksToolbarSubmenu(toolbar);
|
||||
popup.insertBefore(menu, firstMenuItem);
|
||||
|
||||
// Insert Show Otherbookmarks menu item.
|
||||
let otherBookmarksMenuItem = BookmarkingUI.buildShowOtherBookmarksMenuItem();
|
||||
|
||||
if (!otherBookmarksMenuItem) {
|
||||
continue;
|
||||
}
|
||||
|
||||
popup.insertBefore(otherBookmarksMenuItem, menu.nextElementSibling);
|
||||
} else {
|
||||
let menuItem = document.createXULElement("menuitem");
|
||||
menuItem.setAttribute("id", "toggle_" + toolbar.id);
|
||||
|
|
|
@ -250,18 +250,8 @@ PlacesViewBase.prototype = {
|
|||
this._contextMenuShown = aPopup;
|
||||
window.updateCommands("places");
|
||||
|
||||
// Ensure that an existing "Show Other Bookmarks" item is removed before adding it
|
||||
// again. This item should only be added when gBookmarksToolbar2h2020 is true, but
|
||||
// its possible the pref could be toggled off in the same window. This results in
|
||||
// the "Show Other Bookmarks" menu item still being visible even when the pref is
|
||||
// set to false.
|
||||
let existingOtherBookmarksItem = aPopup.querySelector(
|
||||
"#show-other-bookmarks_PersonalToolbar"
|
||||
);
|
||||
existingOtherBookmarksItem?.remove();
|
||||
|
||||
// Add the View menu for the Bookmarks Toolbar and "Show Other Bookmarks" menu item
|
||||
// if the click originated from the Bookmarks Toolbar.
|
||||
// Add the View menu for the Bookmarks Toolbar if the click originated
|
||||
// from the Bookmarks Toolbar.
|
||||
if (gBookmarksToolbar2h2020) {
|
||||
let existingSubmenu = aPopup.querySelector("#toggle_PersonalToolbar");
|
||||
existingSubmenu?.remove();
|
||||
|
@ -269,20 +259,6 @@ PlacesViewBase.prototype = {
|
|||
if (bookmarksToolbar?.contains(aPopup.triggerNode)) {
|
||||
let menu = BookmarkingUI.buildBookmarksToolbarSubmenu(bookmarksToolbar);
|
||||
aPopup.appendChild(menu);
|
||||
|
||||
if (
|
||||
aPopup.triggerNode.id === "OtherBookmarks" ||
|
||||
aPopup.triggerNode.id === "PlacesToolbarItems"
|
||||
) {
|
||||
let otherBookmarksMenuItem = BookmarkingUI.buildShowOtherBookmarksMenuItem();
|
||||
|
||||
if (otherBookmarksMenuItem) {
|
||||
aPopup.insertBefore(
|
||||
otherBookmarksMenuItem,
|
||||
menu.nextElementSibling
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,10 @@ add_task(async function setup() {
|
|||
let toolbar = document.getElementById("PersonalToolbar");
|
||||
let wasCollapsed = toolbar.collapsed;
|
||||
|
||||
await setupBookmarksToolbar();
|
||||
// Uncollapse the personal toolbar if needed.
|
||||
if (wasCollapsed) {
|
||||
await promiseSetToolbarVisibility(toolbar, true);
|
||||
}
|
||||
|
||||
// Cleanup.
|
||||
registerCleanupFunction(async () => {
|
||||
|
@ -50,18 +53,18 @@ add_task(async function testShowingOtherBookmarksInToolbar() {
|
|||
});
|
||||
|
||||
info("Check visibility of an empty Other Bookmarks folder.");
|
||||
await testIsOtherBookmarksHidden(true);
|
||||
testIsOtherBookmarksHidden(true);
|
||||
|
||||
info("Ensure folder appears in toolbar when a new bookmark is added.");
|
||||
let bookmarks = await PlacesUtils.bookmarks.insertTree({
|
||||
guid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
children: bookmarksInfo,
|
||||
});
|
||||
await testIsOtherBookmarksHidden(false);
|
||||
testIsOtherBookmarksHidden(false);
|
||||
|
||||
info("Ensure folder disappears from toolbar when no bookmarks are present.");
|
||||
await PlacesUtils.bookmarks.remove(bookmarks);
|
||||
await testIsOtherBookmarksHidden(true);
|
||||
testIsOtherBookmarksHidden(true);
|
||||
});
|
||||
|
||||
// Test that folder visibility is correct when moving bookmarks to an empty
|
||||
|
@ -76,7 +79,7 @@ add_task(async function testOtherBookmarksVisibilityWhenMovingBookmarks() {
|
|||
guid: PlacesUtils.bookmarks.toolbarGuid,
|
||||
children: bookmarksInfo,
|
||||
});
|
||||
await testIsOtherBookmarksHidden(true);
|
||||
testIsOtherBookmarksHidden(true);
|
||||
|
||||
info("Move toolbar bookmarks to Other Bookmarks folder.");
|
||||
await PlacesUtils.bookmarks.moveToFolder(
|
||||
|
@ -84,7 +87,7 @@ add_task(async function testOtherBookmarksVisibilityWhenMovingBookmarks() {
|
|||
PlacesUtils.bookmarks.unfiledGuid,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
);
|
||||
await testIsOtherBookmarksHidden(false);
|
||||
testIsOtherBookmarksHidden(false);
|
||||
|
||||
info("Move bookmarks from Other Bookmarks back to the toolbar.");
|
||||
await PlacesUtils.bookmarks.moveToFolder(
|
||||
|
@ -92,7 +95,7 @@ add_task(async function testOtherBookmarksVisibilityWhenMovingBookmarks() {
|
|||
PlacesUtils.bookmarks.toolbarGuid,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
);
|
||||
await testIsOtherBookmarksHidden(true);
|
||||
testIsOtherBookmarksHidden(true);
|
||||
});
|
||||
|
||||
// Test OtherBookmarksPopup in toolbar.
|
||||
|
@ -107,7 +110,7 @@ add_task(async function testOtherBookmarksMenuPopup() {
|
|||
children: bookmarksInfo,
|
||||
});
|
||||
|
||||
await testIsOtherBookmarksHidden(false);
|
||||
testIsOtherBookmarksHidden(false);
|
||||
|
||||
info("Check the popup menu has correct number of children.");
|
||||
await openMenuPopup("#OtherBookmarksPopup", "#OtherBookmarks");
|
||||
|
@ -156,22 +159,30 @@ add_task(async function testFolderPopup() {
|
|||
});
|
||||
|
||||
add_task(async function testOnlyShowOtherFolderInBookmarksToolbar() {
|
||||
await testIsOtherBookmarksHidden(false);
|
||||
testIsOtherBookmarksHidden(false);
|
||||
|
||||
// Test that moving the personal-bookmarks widget out of the
|
||||
// Bookmarks Toolbar will hide the "Other Bookmarks" folder.
|
||||
let widgetId = "personal-bookmarks";
|
||||
CustomizableUI.addWidgetToArea(widgetId, CustomizableUI.AREA_NAVBAR);
|
||||
await testIsOtherBookmarksHidden(true);
|
||||
testIsOtherBookmarksHidden(true);
|
||||
|
||||
CustomizableUI.reset();
|
||||
await testIsOtherBookmarksHidden(false);
|
||||
testIsOtherBookmarksHidden(false);
|
||||
});
|
||||
|
||||
// Test that the menu popup updates when menu items are deleted from it while
|
||||
// it's open.
|
||||
add_task(async function testDeletingMenuItems() {
|
||||
await setupBookmarksToolbar();
|
||||
let toolbar = document.getElementById("PersonalToolbar");
|
||||
let wasCollapsed = toolbar.collapsed;
|
||||
|
||||
// Uncollapse the personal toolbar if needed.
|
||||
if (wasCollapsed) {
|
||||
await promiseSetToolbarVisibility(toolbar, true);
|
||||
}
|
||||
|
||||
await PlacesUtils.bookmarks.eraseEverything();
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[BOOKMARKS_H2_2020_PREF, true]],
|
||||
|
@ -232,70 +243,14 @@ add_task(async function no_errors_when_bookmarks_placed_in_palette() {
|
|||
CustomizableUI.reset();
|
||||
});
|
||||
|
||||
// Test "Show Other Bookmarks" menu item visibility in toolbar context menu.
|
||||
add_task(async function testShowingOtherBookmarksContextMenuItem() {
|
||||
await setupBookmarksToolbar();
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[BOOKMARKS_H2_2020_PREF, true]],
|
||||
});
|
||||
|
||||
info("Add bookmark to Other Bookmarks.");
|
||||
let bookmark = await PlacesUtils.bookmarks.insertTree({
|
||||
guid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
children: [{ title: "firefox", url: "http://example.com" }],
|
||||
});
|
||||
|
||||
info("'Show Other Bookmarks' menu item should be checked by default.");
|
||||
await testOtherBookmarksCheckedState(true);
|
||||
|
||||
info("Toggle off showing the Other Bookmarks folder.");
|
||||
await selectShowOtherBookmarksMenuItem();
|
||||
await testOtherBookmarksCheckedState(false);
|
||||
await testIsOtherBookmarksHidden(true);
|
||||
|
||||
info("Toggle on showing the Other Bookmarks folder.");
|
||||
await selectShowOtherBookmarksMenuItem();
|
||||
await testOtherBookmarksCheckedState(true);
|
||||
await testIsOtherBookmarksHidden(false);
|
||||
|
||||
info(
|
||||
"Ensure 'Show Other Bookmarks' isn't shown when Other Bookmarks is empty."
|
||||
);
|
||||
await PlacesUtils.bookmarks.remove(bookmark);
|
||||
await testIsOtherBookmarksMenuItemShown(false);
|
||||
|
||||
info("Add a bookmark to the empty Other Bookmarks folder.");
|
||||
await PlacesUtils.bookmarks.insertTree({
|
||||
guid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
children: [{ title: "firefox", url: "http://example.com" }],
|
||||
});
|
||||
await testIsOtherBookmarksMenuItemShown(true);
|
||||
});
|
||||
|
||||
// Test 'Show Other Bookmarks' isn't shown when pref is false.
|
||||
add_task(async function showOtherBookmarksMenuItemPrefDisabled() {
|
||||
await setupBookmarksToolbar();
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[BOOKMARKS_H2_2020_PREF, false]],
|
||||
});
|
||||
await testIsOtherBookmarksMenuItemShown(false);
|
||||
});
|
||||
|
||||
/**
|
||||
* Tests whether or not the "Other Bookmarks" folder is visible.
|
||||
*/
|
||||
async function testIsOtherBookmarksHidden(expected) {
|
||||
info("Test whether or not the 'Other Bookmarks' folder is visible.");
|
||||
let otherBookmarks = document.getElementById("OtherBookmarks");
|
||||
|
||||
// Ensure the toolbar is visible.
|
||||
let toolbar = document.getElementById("PersonalToolbar");
|
||||
await promiseSetToolbarVisibility(toolbar, true);
|
||||
|
||||
await TestUtils.waitForCondition(() => {
|
||||
let otherBookmarks = document.getElementById("OtherBookmarks");
|
||||
return otherBookmarks.hidden === expected;
|
||||
}, "Other Bookmarks folder failed to change hidden state.");
|
||||
await BrowserTestUtils.waitForAttribute("hidden", otherBookmarks, expected);
|
||||
|
||||
ok(true, `Other Bookmarks folder "hidden" state should be ${expected}.`);
|
||||
}
|
||||
|
@ -319,59 +274,6 @@ function testNumberOfMenuPopupChildren(selector, expected) {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test helper for checking the 'checked' state of the "Show Other Bookmarks" menu item
|
||||
* after selecting it from the context menu.
|
||||
*
|
||||
* @param {Boolean} expectedCheckedState
|
||||
* Whether or not the menu item is checked.
|
||||
*/
|
||||
async function testOtherBookmarksCheckedState(expectedCheckedState) {
|
||||
await openToolbarContextMenu();
|
||||
|
||||
info("Check 'Show Other Bookmarks' menu item state");
|
||||
await openToolbarContextMenu();
|
||||
let otherBookmarksMenuItem = document.querySelector(
|
||||
"#show-other-bookmarks_PersonalToolbar"
|
||||
);
|
||||
|
||||
is(
|
||||
otherBookmarksMenuItem.getAttribute("checked"),
|
||||
`${expectedCheckedState}`,
|
||||
`Other Bookmarks item's checked state should be ${expectedCheckedState}`
|
||||
);
|
||||
|
||||
await closeToolbarContextMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test helper for checking whether or not the 'Show Other Bookmarks' menu item
|
||||
* appears in the toolbar's context menu.
|
||||
*
|
||||
* @param {Boolean} expected
|
||||
* Whether or not the menu item appears in the toolbar conext menu.
|
||||
*/
|
||||
async function testIsOtherBookmarksMenuItemShown(expected) {
|
||||
let toolbar = document.getElementById("PersonalToolbar");
|
||||
let contextMenu = document.getElementById("placesContext");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(toolbar, {
|
||||
type: "contextmenu",
|
||||
});
|
||||
await BrowserTestUtils.waitForPopupEvent(contextMenu, "shown");
|
||||
let otherBookmarksMenuItem = document.querySelector(
|
||||
"#show-other-bookmarks_PersonalToolbar"
|
||||
);
|
||||
|
||||
is(
|
||||
!!otherBookmarksMenuItem,
|
||||
expected,
|
||||
"'Show Other Bookmarks' menu item appearance state is correct."
|
||||
);
|
||||
|
||||
await closeToolbarContextMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for opening a menu popup.
|
||||
*
|
||||
|
@ -402,59 +304,3 @@ async function closeMenuPopup(popupSelector) {
|
|||
popup.hidePopup();
|
||||
await BrowserTestUtils.waitForPopupEvent(popup, "hidden");
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for opening the toolbar context menu.
|
||||
*/
|
||||
async function openToolbarContextMenu() {
|
||||
let contextMenu = document.getElementById("placesContext");
|
||||
let toolbar = document.getElementById("PersonalToolbar");
|
||||
EventUtils.synthesizeMouseAtCenter(toolbar, {
|
||||
type: "contextmenu",
|
||||
});
|
||||
await BrowserTestUtils.waitForPopupEvent(contextMenu, "shown");
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for closing the toolbar context menu.
|
||||
*/
|
||||
async function closeToolbarContextMenu() {
|
||||
let contextMenu = document.getElementById("placesContext");
|
||||
contextMenu.hidePopup();
|
||||
await BrowserTestUtils.waitForPopupEvent(contextMenu, "hidden");
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for setting up the bookmarks toolbar state. This ensures the beginning
|
||||
* of a task will always have the bookmark toolbar in a state that makes the
|
||||
* Other Bookmarks folder testable.
|
||||
*/
|
||||
async function setupBookmarksToolbar() {
|
||||
let toolbar = document.getElementById("PersonalToolbar");
|
||||
let wasCollapsed = toolbar.collapsed;
|
||||
|
||||
// Uncollapse the personal toolbar if needed.
|
||||
if (wasCollapsed) {
|
||||
await promiseSetToolbarVisibility(toolbar, true);
|
||||
}
|
||||
|
||||
await PlacesUtils.bookmarks.eraseEverything();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for selecting the "Show Other Bookmarks" menu item from the bookmarks
|
||||
* toolbar context menu.
|
||||
*/
|
||||
async function selectShowOtherBookmarksMenuItem() {
|
||||
info("Select 'Show Other Bookmarks' menu item");
|
||||
await openToolbarContextMenu();
|
||||
|
||||
let otherBookmarksMenuItem = document.querySelector(
|
||||
"#show-other-bookmarks_PersonalToolbar"
|
||||
);
|
||||
let contextMenu = document.getElementById("placesContext");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(otherBookmarksMenuItem, {});
|
||||
|
||||
await BrowserTestUtils.waitForPopupEvent(contextMenu, "hidden");
|
||||
}
|
||||
|
|
|
@ -64,7 +64,3 @@ toolbar-context-menu-bookmarks-toolbar-never-show =
|
|||
toolbar-context-menu-bookmarks-toolbar-on-new-tab =
|
||||
.label = Only on New Tab
|
||||
.accesskey = O
|
||||
|
||||
toolbar-context-menu-bookmarks-show-other-bookmarks =
|
||||
.label = Show Other Bookmarks
|
||||
.accesskey = h
|
||||
|
|
Загрузка…
Ссылка в новой задаче