From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../browser_962069_drag_to_overflow_chevron.js | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 browser/components/customizableui/test/browser_962069_drag_to_overflow_chevron.js (limited to 'browser/components/customizableui/test/browser_962069_drag_to_overflow_chevron.js') diff --git a/browser/components/customizableui/test/browser_962069_drag_to_overflow_chevron.js b/browser/components/customizableui/test/browser_962069_drag_to_overflow_chevron.js new file mode 100644 index 0000000000..5337110482 --- /dev/null +++ b/browser/components/customizableui/test/browser_962069_drag_to_overflow_chevron.js @@ -0,0 +1,79 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +var originalWindowWidth; + +// Drag to overflow chevron should open the overflow panel. +add_task(async function () { + // Load a page so the identity box can be dragged. + BrowserTestUtils.startLoadingURIString(gBrowser, "http://mochi.test:8888/"); + await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); + + originalWindowWidth = window.outerWidth; + let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); + ok( + !navbar.hasAttribute("overflowing"), + "Should start with a non-overflowing toolbar." + ); + ok(CustomizableUI.inDefaultState, "Should start in default state."); + window.resizeTo(kForceOverflowWidthPx, window.outerHeight); + await TestUtils.waitForCondition(() => navbar.hasAttribute("overflowing")); + ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar."); + + let widgetOverflowPanel = document.getElementById("widget-overflow"); + let panelShownPromise = promisePanelElementShown(window, widgetOverflowPanel); + let identityBox = document.getElementById("identity-icon-box"); + let overflowChevron = document.getElementById("nav-bar-overflow-button"); + + // Listen for hiding immediately so we don't miss the event because of the + // async-ness of the 'shown' yield... + let panelHiddenPromise = promisePanelElementHidden( + window, + widgetOverflowPanel + ); + + var ds = Cc["@mozilla.org/widget/dragservice;1"].getService( + Ci.nsIDragService + ); + + ds.startDragSessionForTests( + Ci.nsIDragService.DRAGDROP_ACTION_MOVE | + Ci.nsIDragService.DRAGDROP_ACTION_COPY | + Ci.nsIDragService.DRAGDROP_ACTION_LINK + ); + try { + var [result, dataTransfer] = EventUtils.synthesizeDragOver( + identityBox, + overflowChevron + ); + + // Wait for showing panel before ending drag session. + await panelShownPromise; + + EventUtils.synthesizeDropAfterDragOver( + result, + dataTransfer, + overflowChevron + ); + } finally { + ds.endDragSession(true); + } + + info("Overflow panel is shown."); + + widgetOverflowPanel.hidePopup(); + await panelHiddenPromise; +}); + +add_task(async function () { + window.resizeTo(originalWindowWidth, window.outerHeight); + let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); + await TestUtils.waitForCondition(() => !navbar.hasAttribute("overflowing")); + ok( + !navbar.hasAttribute("overflowing"), + "Should not have an overflowing toolbar." + ); +}); -- cgit v1.2.3