Diff
Modified: trunk/Source/WebDriver/ChangeLog (267918 => 267919)
--- trunk/Source/WebDriver/ChangeLog 2020-10-03 06:26:08 UTC (rev 267918)
+++ trunk/Source/WebDriver/ChangeLog 2020-10-03 06:28:13 UTC (rev 267919)
@@ -1,5 +1,20 @@
2020-10-02 Carlos Garcia Campos <[email protected]>
+ WebDriver: add support for same site cookies
+ https://bugs.webkit.org/show_bug.cgi?id=217222
+
+ Reviewed by Brian Burg.
+
+ * Session.cpp:
+ (WebDriver::parseAutomationCookie): Parse sameSite.
+ (WebDriver::builtAutomationCookie): Add sameSite to cookie.
+ (WebDriver::serializeCookie): Serialize sameSite.
+ * Session.h:
+ * WebDriverService.cpp:
+ (WebDriver::deserializeCookie): Deserialize sameSite.
+
+2020-10-02 Carlos Garcia Campos <[email protected]>
+
WebDriver: several issues when switching to new browser context
https://bugs.webkit.org/show_bug.cgi?id=217217
Modified: trunk/Source/WebDriver/Session.cpp (267918 => 267919)
--- trunk/Source/WebDriver/Session.cpp 2020-10-03 06:26:08 UTC (rev 267918)
+++ trunk/Source/WebDriver/Session.cpp 2020-10-03 06:28:13 UTC (rev 267919)
@@ -2395,6 +2395,10 @@
cookie.expiry = *expiry;
}
+ auto sameSite = cookieObject.getString("sameSite"_s);
+ if (!!sameSite)
+ cookie.sameSite = sameSite;
+
return cookie;
}
@@ -2409,6 +2413,7 @@
cookieObject->setBoolean("httpOnly"_s, cookie.httpOnly.valueOr(false));
cookieObject->setBoolean("session"_s, !cookie.expiry);
cookieObject->setDouble("expires"_s, cookie.expiry.valueOr(0));
+ cookieObject->setString("sameSite"_s, cookie.sameSite.valueOr("None"));
return cookieObject;
}
@@ -2427,6 +2432,8 @@
cookieObject->setBoolean("httpOnly"_s, cookie.httpOnly.value());
if (cookie.expiry)
cookieObject->setInteger("expiry"_s, cookie.expiry.value());
+ if (cookie.sameSite)
+ cookieObject->setString("sameSite"_s, cookie.sameSite.value());
return cookieObject;
}
Modified: trunk/Source/WebDriver/Session.h (267918 => 267919)
--- trunk/Source/WebDriver/Session.h 2020-10-03 06:26:08 UTC (rev 267918)
+++ trunk/Source/WebDriver/Session.h 2020-10-03 06:28:13 UTC (rev 267919)
@@ -67,6 +67,7 @@
Optional<bool> secure;
Optional<bool> httpOnly;
Optional<uint64_t> expiry;
+ Optional<String> sameSite;
};
InputSource& getOrCreateInputSource(const String& id, InputSource::Type, Optional<PointerType>);
Modified: trunk/Source/WebDriver/WebDriverService.cpp (267918 => 267919)
--- trunk/Source/WebDriver/WebDriverService.cpp 2020-10-03 06:26:08 UTC (rev 267918)
+++ trunk/Source/WebDriver/WebDriverService.cpp 2020-10-03 06:28:13 UTC (rev 267919)
@@ -1760,6 +1760,12 @@
return WTF::nullopt;
cookie.expiry = expiry.value();
}
+ if (auto value = cookieObject.getValue("sameSite"_s)) {
+ auto sameSite = value->asString();
+ if (sameSite != "None"_s && sameSite != "Lax"_s && sameSite != "Strict"_s)
+ return WTF::nullopt;
+ cookie.sameSite = sameSite;
+ }
return cookie;
}
Modified: trunk/Source/WebKit/ChangeLog (267918 => 267919)
--- trunk/Source/WebKit/ChangeLog 2020-10-03 06:26:08 UTC (rev 267918)
+++ trunk/Source/WebKit/ChangeLog 2020-10-03 06:28:13 UTC (rev 267919)
@@ -1,5 +1,19 @@
2020-10-02 Carlos Garcia Campos <[email protected]>
+ WebDriver: add support for same site cookies
+ https://bugs.webkit.org/show_bug.cgi?id=217222
+
+ Reviewed by Brian Burg.
+
+ * UIProcess/Automation/Automation.json: Add CookieSameSitePolicy enum and sameSite member to Cookie object.
+ * UIProcess/Automation/WebAutomationSession.cpp:
+ (WebKit::toProtocolSameSitePolicy): Convert WebCore same site policy to inspector protocol value.
+ (WebKit::toWebCoreSameSitePolicy): Convert inspector protocol same site policy to WebCore value.
+ (WebKit::buildObjectForCookie): Add sameSite.
+ (WebKit::WebAutomationSession::addSingleCookie): Set sameSite policy to cookie.
+
+2020-10-02 Carlos Garcia Campos <[email protected]>
+
WebDriver: several issues when switching to new browser context
https://bugs.webkit.org/show_bug.cgi?id=217217
Modified: trunk/Source/WebKit/UIProcess/Automation/Automation.json (267918 => 267919)
--- trunk/Source/WebKit/UIProcess/Automation/Automation.json 2020-10-03 06:26:08 UTC (rev 267918)
+++ trunk/Source/WebKit/UIProcess/Automation/Automation.json 2020-10-03 06:28:13 UTC (rev 267919)
@@ -226,6 +226,16 @@
]
},
{
+ "id": "CookieSameSitePolicy",
+ "type": "string",
+ "description": "Enumerates values for cookies same site policy",
+ "enum": [
+ "None",
+ "Lax",
+ "Strict"
+ ]
+ },
+ {
"id": "Cookie",
"type": "object",
"properties": [
@@ -237,7 +247,8 @@
{ "name": "size", "type": "integer", "description": "Cookie size." },
{ "name": "httpOnly", "type": "boolean", "description": "True if cookie is http-only." },
{ "name": "secure", "type": "boolean", "description": "True if cookie is secure." },
- { "name": "session", "type": "boolean", "description": "True in case of session cookie." }
+ { "name": "session", "type": "boolean", "description": "True in case of session cookie." },
+ { "name": "sameSite", "$ref": "CookieSameSitePolicy", "description": "Cookie same site policy." }
]
},
{
Modified: trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp (267918 => 267919)
--- trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp 2020-10-03 06:26:08 UTC (rev 267918)
+++ trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp 2020-10-03 06:28:13 UTC (rev 267919)
@@ -1279,6 +1279,32 @@
page->process().sendWithAsyncReply(Messages::WebAutomationSessionProxy::SetFilesForInputFileUpload(page->webPageID(), frameID, nodeHandle, WTFMove(newFileList)), WTFMove(completionHandler));
}
+static inline Inspector::Protocol::Automation::CookieSameSitePolicy toProtocolSameSitePolicy(WebCore::Cookie::SameSitePolicy policy)
+{
+ switch (policy) {
+ case WebCore::Cookie::SameSitePolicy::None:
+ return Inspector::Protocol::Automation::CookieSameSitePolicy::None;
+ case WebCore::Cookie::SameSitePolicy::Lax:
+ return Inspector::Protocol::Automation::CookieSameSitePolicy::Lax;
+ case WebCore::Cookie::SameSitePolicy::Strict:
+ return Inspector::Protocol::Automation::CookieSameSitePolicy::Strict;
+ }
+ RELEASE_ASSERT_NOT_REACHED();
+}
+
+static inline WebCore::Cookie::SameSitePolicy toWebCoreSameSitePolicy(Inspector::Protocol::Automation::CookieSameSitePolicy policy)
+{
+ switch (policy) {
+ case Inspector::Protocol::Automation::CookieSameSitePolicy::None:
+ return WebCore::Cookie::SameSitePolicy::None;
+ case Inspector::Protocol::Automation::CookieSameSitePolicy::Lax:
+ return WebCore::Cookie::SameSitePolicy::Lax;
+ case Inspector::Protocol::Automation::CookieSameSitePolicy::Strict:
+ return WebCore::Cookie::SameSitePolicy::Strict;
+ }
+ RELEASE_ASSERT_NOT_REACHED();
+}
+
static Ref<Inspector::Protocol::Automation::Cookie> buildObjectForCookie(const WebCore::Cookie& cookie)
{
return Inspector::Protocol::Automation::Cookie::create()
@@ -1291,6 +1317,7 @@
.setHttpOnly(cookie.httpOnly)
.setSecure(cookie.secure)
.setSession(cookie.session)
+ .setSameSite(toProtocolSameSitePolicy(cookie.sameSite))
.release();
}
@@ -1409,6 +1436,16 @@
cookie.httpOnly = *httpOnly;
+ auto sameSite = cookieObject->getString("sameSite"_s);
+ if (!sameSite)
+ ASYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(MissingParameter, "The parameter 'sameSite' was not found.");
+
+ auto parsedSameSite = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::CookieSameSitePolicy>(sameSite);
+ if (!parsedSameSite)
+ ASYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The parameter 'sameSite' has an unknown value.");
+
+ cookie.sameSite = toWebCoreSameSitePolicy(*parsedSameSite);
+
WebCookieManagerProxy& cookieManager = page->websiteDataStore().networkProcess().cookieManager();
cookieManager.setCookies(page->websiteDataStore().sessionID(), { cookie }, [callback]() {
callback->sendSuccess();