From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../browser/browser_toolbarbutton_menu_context.js | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 browser/components/places/tests/browser/browser_toolbarbutton_menu_context.js (limited to 'browser/components/places/tests/browser/browser_toolbarbutton_menu_context.js') diff --git a/browser/components/places/tests/browser/browser_toolbarbutton_menu_context.js b/browser/components/places/tests/browser/browser_toolbarbutton_menu_context.js new file mode 100644 index 0000000000..a87f26caab --- /dev/null +++ b/browser/components/places/tests/browser/browser_toolbarbutton_menu_context.js @@ -0,0 +1,72 @@ +CustomizableUI.addWidgetToArea( + "bookmarks-menu-button", + CustomizableUI.AREA_NAVBAR, + 4 +); +var bookmarksMenuButton = document.getElementById("bookmarks-menu-button"); +var BMB_menuPopup = document.getElementById("BMB_bookmarksPopup"); +var BMB_showAllBookmarks = document.getElementById("BMB_bookmarksShowAll"); +var contextMenu = document.getElementById("placesContext"); +var newBookmarkItem = document.getElementById("placesContext_new:bookmark"); + +waitForExplicitFinish(); +add_task(async function testPopup() { + info("Checking popup context menu before moving the bookmarks button"); + await checkPopupContextMenu(); + let pos = CustomizableUI.getPlacementOfWidget( + "bookmarks-menu-button" + ).position; + let target = CustomizableUI.AREA_FIXED_OVERFLOW_PANEL; + CustomizableUI.addWidgetToArea("bookmarks-menu-button", target); + CustomizableUI.addWidgetToArea( + "bookmarks-menu-button", + CustomizableUI.AREA_NAVBAR, + pos + ); + info("Checking popup context menu after moving the bookmarks button"); + await checkPopupContextMenu(); + CustomizableUI.reset(); +}); + +async function checkPopupContextMenu() { + let clickTarget = bookmarksMenuButton; + BMB_menuPopup.setAttribute("style", "transition: none;"); + let popupShownPromise = onPopupEvent(BMB_menuPopup, "shown"); + EventUtils.synthesizeMouseAtCenter(clickTarget, {}); + info("Waiting for bookmarks menu to be shown."); + await popupShownPromise; + let contextMenuShownPromise = onPopupEvent(contextMenu, "shown"); + EventUtils.synthesizeMouseAtCenter(BMB_showAllBookmarks, { + type: "contextmenu", + button: 2, + }); + info("Waiting for context menu on bookmarks menu to be shown."); + await contextMenuShownPromise; + ok( + !newBookmarkItem.hasAttribute("disabled"), + "New bookmark item shouldn't be disabled" + ); + let contextMenuHiddenPromise = onPopupEvent(contextMenu, "hidden"); + contextMenu.hidePopup(); + BMB_menuPopup.removeAttribute("style"); + info("Waiting for context menu on bookmarks menu to be hidden."); + await contextMenuHiddenPromise; + let popupHiddenPromise = onPopupEvent(BMB_menuPopup, "hidden"); + // Can't use synthesizeMouseAtCenter because the dropdown panel is in the way + EventUtils.synthesizeKey("KEY_Escape"); + info("Waiting for bookmarks menu to be hidden."); + await popupHiddenPromise; +} + +function onPopupEvent(popup, evt) { + let fullEvent = "popup" + evt; + return new Promise(resolve => { + let onPopupHandler = e => { + if (e.target == popup) { + popup.removeEventListener(fullEvent, onPopupHandler); + resolve(); + } + }; + popup.addEventListener(fullEvent, onPopupHandler); + }); +} -- cgit v1.2.3