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): respect first party url in intercepted set-cookie (soup) (#9320)

Yury Semikhatskyec7ae4e96bd3
diff --git a/browser_patches/webkit/BUILD_NUMBER b/browser_patches/webkit/BUILD_NUMBER
index 6de55704f5..4137a0aeda 100644
--- a/browser_patches/webkit/BUILD_NUMBER
+++ b/browser_patches/webkit/BUILD_NUMBER
@@ -1,2 +1,2 @@
-1555
-Changed: [email protected] Mon Oct 4 22:10:59 PDT 2021
+1556
+Changed: [email protected] Tue 05 Oct 2021 12:17:40 PM PDT
diff --git a/browser_patches/webkit/patches/bootstrap.diff b/browser_patches/webkit/patches/bootstrap.diff
index 7639f76a21..bd50cb6d3a 100644
--- a/browser_patches/webkit/patches/bootstrap.diff
+++ b/browser_patches/webkit/patches/bootstrap.diff
@@ -8601,26 +8601,34 @@ index 4b9491c11543f2b60f12d36e9e6a0cbaae34a72e..e907fc00a2a426384ce1e471847911c9
SocketStreamHandleImpl::~SocketStreamHandleImpl()
diff --git a/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp b/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp
-index 5b32534e2bcaf1701331e9541013b8a5c38c4d36..efee59ab00e99bc0e5d4374cc0a474461c2c1386 100644
+index 5b32534e2bcaf1701331e9541013b8a5c38c4d36..44ca33a774629841214ab3233f8a064557976e78 100644
--- a/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp
+++ b/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp
-@@ -408,6 +408,22 @@ void NetworkStorageSession::setCookie(const Cookie& cookie)
+@@ -408,6 +408,30 @@ void NetworkStorageSession::setCookie(const Cookie& cookie)
soup_cookie_jar_add_cookie(cookieStorage(), cookie.toSoupCookie());
}
-+void NetworkStorageSession::setCookiesFromResponse(const URL&, const URL& url, const String& setCookieValue)
++void NetworkStorageSession::setCookiesFromResponse(const URL& firstParty, const URL& url, const String& setCookieValue)
+{
+ auto origin = urlToSoupURI(url);
+ if (!origin)
+ return;
+
++ auto firstPartyURI = urlToSoupURI(firstParty);
++ if (!firstPartyURI)
++ return;
++
+ for (auto& cookieString : setCookieValue.split('\n')) {
+ GUniquePtr<SoupCookie> cookie(soup_cookie_parse(cookieString.utf8().data(), origin.get()));
+
+ if (!cookie)
+ continue;
+
-+ soup_cookie_jar_add_cookie(cookieStorage(), cookie.release());
++#if SOUP_CHECK_VERSION(2, 67, 1)
++ soup_cookie_jar_add_cookie_full(cookieStorage(), cookie.release(), origin.get(), firstPartyURI.get());
++#else
++ soup_cookie_jar_add_cookie_with_first_party(cookieStorage(), firstPartyURI.get(), cookie.release());
++#endif
+ }
+}
+