Title: [287000] trunk
Revision
287000
Author
chris.r...@sony.com
Date
2021-12-13 17:52:38 -0800 (Mon, 13 Dec 2021)

Log Message

[Curl] Improve curl's cookie conformance in WPT
https://bugs.webkit.org/show_bug.cgi?id=232722

Reviewed by Fujii Hironori.

Source/WebCore:

Fix some cases where CookieJarDB differs from WPT expectations.

* platform/network/curl/CookieJarDB.cpp:
__Secure and __Host prefixes are now stricter.
Don't allow empty cookies to be set.
* platform/network/curl/CookieUtil.cpp:
Empty paths should override previous paths in the cookie list.
* platform/network/curl/NetworkStorageSessionCurl.cpp:

Tools:

* WebKitTestRunner/TestController.cpp: Use a unique cookie file for each test on windows

LayoutTests:

Add baseline for wpt cookie tests on wincairo

* platform/wincairo/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (286999 => 287000)


--- trunk/LayoutTests/ChangeLog	2021-12-14 01:50:21 UTC (rev 286999)
+++ trunk/LayoutTests/ChangeLog	2021-12-14 01:52:38 UTC (rev 287000)
@@ -1,3 +1,14 @@
+2021-12-13  Christopher Reid  <chris.r...@sony.com>
+
+        [Curl] Improve curl's cookie conformance in WPT
+        https://bugs.webkit.org/show_bug.cgi?id=232722
+
+        Reviewed by Fujii Hironori.
+
+        Add baseline for wpt cookie tests on wincairo
+
+        * platform/wincairo/TestExpectations:
+
 2021-12-13  Robert Jenner  <jen...@apple.com>
 
         [ iOS ] 8 imported/w3c/web-platform-tests/fetch/api (layout-tests) are flaky text failures

Modified: trunk/LayoutTests/platform/wincairo/TestExpectations (286999 => 287000)


--- trunk/LayoutTests/platform/wincairo/TestExpectations	2021-12-14 01:50:21 UTC (rev 286999)
+++ trunk/LayoutTests/platform/wincairo/TestExpectations	2021-12-14 01:52:38 UTC (rev 287000)
@@ -1427,6 +1427,35 @@
 storage/indexeddb/modern/aborted-put.html [ Timeout Pass ]
 [ Debug ] storage/indexeddb/modern/index-rename-1.html [ Skip ]
 
+# Flaky values in WPT cookie expectations
+imported/w3c/web-platform-tests/cookies/prefix/__secure.header.https.html [ Pass Failure ]
+imported/w3c/web-platform-tests/cookies/samesite-none-secure/cookies-without-samesite-must-be-secure.https.tentative.html [ Pass Failure ]
+imported/w3c/web-platform-tests/cookies/samesite/iframe.document.https.html [ Pass Failure ]
+imported/w3c/web-platform-tests/cookies/samesite/multiple-samesite-attributes.https.html [ Pass Failure ]
+imported/w3c/web-platform-tests/cookies/samesite/sandbox-iframe-nested.https.html [ Pass Failure ]
+imported/w3c/web-platform-tests/cookies/samesite/sandbox-iframe-subresource.https.html [ Pass Failure ]
+imported/w3c/web-platform-tests/cookies/samesite/setcookie-lax.https.html [ Pass Failure ]
+imported/w3c/web-platform-tests/cookies/samesite/setcookie-navigation.https.html [ Pass Failure ]
+imported/w3c/web-platform-tests/cookies/schemeful-same-site/schemeful-iframe-subresource.tentative.html [ Pass Failure ]
+imported/w3c/web-platform-tests/cookies/schemeful-same-site/schemeful-navigation.tentative.html [ Pass Failure ]
+imported/w3c/web-platform-tests/cookies/schemeful-same-site/schemeful-subresource.tentative.html [ Pass Failure ]
+
+# WPT diff failures that need more investigation
+imported/w3c/web-platform-tests/cookies/domain/domain-attribute-host-with-leading-period.sub.https.html [ Failure ]
+imported/w3c/web-platform-tests/cookies/encoding/charset.html [ Failure ]
+imported/w3c/web-platform-tests/cookies/name/name-ctl.html [ Failure ]
+imported/w3c/web-platform-tests/cookies/secure/set-from-dom.sub.html [ Failure ]
+imported/w3c/web-platform-tests/cookies/secure/set-from-http.sub.html [ Failure ]
+imported/w3c/web-platform-tests/cookies/secure/set-from-ws.sub.html [ Failure ]
+imported/w3c/web-platform-tests/cookies/value/value-ctl.html [ Failure ]
+imported/w3c/web-platform-tests/cookies/value/value.html [ Failure ]
+
+# Skip WPT tests that timeout
+imported/w3c/web-platform-tests/cookies/samesite/form-get-blank-reload.https.html [ Skip ]
+imported/w3c/web-platform-tests/cookies/samesite/form-get-blank.https.html [ Skip ]
+imported/w3c/web-platform-tests/cookies/samesite/form-post-blank-reload.https.html [ Skip ]
+imported/w3c/web-platform-tests/cookies/samesite/form-post-blank.https.html [ Skip ]
+
 ################################################################################
 ############################   End Storage Issues   ############################
 ################################################################################
@@ -1548,7 +1577,6 @@
 imported/w3c/web-platform-tests/compat [ Skip ]
 imported/w3c/web-platform-tests/console [ Skip ]
 imported/w3c/web-platform-tests/content-security-policy [ Skip ]
-imported/w3c/web-platform-tests/cookies [ Skip ]
 imported/w3c/web-platform-tests/cors [ Skip ]
 imported/w3c/web-platform-tests/credential-management [ Skip ]
 imported/w3c/web-platform-tests/css [ Skip ]

Added: trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/attributes/invalid-expected.txt (0 => 287000)


--- trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/attributes/invalid-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/attributes/invalid-expected.txt	2021-12-14 01:52:38 UTC (rev 287000)
@@ -0,0 +1,28 @@
+
+PASS Set cookie with invalid attribute
+PASS Set cookie ending with invalid attribute.
+PASS Set cookie ending with quoted invalid attribute.
+PASS Set cookie ending with double-quoted invalid attribute.
+PASS Set cookie ending with invalid attribute equals.
+PASS Set cookie with two invalid attributes (lol="aaa and bbb).
+PASS Set cookie ending with two invalid attributes (lol="aaa and bbb).
+PASS Set cookie for quoted Secure attribute
+PASS Set cookie for Secure qux
+PASS Ignore invalid attribute name with comma
+PASS Ignore invalid attribute value with comma
+PASS Set cookie ignoring multiple invalid attributes, whitespace, and semicolons
+PASS Set cookie with multiple '='s in its value, ignoring multiple invalid attributes, whitespace, and semicolons
+PASS Set cookie with (invalid) version=1 attribute
+PASS Set cookie with (invalid) version=1000 attribute
+PASS Set cookie ignoring anything after ; (which looks like an invalid attribute)
+PASS Set cookie ignoring anything after ; (which looks like an invalid attribute, with no trailing semicolon)
+PASS Ignore keys after semicolon
+PASS Ignore attributes after semicolon
+PASS Ignore `Set-Cookie: =`
+PASS Ignore empty cookie string
+PASS Ignore `Set-Cookie: =` with other `Set-Cookie` headers
+PASS Ignore name- and value-less `Set-Cookie: ; bar`
+PASS Ignore name- and value-less `Set-Cookie:    `
+PASS Ignore name- and value-less `Set-Cookie: \t`
+PASS Ignore cookie with domain that won't domain match (along with other invalid noise)
+

Added: trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/attributes/max-age-expected.txt (0 => 287000)


--- trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/attributes/max-age-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/attributes/max-age-expected.txt	2021-12-14 01:52:38 UTC (rev 287000)
@@ -0,0 +1,12 @@
+
+PASS Ignore max-age attribute with invalid non-zero-digit (containing a comma)
+PASS Set cookie with age
+PASS Set no cookie with max-age=0
+PASS Set no cookie with max-age=-1
+PASS Set no cookie with max-age=-20
+PASS Set multiple cookies with max-age attribute
+PASS Expire later cookie with same name and max-age=0
+PASS Expire later cookie with same name and max-age=0, and don't set cookie with max-age=0
+PASS Set mulitiple cookies with valid max-age values
+PASS Don't set multiple cookies with max-age=0
+

Added: trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/name/name-expected.txt (0 => 287000)


--- trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/name/name-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/name/name-expected.txt	2021-12-14 01:52:38 UTC (rev 287000)
@@ -0,0 +1,46 @@
+
+PASS Set valueless cookie to its name with empty value
+PASS Set a nameless cookie (that has an = in its value)
+PASS Set a nameless cookie (that has multiple ='s in its value)
+PASS Set a nameless cookie
+PASS Remove trailing WSP characters from the name string
+PASS Remove leading WSP characters from the name string
+PASS Only return the new cookie (with the same name)
+PASS Ignore invalid attributes after nameless cookie
+PASS Ignore invalid attributes after valid name (that looks like Cookie2 Version attribute)
+PASS Set a cookie that has whitespace in its name
+PASS Set a nameless cookie ignoring characters after first ;
+PASS Set a nameless cookie ignoring characters after first ; (2)
+PASS Return the most recent nameless cookie
+PASS Return the most recent nameless cookie, without leading =
+PASS Return the most recent nameless cookie, even if preceded by =
+PASS Return the most recent nameless cookie, even if preceded by =, in addition to other valid cookie
+PASS Use last value for cookies with identical names
+PASS Keep first-in, first-out name order
+PASS Keep first-in, first-out single-char name order
+PASS Keep non-alphabetic first-in, first-out name order
+PASS Keep first-in, first-out order if comma-separated
+PASS Set nameless cookie, given `Set-Cookie: =test16`
+PASS Overwrite nameless cookie
+PASS Ignore cookie with empty name and empty value
+PASS Ignore cookie with no name or value
+PASS URL-encoded cookie name is not decoded
+PASS Name is set as expected for a=test
+PASS Name is set as expected for 1=test
+PASS Name is set as expected for $=test
+PASS Name is set as expected for !a=test
+PASS Name is set as expected for @a=test
+PASS Name is set as expected for #a=test
+PASS Name is set as expected for $a=test
+PASS Name is set as expected for %a=test
+PASS Name is set as expected for ^a=test
+PASS Name is set as expected for &a=test
+PASS Name is set as expected for *a=test
+PASS Name is set as expected for (a=test
+PASS Name is set as expected for )a=test
+PASS Name is set as expected for -a=test
+PASS Name is set as expected for _a=test
+PASS Name is set as expected for +=test
+PASS Name is set as expected for "a=test
+PASS Name is set as expected for "a=b"=test
+

Added: trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/ordering/ordering.sub-expected.txt (0 => 287000)


--- trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/ordering/ordering.sub-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/ordering/ordering.sub-expected.txt	2021-12-14 01:52:38 UTC (rev 287000)
@@ -0,0 +1,7 @@
+
+PASS Test cookie ordering
+FAIL Cookies with longer path attribute values are ordered before shorter ones assert_equals: The cookie was set as expected. expected "testF=1; testB=1; testC=1; testE=1" but got "testB=1; testC=1"
+FAIL Cookies with longer path attribute values are ordered before shorter ones (2) assert_equals: The cookie was set as expected. expected "testG=2; testB=2; testF=2; testH=2; testC=2" but got "testB=2; testH=2; testC=2"
+PASS Cookies with longer paths are listed before cookies with shorter paths
+PASS For equal length paths, list the cookie with an earlier creation time first
+

Added: trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/path/match-expected.txt (0 => 287000)


--- trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/path/match-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/path/match-expected.txt	2021-12-14 01:52:38 UTC (rev 287000)
@@ -0,0 +1,18 @@
+
+PASS `document.cookie` on /cookies/resources/echo-cookie.html sets cookie with path: /
+PASS `document.cookie` on /cookies/resources/echo-cookie.html sets cookie with path: match.html
+PASS `document.cookie` on /cookies/resources/echo-cookie.html sets cookie with path: cookies
+PASS `document.cookie` on /cookies/resources/echo-cookie.html sets cookie with path: /cookies
+PASS `document.cookie` on /cookies/resources/echo-cookie.html sets cookie with path: /cookies/
+PASS `document.cookie` on /cookies/resources/echo-cookie.html sets cookie with path: /cookies/resources/echo-cookie.html
+PASS `document.cookie` on /cookies/resources/echo-cookie.html DOES NOT set cookie for path: /cook
+PASS `document.cookie` on /cookies/resources/echo-cookie.html DOES NOT set cookie for path: /w/
+PASS `Set-Cookie` on /cookies/resources/echo-cookie.html sets cookie with path: /
+PASS `Set-Cookie` on /cookies/resources/echo-cookie.html sets cookie with path: match.html
+PASS `Set-Cookie` on /cookies/resources/echo-cookie.html sets cookie with path: cookies
+PASS `Set-Cookie` on /cookies/resources/echo-cookie.html sets cookie with path: /cookies
+PASS `Set-Cookie` on /cookies/resources/echo-cookie.html sets cookie with path: /cookies/
+PASS `Set-Cookie` on /cookies/resources/echo-cookie.html sets cookie with path: /cookies/resources/echo-cookie.html
+PASS `Set-Cookie` on /cookies/resources/echo-cookie.html DOES NOT set cookie for path: /cook
+PASS `Set-Cookie` on /cookies/resources/echo-cookie.html DOES NOT set cookie for path: /w/
+

Added: trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/samesite/about-blank-subresource.https-expected.txt (0 => 287000)


--- trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/samesite/about-blank-subresource.https-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/samesite/about-blank-subresource.https-expected.txt	2021-12-14 01:52:38 UTC (rev 287000)
@@ -0,0 +1,3 @@
+
+PASS SameSite cookies on subresource of top-level about:blank window
+

Added: trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/samesite/about-blank-toplevel.https-expected.txt (0 => 287000)


--- trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/samesite/about-blank-toplevel.https-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/wincairo/imported/w3c/web-platform-tests/cookies/samesite/about-blank-toplevel.https-expected.txt	2021-12-14 01:52:38 UTC (rev 287000)
@@ -0,0 +1,3 @@
+
+PASS SameSite cookies with top-level about:blank window
+

Modified: trunk/Source/WebCore/ChangeLog (286999 => 287000)


--- trunk/Source/WebCore/ChangeLog	2021-12-14 01:50:21 UTC (rev 286999)
+++ trunk/Source/WebCore/ChangeLog	2021-12-14 01:52:38 UTC (rev 287000)
@@ -1,3 +1,19 @@
+2021-12-13  Christopher Reid  <chris.r...@sony.com>
+
+        [Curl] Improve curl's cookie conformance in WPT
+        https://bugs.webkit.org/show_bug.cgi?id=232722
+
+        Reviewed by Fujii Hironori.
+
+        Fix some cases where CookieJarDB differs from WPT expectations.
+
+        * platform/network/curl/CookieJarDB.cpp:
+        __Secure and __Host prefixes are now stricter.
+        Don't allow empty cookies to be set.
+        * platform/network/curl/CookieUtil.cpp:
+        Empty paths should override previous paths in the cookie list.
+        * platform/network/curl/NetworkStorageSessionCurl.cpp:
+
 2021-12-13  J Pascoe  <j_pas...@apple.com>
 
         [WebAuthn] Allow same-site, cross-origin iframe get()

Modified: trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp (286999 => 287000)


--- trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp	2021-12-14 01:50:21 UTC (rev 286999)
+++ trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp	2021-12-14 01:52:38 UTC (rev 287000)
@@ -488,6 +488,18 @@
     return statement.step() == SQLITE_ROW;
 }
 
+static bool checkSecureCookie(const Cookie& cookie)
+{
+    if (cookie.name.startsWith("__Secure-"_s) && !cookie.secure)
+        return false;
+
+    // Cookies for __Host must have the Secure attribute, path explicitly set to "/", and no domain attribute
+    if (cookie.name.startsWith("__Host-"_s) && (!cookie.secure || cookie.path != "/"_s || !cookie.domain.isEmpty()))
+        return false;
+
+    return true;
+}
+
 bool CookieJarDB::canAcceptCookie(const Cookie& cookie, const URL& firstParty, const URL& url, CookieJarDB::Source source)
 {
 #if ENABLE(PUBLIC_SUFFIX_LIST)
@@ -538,9 +550,12 @@
         return false;
 
     auto cookie = CookieUtil::parseCookieHeader(body);
-    if (!cookie)
+    if (!cookie || (cookie->name.isEmpty() && cookie->value.isEmpty()))
         return false;
 
+    if (!checkSecureCookie(*cookie))
+        return false;
+
     if (cookie->domain.isEmpty())
         cookie->domain = url.host().convertToASCIILowercase();
 

Modified: trunk/Source/WebCore/platform/network/curl/CookieUtil.cpp (286999 => 287000)


--- trunk/Source/WebCore/platform/network/curl/CookieUtil.cpp	2021-12-14 01:50:21 UTC (rev 286999)
+++ trunk/Source/WebCore/platform/network/curl/CookieUtil.cpp	2021-12-14 01:52:38 UTC (rev 287000)
@@ -124,15 +124,23 @@
             // If there is a max-age attribute as well as an expires attribute
             // the rightmost max-age attribute takes precedence.
             hasMaxAge = true;
+        } else {
+            result.session = true;
+            result.expires = std::nullopt;
         }
     } else if (equalIgnoringASCIICase(attributeName, "expires") && !hasMaxAge) {
         if (auto expiryTime = parseExpiresMS(attributeValue.utf8().data())) {
             result.expires = expiryTime.value();
             result.session = false;
+        } else if (!hasMaxAge) {
+            result.session = true;
+            result.expires = std::nullopt;
         }
     } else if (equalIgnoringASCIICase(attributeName, "path")) {
         if (!attributeValue.isEmpty() && attributeValue.startsWith('/'))
             result.path = attributeValue;
+        else
+            result.path = emptyString();
     }
 }
 

Modified: trunk/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp (286999 => 287000)


--- trunk/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp	2021-12-14 01:50:21 UTC (rev 286999)
+++ trunk/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp	2021-12-14 01:52:38 UTC (rev 287000)
@@ -64,8 +64,10 @@
         for (const auto& cookie : *result) {
             if (!cookies.isEmpty())
                 cookies.append("; ");
-            cookies.append(cookie.name);
-            cookies.append("=");
+            if (!cookie.name.isEmpty()) {
+                cookies.append(cookie.name);
+                cookies.append("=");
+            }
             cookies.append(cookie.value);
         }
     }

Modified: trunk/Tools/ChangeLog (286999 => 287000)


--- trunk/Tools/ChangeLog	2021-12-14 01:50:21 UTC (rev 286999)
+++ trunk/Tools/ChangeLog	2021-12-14 01:52:38 UTC (rev 287000)
@@ -1,3 +1,12 @@
+2021-12-13  Christopher Reid  <chris.r...@sony.com>
+
+        [Curl] Improve curl's cookie conformance in WPT
+        https://bugs.webkit.org/show_bug.cgi?id=232722
+
+        Reviewed by Fujii Hironori.
+
+        * WebKitTestRunner/TestController.cpp: Use a unique cookie file for each test on windows
+
 2021-12-13  Jean-Yves Avenard  <j...@apple.com>
 
         Add SharedBufferBuilder class

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (286999 => 287000)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2021-12-14 01:50:21 UTC (rev 286999)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2021-12-14 01:52:38 UTC (rev 287000)
@@ -608,6 +608,9 @@
         WKWebsiteDataStoreConfigurationSetMediaKeysStorageDirectory(configuration, toWK(makeString(temporaryFolder, pathSeparator, "MediaKeys", pathSeparator, randomNumber)).get());
         WKWebsiteDataStoreConfigurationSetResourceLoadStatisticsDirectory(configuration, toWK(makeString(temporaryFolder, pathSeparator, "ResourceLoadStatistics", pathSeparator, randomNumber)).get());
         WKWebsiteDataStoreConfigurationSetServiceWorkerRegistrationDirectory(configuration, toWK(makeString(temporaryFolder, pathSeparator, "ServiceWorkers", pathSeparator, randomNumber)).get());
+#if PLATFORM(WIN)
+        WKWebsiteDataStoreConfigurationSetCookieStorageFile(configuration, toWK(makeString(temporaryFolder, pathSeparator, "cookies", pathSeparator, randomNumber, pathSeparator, "cookiejar.db")).get());
+#endif
         WKWebsiteDataStoreConfigurationSetPerOriginStorageQuota(configuration, 400 * 1024);
         WKWebsiteDataStoreConfigurationSetNetworkCacheSpeculativeValidationEnabled(configuration, true);
         WKWebsiteDataStoreConfigurationSetStaleWhileRevalidateEnabled(configuration, true);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to