Title: [295333] trunk/Tools/TestWebKitAPI
- Revision
- 295333
- Author
- [email protected]
- Date
- 2022-06-06 23:57:18 -0700 (Mon, 06 Jun 2022)
Log Message
Make _WKDataTask.Basic API test more permissive of different number of TCP connections
https://bugs.webkit.org/show_bug.cgi?id=241358
rdar://94322457
Reviewed by Tim Horton.
Since r294757 we call _setPrivacyProxyFailClosedForUnreachableNonMainHosts on most loads
from WKWebView, but _WKDataTask uses NetworkSessionCocoa::dataTaskWithRequest which does not.
On platforms that support the SPI, we now make a different TCP connection because the stream
properties are different so we can't use the same cached connection. This is fine. The test
verifies that the session cookie is sent. An alternative could be to call
_setPrivacyProxyFailClosedForUnreachableNonMainHosts for all _WKDataTask loads, but that would
strangely and unnecessarily block some loads. The mitigation for rdar://problem/92697007 is not
needed in contexts where _WKDataTask is used because those loads can't run JS that then triggers
other loads, and there's also no main document so the algorithm we use in r294757 can't work.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm:
(TEST):
* Tools/TestWebKitAPI/cocoa/HTTPServer.h:
* Tools/TestWebKitAPI/cocoa/HTTPServer.mm:
(TestWebKitAPI::Connection::awaitableSend):
Canonical link: https://commits.webkit.org/251352@main
Modified Paths
Diff
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm (295332 => 295333)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm 2022-06-07 06:03:40 UTC (rev 295332)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm 2022-06-07 06:57:18 UTC (rev 295333)
@@ -428,21 +428,27 @@
constexpr auto html = "<script>document.cookie='testkey=value'</script>"_s;
constexpr auto secondResponse = "second response"_s;
Vector<char> secondRequest;
- auto server = HTTPServer([&](const Connection& connection) {
- connection.receiveHTTPRequest([&, connection](Vector<char>&& request) {
- connection.send(HTTPResponse(html).serialize(), [&, connection] {
- connection.receiveHTTPRequest([&, connection](Vector<char>&& request) {
- secondRequest = WTFMove(request);
- connection.send(HTTPResponse(secondResponse).serialize());
- });
- });
- });
+ auto server = HTTPServer(HTTPServer::UseCoroutines::Yes, [&](Connection connection) -> Task {
+ while (1) {
+ auto request = co_await connection.awaitableReceiveHTTPRequest();
+ auto path = HTTPServer::parsePath(request);
+ if (path == "/initial_request"_s) {
+ co_await connection.awaitableSend(HTTPResponse(html).serialize());
+ continue;
+ }
+ if (path == "/second_request"_s) {
+ secondRequest = WTFMove(request);
+ co_await connection.awaitableSend(HTTPResponse(secondResponse).serialize());
+ continue;
+ }
+ EXPECT_FALSE(true);
+ }
});
auto webView = adoptNS([TestWKWebView new]);
- [webView synchronouslyLoadRequest:server.request()];
+ [webView synchronouslyLoadRequest:server.request("/initial_request"_s)];
__block bool done = false;
- RetainPtr<NSMutableURLRequest> postRequest = adoptNS([server.request() mutableCopy]);
+ RetainPtr<NSMutableURLRequest> postRequest = adoptNS([server.request("/second_request"_s) mutableCopy]);
[postRequest setMainDocumentURL:postRequest.get().URL];
[postRequest setHTTPMethod:@"POST"];
auto requestBody = "request body";
Modified: trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.h (295332 => 295333)
--- trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.h 2022-06-07 06:03:40 UTC (rev 295332)
+++ trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.h 2022-06-07 06:57:18 UTC (rev 295333)
@@ -113,6 +113,7 @@
void send(String&&, CompletionHandler<void()>&& = nullptr) const;
void send(Vector<uint8_t>&&, CompletionHandler<void()>&& = nullptr) const;
void send(RetainPtr<dispatch_data_t>&&, CompletionHandler<void(bool)>&& = nullptr) const;
+ SendOperation awaitableSend(Vector<uint8_t>&&);
SendOperation awaitableSend(String&&);
void sendAndReportError(Vector<uint8_t>&&, CompletionHandler<void(bool)>&&) const;
void receiveBytes(CompletionHandler<void(Vector<uint8_t>&&)>&&, size_t minimumSize = 1) const;
Modified: trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.mm (295332 => 295333)
--- trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.mm 2022-06-07 06:03:40 UTC (rev 295332)
+++ trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.mm 2022-06-07 06:57:18 UTC (rev 295333)
@@ -467,6 +467,11 @@
});
}
+SendOperation Connection::awaitableSend(Vector<uint8_t>&& message)
+{
+ return { dataFromVector(WTFMove(message)), *this };
+}
+
SendOperation Connection::awaitableSend(String&& message)
{
return { dataFromString(WTFMove(message)), *this };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes