Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: ca495b340ba6cccf8f05dc1dc0ac4e892924c53e
https://github.com/WebKit/WebKit/commit/ca495b340ba6cccf8f05dc1dc0ac4e892924c53e
Author: Yury Semikhatsky <[email protected]>
Date: 2026-08-18 (Tue, 18 Aug 2026)
Changed paths:
M Source/WebKit/UIProcess/WebContextMenuProxy.h
M Source/WebKit/UIProcess/WebPageProxy.cpp
M Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.h
M Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm
M Source/WebKit/UIProcess/win/WebContextMenuProxyWin.cpp
M Source/WebKit/UIProcess/win/WebContextMenuProxyWin.h
M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/mac/ContextMenuTests.mm
Log Message:
-----------
Context menu is not dismissed when its page is closed
https://bugs.webkit.org/show_bug.cgi?id=321746
Reviewed by Devin Rousso.
WebPageProxy::close() cancels tracking of the active popup menu, but only
drops its reference to the active context menu without dismissing it. On
macOS and Windows the menu runs a nested run loop that keeps the proxy
alive, so the menu stays on screen tracking a closed page.
Cancel tracking of the active context menu in close(), matching popup menus.
Implemented with -[NSMenu cancelTracking] on macOS and ::EndMenu() on
Windows. GTK needs no override since its menus are non-modal and popped down
by the proxy destructor; WPE shows no native menu.
Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/mac/ContextMenuTests.mm
* Source/WebKit/UIProcess/WebContextMenuProxy.h:
(WebKit::WebContextMenuProxy::cancelTracking):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::close):
* Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.h:
* Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm:
(WebKit::WebContextMenuProxyMac::cancelTracking):
* Source/WebKit/UIProcess/win/WebContextMenuProxyWin.cpp:
(WebKit::WebContextMenuProxyWin::cancelTracking):
(WebKit::WebContextMenuProxyWin::showContextMenuWithItems):
* Source/WebKit/UIProcess/win/WebContextMenuProxyWin.h:
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/mac/ContextMenuTests.mm:
(TestWebKitAPI::TEST(ContextMenuTests, MenuTrackingCancelledWhenPageCloses)):
Canonical link: https://commits.webkit.org/319401@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications