Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit 2008e96

Browse files
[Curl] Implement functions to use ResourceLoadStatistics.
https://bugs.webkit.org/show_bug.cgi?id=207692 Patch by Takashi Komori <[email protected]> on 2020-06-12 Reviewed by Don Olmstead. Implement functions which are required to implement ResourceLoadStatistics for Curl port. Source/WebCore: Tests: http/tests/resourceLoadStatistics/ * CMakeLists.txt: * platform/network/curl/CookieJarDB.cpp: (WebCore::CookieJarDB::openDatabase): (WebCore::CookieJarDB::setCookie): (WebCore::CookieJarDB::allDomains): (WebCore::CookieJarDB::deleteCookiesForHostname): * platform/network/curl/CookieJarDB.h: * platform/network/curl/NetworkStorageSessionCurl.cpp: (WebCore::NetworkStorageSession::setCookiesFromDOM const): (WebCore::NetworkStorageSession::setCookies): (WebCore::NetworkStorageSession::deleteCookiesForHostnames): (WebCore::NetworkStorageSession::getHostnamesWithCookies): Source/WebKit: In NetworkDataTaskCurl.cpp we check if we should block cookies and block if needed. Tests: http/tests/resourceLoadStatistics/ * NetworkProcess/NetworkDataTask.cpp: (WebKit::NetworkDataTask::create): * NetworkProcess/curl/NetworkDataTaskCurl.cpp: (WebKit::NetworkDataTaskCurl::NetworkDataTaskCurl): (WebKit::NetworkDataTaskCurl::createCurlRequest): (WebKit::NetworkDataTaskCurl::willPerformHTTPRedirection): (WebKit::NetworkDataTaskCurl::blockCookies): (WebKit::NetworkDataTaskCurl::unblockCookies): (WebKit::NetworkDataTaskCurl::shouldBlockCookies): (WebKit::NetworkDataTaskCurl::isThirdPartyRequest): * NetworkProcess/curl/NetworkDataTaskCurl.h: * NetworkProcess/curl/NetworkSessionCurl.cpp: (WebKit::NetworkSessionCurl::NetworkSessionCurl): * UIProcess/API/C/WKWebsiteDataStoreRef.cpp: (WKWebsiteDataStoreGetAllStorageAccessEntries): * UIProcess/API/C/WKWebsiteDataStoreRef.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::parameters): Tools: Tests: http/tests/resourceLoadStatistics/ * WebKitTestRunner/TestController.cpp: (WTR::GetAllStorageAccessEntriesCallbackContext::GetAllStorageAccessEntriesCallbackContext): (WTR::getAllStorageAccessEntriesCallback): (WTR::TestController::getAllStorageAccessEntries): LayoutTests: Tests: http/tests/resourceLoadStatistics/ * platform/wincairo-wk1/TestExpectations: * platform/wincairo/TestExpectations: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@262971 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent f546cdf commit 2008e96

File tree

18 files changed

+315
-18
lines changed

18 files changed

+315
-18
lines changed

LayoutTests/ChangeLog

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2020-06-12 Takashi Komori <[email protected]>
2+
3+
[Curl] Implement functions to use ResourceLoadStatistics.
4+
https://bugs.webkit.org/show_bug.cgi?id=207692
5+
6+
Reviewed by Don Olmstead.
7+
8+
Implement functions which are required to implement ResourceLoadStatistics for Curl port.
9+
10+
Tests: http/tests/resourceLoadStatistics/
11+
12+
* platform/wincairo-wk1/TestExpectations:
13+
* platform/wincairo/TestExpectations:
14+
115
2020-06-12 Yusuke Suzuki <[email protected]>
216

317
[ Mojave wk2 Release ] js/dom/unhandled-promise-rejection-console-no-report.html is flaky failing.

LayoutTests/platform/wincairo-wk1/TestExpectations

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,3 +309,6 @@ webkit.org/b/191498 http/tests/inspector/network/getSerializedCertificate.html [
309309

310310
# Skip IsLoggedIn
311311
http/tests/is-logged-in/ [ Skip ]
312+
313+
# Skip ResourceLoadStatistics
314+
http/tests/resourceLoadStatistics [ Skip ]

LayoutTests/platform/wincairo/TestExpectations

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,9 +1175,37 @@ http/tests/referrer-policy/no-referrer-when-downgrade/ [ Skip ]
11751175
http/tests/referrer-policy/unsafe-url/cross-origin-http-http.html [ Skip ]
11761176
http/tests/referrer-policy/unsafe-url/cross-origin-http.https.html [ Skip ]
11771177

1178-
# All timing out
1179-
http/tests/resourceLoadStatistics [ Skip ]
1178+
# ResourceLoadStatistics
1179+
http/tests/resourceLoadStatistics [ Pass ]
1180+
http/tests/resourceLoadStatistics/exemptDomains [ Skip ]
1181+
http/tests/resourceLoadStatistics/add-blocking-to-redirect-database.html [ Skip ]
1182+
http/tests/resourceLoadStatistics/add-blocking-to-redirect.html [ Skip ]
1183+
http/tests/resourceLoadStatistics/cookie-deletion-database.html [ Skip ]
1184+
http/tests/resourceLoadStatistics/cookie-deletion.html [ Skip ]
1185+
http/tests/resourceLoadStatistics/cookies-with-and-without-user-interaction-database.html [ Skip ]
1186+
http/tests/resourceLoadStatistics/cookies-with-and-without-user-interaction.html [ Skip ]
1187+
http/tests/resourceLoadStatistics/do-not-remove-blocking-in-redirect-database.html [ Skip ]
1188+
http/tests/resourceLoadStatistics/do-not-remove-blocking-in-redirect.html [ Skip ]
1189+
http/tests/resourceLoadStatistics/enforce-samesite-strict-based-on-top-frame-unique-redirects-to-database.html [ Skip ]
1190+
http/tests/resourceLoadStatistics/enforce-samesite-strict-based-on-top-frame-unique-redirects-to.html [ Skip ]
1191+
http/tests/resourceLoadStatistics/ping-to-prevalent-resource-database.html [ Skip ]
1192+
http/tests/resourceLoadStatistics/ping-to-prevalent-resource.html [ Skip ]
1193+
http/tests/resourceLoadStatistics/set-all-cookies-to-same-site-strict.html [ Skip ]
1194+
http/tests/resourceLoadStatistics/standalone-web-application-exempt-from-website-data-deletion-database.html [ Skip ]
1195+
http/tests/resourceLoadStatistics/standalone-web-application-exempt-from-website-data-deletion.html [ Skip ]
1196+
http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction-database.php [ Skip ]
1197+
http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction.php [ Skip ]
1198+
http/tests/resourceLoadStatistics/telemetry-generation.html [ Skip ]
1199+
http/tests/resourceLoadStatistics/third-party-cookie-blocking-ephemeral-database.html [ Skip ]
1200+
http/tests/resourceLoadStatistics/third-party-cookie-blocking-ephemeral.html [ Skip ]
1201+
http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction-database.html [ Skip ]
1202+
http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction.html [ Skip ]
1203+
http/tests/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time-database.html [ Skip ]
1204+
http/tests/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time.html [ Skip ]
1205+
http/tests/resourceLoadStatistics/user-interaction-reported-after-website-data-removal-database.html [ Skip ]
1206+
http/tests/resourceLoadStatistics/user-interaction-reported-after-website-data-removal.html [ Skip ]
11801207

1208+
# All timing out
11811209
http/tests/security [ Skip ]
11821210
http/tests/security/401-logout/401-logout.php [ Pass ]
11831211
http/tests/security/cookies/third-party-cookie-blocking.html [ Pass ]

Source/WebCore/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,7 @@ set(WebCore_NON_SVG_IDL_FILES
696696
dom/DocumentFragment.idl
697697
dom/DocumentFullscreen.idl
698698
dom/DocumentOrShadowRoot.idl
699+
dom/DocumentStorageAccess.idl
699700
dom/DocumentTouch.idl
700701
dom/DocumentType.idl
701702
dom/DragEvent.idl

Source/WebCore/ChangeLog

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
2020-06-12 Takashi Komori <[email protected]>
2+
3+
[Curl] Implement functions to use ResourceLoadStatistics.
4+
https://bugs.webkit.org/show_bug.cgi?id=207692
5+
6+
Reviewed by Don Olmstead.
7+
8+
Implement functions which are required to implement ResourceLoadStatistics for Curl port.
9+
10+
Tests: http/tests/resourceLoadStatistics/
11+
12+
* CMakeLists.txt:
13+
* platform/network/curl/CookieJarDB.cpp:
14+
(WebCore::CookieJarDB::openDatabase):
15+
(WebCore::CookieJarDB::setCookie):
16+
(WebCore::CookieJarDB::allDomains):
17+
(WebCore::CookieJarDB::deleteCookiesForHostname):
18+
* platform/network/curl/CookieJarDB.h:
19+
* platform/network/curl/NetworkStorageSessionCurl.cpp:
20+
(WebCore::NetworkStorageSession::setCookiesFromDOM const):
21+
(WebCore::NetworkStorageSession::setCookies):
22+
(WebCore::NetworkStorageSession::deleteCookiesForHostnames):
23+
(WebCore::NetworkStorageSession::getHostnamesWithCookies):
24+
125
2020-06-12 Andres Gonzalez <[email protected]>
226

327
In isolated tree mode 2, AXIsolatedObject::setChildrenIDs should be called only on secondary thread.

Source/WebCore/platform/network/curl/CookieJarDB.cpp

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "config.h"
2626
#include "CookieJarDB.h"
27+
#include "cookieJar.h"
2728

2829
#include "CookieUtil.h"
2930
#include "Logging.h"
@@ -63,6 +64,8 @@ namespace WebCore {
6364
"CREATE INDEX IF NOT EXISTS domain_index ON Cookie(domain);"
6465
#define CREATE_PATH_INDEX_SQL \
6566
"CREATE INDEX IF NOT EXISTS path_index ON Cookie(path);"
67+
#define SELECT_ALL_DOMAINS_SQL \
68+
"SELECT DISTINCT domain FROM Cookie;"
6669
#define CHECK_EXISTS_COOKIE_SQL \
6770
"SELECT domain FROM Cookie WHERE ((domain = ?) OR (domain GLOB ?));"
6871
#define CHECK_EXISTS_HTTPONLY_COOKIE_SQL \
@@ -76,6 +79,10 @@ namespace WebCore {
7679
"DELETE FROM Cookie WHERE name = ? AND domain = ?;"
7780
#define DELETE_ALL_SESSION_COOKIE_SQL \
7881
"DELETE FROM Cookie WHERE session = 1;"
82+
#define DELETE_COOKIES_BY_DOMAIN_SQL \
83+
"DELETE FROM Cookie WHERE domain = ? ;"
84+
#define DELETE_COOKIES_BY_DOMAIN_EXCEPT_HTTP_ONLY_SQL \
85+
"DELETE FROM Cookie WHERE (domain = ?) AND (httponly = 0);"
7986
#define DELETE_ALL_COOKIE_SQL \
8087
"DELETE FROM Cookie;"
8188

@@ -165,6 +172,8 @@ bool CookieJarDB::openDatabase()
165172
createPrepareStatement(CHECK_EXISTS_HTTPONLY_COOKIE_SQL);
166173
createPrepareStatement(DELETE_COOKIE_BY_NAME_DOMAIN_PATH_SQL);
167174
createPrepareStatement(DELETE_COOKIE_BY_NAME_DOMAIN_SQL);
175+
createPrepareStatement(DELETE_COOKIES_BY_DOMAIN_SQL);
176+
createPrepareStatement(DELETE_COOKIES_BY_DOMAIN_EXCEPT_HTTP_ONLY_SQL);
168177

169178
return true;
170179
}
@@ -529,7 +538,7 @@ bool CookieJarDB::setCookie(const Cookie& cookie)
529538
return checkSQLiteReturnCode(statement.step());
530539
}
531540

532-
bool CookieJarDB::setCookie(const URL& firstParty, const URL& url, const String& body, CookieJarDB::Source source)
541+
bool CookieJarDB::setCookie(const URL& firstParty, const URL& url, const String& body, CookieJarDB::Source source, Optional<Seconds> cappedLifetime)
533542
{
534543
if (!isEnabled() || !m_database.isOpen())
535544
return false;
@@ -550,9 +559,31 @@ bool CookieJarDB::setCookie(const URL& firstParty, const URL& url, const String&
550559
if (!canAcceptCookie(*cookie, firstParty, url, source))
551560
return false;
552561

562+
if (cappedLifetime && cookie->expires) {
563+
ASSERT(*cappedLifetime >= 0_s);
564+
auto cappedExpires = WallTime::now() + *cappedLifetime;
565+
if (cappedExpires < WallTime::fromRawSeconds(*cookie->expires / WTF::msPerSecond))
566+
cookie->expires = cappedExpires.secondsSinceEpoch().milliseconds();
567+
}
568+
553569
return setCookie(*cookie);
554570
}
555571

572+
HashSet<String> CookieJarDB::allDomains()
573+
{
574+
SQLiteStatement statement(m_database, SELECT_ALL_DOMAINS_SQL);
575+
statement.prepare();
576+
577+
HashSet<String> domains;
578+
while (statement.step() == SQLITE_ROW) {
579+
auto domain = statement.getColumnText(0);
580+
domains.add(domain);
581+
}
582+
583+
statement.finalize();
584+
return domains;
585+
}
586+
556587
bool CookieJarDB::deleteCookie(const String& url, const String& name)
557588
{
558589
if (!isEnabled() || !m_database.isOpen())
@@ -589,6 +620,13 @@ bool CookieJarDB::deleteCookies(const String&)
589620
return false;
590621
}
591622

623+
bool CookieJarDB::deleteCookiesForHostname(const String& hostname, IncludeHttpOnlyCookies includeHttpOnlyCookies)
624+
{
625+
auto& statement = preparedStatement(includeHttpOnlyCookies == IncludeHttpOnlyCookies::Yes ? DELETE_COOKIES_BY_DOMAIN_SQL : DELETE_COOKIES_BY_DOMAIN_EXCEPT_HTTP_ONLY_SQL);
626+
statement.bindText(1, hostname);
627+
return checkSQLiteReturnCode(statement.step());
628+
}
629+
592630
bool CookieJarDB::deleteAllCookies()
593631
{
594632
if (!isEnabled() || !m_database.isOpen())

Source/WebCore/platform/network/curl/CookieJarDB.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#pragma once
2626

2727
#include "Cookie.h"
28+
#include "CookieJar.h"
2829
#include "SQLiteDatabase.h"
2930
#include "SQLiteStatement.h"
3031
#include <wtf/HashMap.h>
@@ -56,13 +57,15 @@ class CookieJarDB {
5657
void setAcceptPolicy(CookieAcceptPolicy policy) { m_acceptPolicy = policy; }
5758
CookieAcceptPolicy acceptPolicy() const { return m_acceptPolicy; }
5859

60+
HashSet<String> allDomains();
5961
Optional<Vector<Cookie>> searchCookies(const URL& firstParty, const URL& requestUrl, const Optional<bool>& httpOnly, const Optional<bool>& secure, const Optional<bool>& session);
6062
Vector<Cookie> getAllCookies();
61-
bool setCookie(const URL& firstParty, const URL&, const String& cookie, Source);
63+
bool setCookie(const URL& firstParty, const URL&, const String& cookie, Source, Optional<Seconds> cappedLifetime = WTF::nullopt);
6264
bool setCookie(const Cookie&);
6365

6466
bool deleteCookie(const String& url, const String& name);
6567
bool deleteCookies(const String& url);
68+
bool deleteCookiesForHostname(const String& hostname, IncludeHttpOnlyCookies);
6669
bool deleteAllCookies();
6770

6871
WEBCORE_EXPORT CookieJarDB(const String& databasePath);

Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,14 @@ CookieJarDB& NetworkStorageSession::cookieDatabase() const
9595
return m_cookieDatabase;
9696
}
9797

98-
void NetworkStorageSession::setCookiesFromDOM(const URL& firstParty, const SameSiteInfo&, const URL& url, Optional<FrameIdentifier>, Optional<PageIdentifier>, ShouldAskITP, const String& value, ShouldRelaxThirdPartyCookieBlocking) const
98+
void NetworkStorageSession::setCookiesFromDOM(const URL& firstParty, const SameSiteInfo&, const URL& url, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, ShouldAskITP, const String& value, ShouldRelaxThirdPartyCookieBlocking shouldRelaxThirdPartyCookieBlocking) const
9999
{
100-
cookieDatabase().setCookie(firstParty, url, value, CookieJarDB::Source::Script);
100+
#if ENABLE(RESOURCE_LOAD_STATISTICS)
101+
Optional<Seconds> cappedLifetime = clientSideCookieCap(RegistrableDomain { firstParty }, pageID);
102+
#else
103+
Optional<Seconds> cappedLifetime = WTF::nullopt;
104+
#endif
105+
cookieDatabase().setCookie(firstParty, url, value, CookieJarDB::Source::Script, cappedLifetime);
101106
}
102107

103108
void NetworkStorageSession::setCookiesFromHTTPResponse(const URL& firstParty, const URL& url, const String& value) const
@@ -133,9 +138,10 @@ std::pair<String, bool> NetworkStorageSession::cookiesForDOM(const URL& firstPar
133138
return { cookiesForSession(*this, firstParty, url, false), false };
134139
}
135140

136-
void NetworkStorageSession::setCookies(const Vector<Cookie>&, const URL&, const URL& /* mainDocumentURL */)
141+
void NetworkStorageSession::setCookies(const Vector<Cookie>& cookies, const URL&, const URL& /* mainDocumentURL */)
137142
{
138-
// FIXME: Implement for WebKit to use.
143+
for (const auto& cookie : cookies)
144+
cookieDatabase().setCookie(cookie);
139145
}
140146

141147
void NetworkStorageSession::setCookie(const Cookie& cookie)
@@ -164,9 +170,10 @@ void NetworkStorageSession::deleteAllCookiesModifiedSince(WallTime)
164170
// FIXME: Not yet implemented
165171
}
166172

167-
void NetworkStorageSession::deleteCookiesForHostnames(const Vector<String>& /* cookieHostNames */, IncludeHttpOnlyCookies)
173+
void NetworkStorageSession::deleteCookiesForHostnames(const Vector<String>& cookieHostNames, IncludeHttpOnlyCookies includeHttpOnlyCookies)
168174
{
169-
// FIXME: Not yet implemented.
175+
for (auto hostname : cookieHostNames)
176+
cookieDatabase().deleteCookiesForHostname(hostname, includeHttpOnlyCookies);
170177
}
171178

172179
void NetworkStorageSession::deleteCookiesForHostnames(const Vector<String>& cookieHostNames)
@@ -179,9 +186,9 @@ Vector<Cookie> NetworkStorageSession::getAllCookies()
179186
return cookieDatabase().getAllCookies();
180187
}
181188

182-
void NetworkStorageSession::getHostnamesWithCookies(HashSet<String>& /* hostnames */)
189+
void NetworkStorageSession::getHostnamesWithCookies(HashSet<String>& hostnames)
183190
{
184-
// FIXME: Not yet implemented
191+
hostnames = cookieDatabase().allDomains();
185192
}
186193

187194
Vector<Cookie> NetworkStorageSession::getCookies(const URL&)

Source/WebKit/ChangeLog

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
2020-06-12 Takashi Komori <[email protected]>
2+
3+
[Curl] Implement functions to use ResourceLoadStatistics.
4+
https://bugs.webkit.org/show_bug.cgi?id=207692
5+
6+
Reviewed by Don Olmstead.
7+
8+
Implement functions which are required to implement ResourceLoadStatistics for Curl port.
9+
10+
In NetworkDataTaskCurl.cpp we check if we should block cookies and block if needed.
11+
12+
Tests: http/tests/resourceLoadStatistics/
13+
14+
* NetworkProcess/NetworkDataTask.cpp:
15+
(WebKit::NetworkDataTask::create):
16+
* NetworkProcess/curl/NetworkDataTaskCurl.cpp:
17+
(WebKit::NetworkDataTaskCurl::NetworkDataTaskCurl):
18+
(WebKit::NetworkDataTaskCurl::createCurlRequest):
19+
(WebKit::NetworkDataTaskCurl::willPerformHTTPRedirection):
20+
(WebKit::NetworkDataTaskCurl::blockCookies):
21+
(WebKit::NetworkDataTaskCurl::unblockCookies):
22+
(WebKit::NetworkDataTaskCurl::shouldBlockCookies):
23+
(WebKit::NetworkDataTaskCurl::isThirdPartyRequest):
24+
* NetworkProcess/curl/NetworkDataTaskCurl.h:
25+
* NetworkProcess/curl/NetworkSessionCurl.cpp:
26+
(WebKit::NetworkSessionCurl::NetworkSessionCurl):
27+
* UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
28+
(WKWebsiteDataStoreGetAllStorageAccessEntries):
29+
* UIProcess/API/C/WKWebsiteDataStoreRef.h:
30+
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
31+
(WebKit::WebsiteDataStore::parameters):
32+
133
2020-06-12 Antoine Quint <[email protected]>
234

335
Double tap to zoom out doesn't work after upgrading to iOS 13

Source/WebKit/NetworkProcess/NetworkDataTask.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Ref<NetworkDataTask> NetworkDataTask::create(NetworkSession& session, NetworkDat
6060
return NetworkDataTaskSoup::create(session, client, parameters.request, parameters.webFrameID, parameters.webPageID, parameters.storedCredentialsPolicy, parameters.contentSniffingPolicy, parameters.contentEncodingSniffingPolicy, parameters.shouldClearReferrerOnHTTPSToHTTPRedirect, parameters.isMainFrameNavigation);
6161
#endif
6262
#if USE(CURL)
63-
return NetworkDataTaskCurl::create(session, client, parameters.request, parameters.storedCredentialsPolicy, parameters.contentSniffingPolicy, parameters.contentEncodingSniffingPolicy, parameters.shouldClearReferrerOnHTTPSToHTTPRedirect, parameters.isMainFrameNavigation);
63+
return NetworkDataTaskCurl::create(session, client, parameters.request, parameters.webFrameID, parameters.webPageID, parameters.storedCredentialsPolicy, parameters.contentSniffingPolicy, parameters.contentEncodingSniffingPolicy, parameters.shouldClearReferrerOnHTTPSToHTTPRedirect, parameters.isMainFrameNavigation, parameters.shouldRelaxThirdPartyCookieBlocking);
6464
#endif
6565
}
6666

0 commit comments

Comments
 (0)