tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit bb07ce96c7dbe2146955667387c72460b75182b3
parent 40b55ca8d8f1e4fd04fab57250d296d56bf4cd91
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date:   Thu, 16 Oct 2025 07:21:24 +0000

Bug 1977584 - When creating a popup as a native context menu, destroy any potential pre-existing widget. r=layout-reviewers,dshin

I think this is a test-only issue because we shouldn't be showing the
native menu as non-native some of the time. But probably some tests do
that, causing asserts to fire.

Differential Revision: https://phabricator.services.mozilla.com/D268704

Diffstat:
Mlayout/xul/nsMenuPopupFrame.cpp | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/layout/xul/nsMenuPopupFrame.cpp b/layout/xul/nsMenuPopupFrame.cpp @@ -975,6 +975,14 @@ void nsMenuPopupFrame::InitializePopupAsNativeContextMenu( mAnchorType = MenuPopupAnchorType::Point; mPositionedOffset = 0; mPositionedByMoveToRect = false; + // Native context menus don't call PrepareWidget(), so if we have a widget + // already (which generally should only be possible on tests, since + // otherwise we shouldn't ever mix native / non-native for the same popup) we + // should destroy it now. + if (mExpirationState.IsTracked()) { + PopupExpirationTracker::Get()->RemoveObject(this); + } + DestroyWidget(); } void nsMenuPopupFrame::InitializePopupAtRect(nsIContent* aTriggerContent,