Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

browser(webkit): don't show context menus for headless windows (#2755)

Joel Einbindercd180474ee5e
diff --git a/browser_patches/webkit/patches/bootstrap.diff b/browser_patches/webkit/patches/bootstrap.diff
index d16900f8cf..89bef2072f 100644
--- a/browser_patches/webkit/patches/bootstrap.diff
+++ b/browser_patches/webkit/patches/bootstrap.diff
@@ -13682,6 +13682,19 @@ index 0000000000000000000000000000000000000000..135a60361fa8fbf907382625e7c8dd4e
+}
+
+} // namespace WebKit
+diff --git a/Source/WebKit/UIProcess/win/WebContextMenuProxyWin.cpp b/Source/WebKit/UIProcess/win/WebContextMenuProxyWin.cpp
+index aa171f48bc40a96a86d951451b578f609c573fce..8cdc2ff1e3a2ce3d05aacc46a83521c02442dd44 100644
+--- a/Source/WebKit/UIProcess/win/WebContextMenuProxyWin.cpp
++++ b/Source/WebKit/UIProcess/win/WebContextMenuProxyWin.cpp
+@@ -105,6 +105,8 @@ void WebContextMenuProxyWin::showContextMenuWithItems(Vector<Ref<WebContextMenuI
+ UINT flags = TPM_RIGHTBUTTON | TPM_TOPALIGN | TPM_VERPOSANIMATION | TPM_HORIZONTAL | TPM_LEFTALIGN | TPM_HORPOSANIMATION;
+ POINT pt { m_context.menuLocation().x(), m_context.menuLocation().y() };
+ HWND wnd = m_page.viewWidget();
++ if (!::IsWindowVisibile(wnd))
++ return;
+ ::ClientToScreen(wnd, &pt);
+ ::TrackPopupMenuEx(m_menu, flags, pt.x, pt.y, m_page.viewWidget(), nullptr);
+ }
diff --git a/Source/WebKit/UIProcess/win/WebPageInspectorEmulationAgentWin.cpp b/Source/WebKit/UIProcess/win/WebPageInspectorEmulationAgentWin.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..62b841fe1d0de2296e1c61e328cff564f5aa1c0f