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): ctrl+click on windows (#11667)

Yury Semikhatsky84a5400d0db5
diff --git a/browser_patches/webkit/BUILD_NUMBER b/browser_patches/webkit/BUILD_NUMBER
index 9ea4ce9d3f..f39ae9fa73 100644
--- a/browser_patches/webkit/BUILD_NUMBER
+++ b/browser_patches/webkit/BUILD_NUMBER
@@ -1,2 +1,2 @@
-1603
-Changed: [email protected] Wed Jan 26 15:11:07 PST 2022
+1604
+Changed: [email protected] Thu, Jan 27, 2022 1:59:07 AM
diff --git a/browser_patches/webkit/embedder/Playwright/win/WebKitBrowserWindow.cpp b/browser_patches/webkit/embedder/Playwright/win/WebKitBrowserWindow.cpp
index 23d99e5b13..5116eba952 100644
--- a/browser_patches/webkit/embedder/Playwright/win/WebKitBrowserWindow.cpp
+++ b/browser_patches/webkit/embedder/Playwright/win/WebKitBrowserWindow.cpp
@@ -100,6 +100,7 @@ WebKitBrowserWindow::WebKitBrowserWindow(BrowserWindowClient& client, HWND mainW
policyClient.base.version = 1;
policyClient.base.clientInfo = this;
policyClient.decidePolicyForResponse_deprecatedForUseWithV0 = decidePolicyForResponse;
+ policyClient.decidePolicyForNavigationAction = decidePolicyForNavigationAction;
WKPageSetPagePolicyClient(page, &policyClient.base);
resetZoom();
}
@@ -384,6 +385,20 @@ void WebKitBrowserWindow::didNotHandleKeyEvent(WKPageRef, WKNativeEventPtr event
PostMessage(thisWindow.m_hMainWnd, event->message, event->wParam, event->lParam);
}
+void WebKitBrowserWindow::decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKFrameRef originatingFrame, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
+{
+ WebKitBrowserWindow* browserWindow = reinterpret_cast<WebKitBrowserWindow*>(const_cast<void*>(clientInfo));
+ if (navigationType == kWKFrameNavigationTypeLinkClicked &&
+ mouseButton == kWKEventMouseButtonLeftButton &&
+ (modifiers & (kWKEventModifiersShiftKey | kWKEventModifiersControlKey)) != 0) {
+ WKRetainPtr<WKPageRef> newPage = createViewCallback(WKPageCopyPageConfiguration(page), false);
+ WKPageLoadURLRequest(newPage.get(), request);
+ WKFramePolicyListenerIgnore(listener);
+ return;
+ }
+ WKFramePolicyListenerUse(listener);
+}
+
void WebKitBrowserWindow::decidePolicyForResponse(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
{
if (WKURLResponseIsAttachment(response))
diff --git a/browser_patches/webkit/embedder/Playwright/win/WebKitBrowserWindow.h b/browser_patches/webkit/embedder/Playwright/win/WebKitBrowserWindow.h
index ce9270608a..a8d08516c1 100644
--- a/browser_patches/webkit/embedder/Playwright/win/WebKitBrowserWindow.h
+++ b/browser_patches/webkit/embedder/Playwright/win/WebKitBrowserWindow.h
@@ -72,6 +72,7 @@ private:
static void handleJavaScriptDialog(WKPageRef page, bool accept, WKStringRef value, const void *clientInfo);
static WKRect getWindowFrame(WKPageRef page, const void *clientInfo);
static void didNotHandleKeyEvent(WKPageRef, WKNativeEventPtr, const void*);
+ static void decidePolicyForNavigationAction(WKPageRef, WKFrameRef, WKFrameNavigationType, WKEventModifiers, WKEventMouseButton, WKFrameRef, WKURLRequestRef, WKFramePolicyListenerRef, WKTypeRef, const void* clientInfo);
static void decidePolicyForResponse(WKPageRef, WKFrameRef, WKURLResponseRef, WKURLRequestRef, WKFramePolicyListenerRef, WKTypeRef, const void*);
BrowserWindowClient& m_client;