Diff
Modified: trunk/Source/WebKit/ChangeLog (262984 => 262985)
--- trunk/Source/WebKit/ChangeLog 2020-06-12 22:38:27 UTC (rev 262984)
+++ trunk/Source/WebKit/ChangeLog 2020-06-12 23:32:15 UTC (rev 262985)
@@ -1,3 +1,26 @@
+2020-06-12 Alex Christensen <achristen...@webkit.org>
+
+ Make API tests tolerant of our relatively new use of WebPageProxy::preconnectTo
+ https://bugs.webkit.org/show_bug.cgi?id=213144
+
+ Reviewed by Geofferey Garen.
+
+ * NetworkProcess/cocoa/NetworkSessionCocoa.h:
+ * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+ (-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
+ (-[WKNetworkSessionDelegate URLSession:task:didCompleteWithError:]):
+ (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]):
+ (WebKit::NetworkSessionCocoa::taskServerConnectionSucceeded):
+ (WebKit::NetworkSessionCocoa::taskReceivedBytes): Deleted.
+ Fix our logic that remembers successful client certificate connections.
+ If a task completes with no error (like a preconnect task does), consider that a successful connection.
+
+ * UIProcess/Network/NetworkProcessProxy.cpp:
+ (WebKit::NetworkProcessProxy::preconnectTo):
+ Remove the check to not preconnect to loopback addresses.
+ This was making our tests different than the real internet and prevented me from landing a perfectly good test
+ in https://bugs.webkit.org/show_bug.cgi?id=213109
+
2020-06-12 Per Arne Vollan <pvol...@apple.com>
[iOS] Preferences are not being observed if the process pool is being created after activation
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h (262984 => 262985)
--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h 2020-06-12 22:38:27 UTC (rev 262984)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h 2020-06-12 23:32:15 UTC (rev 262985)
@@ -102,7 +102,7 @@
bool preventsSystemHTTPProxyAuthentication() const { return m_preventsSystemHTTPProxyAuthentication; }
void clientCertificateSuggestedForHost(NetworkDataTaskCocoa::TaskIdentifier, NSURLCredential *, const String& host, uint16_t port);
- void taskReceivedBytes(NetworkDataTaskCocoa::TaskIdentifier);
+ void taskServerConnectionSucceeded(NetworkDataTaskCocoa::TaskIdentifier);
void taskFailed(NetworkDataTaskCocoa::TaskIdentifier);
NSURLCredential *successfulClientCertificateForHost(const String& host, uint16_t port) const;
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (262984 => 262985)
--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm 2020-06-12 22:38:27 UTC (rev 262984)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm 2020-06-12 23:32:15 UTC (rev 262985)
@@ -532,7 +532,7 @@
auto completionHandlerCopy = Block_copy(completionHandler);
if (auto* sessionCocoa = [self sessionFromTask:task])
- sessionCocoa->taskReceivedBytes(taskIdentifier);
+ sessionCocoa->taskServerConnectionSucceeded(taskIdentifier);
bool shouldIgnoreHSTS = false;
#if ENABLE(RESOURCE_LOAD_STATISTICS)
@@ -730,8 +730,12 @@
}
if (auto* networkDataTask = [self existingTask:task]) {
- if (auto* sessionCocoa = [self sessionFromTask:task])
- sessionCocoa->taskFailed(task.taskIdentifier);
+ if (auto* sessionCocoa = [self sessionFromTask:task]) {
+ if (error)
+ sessionCocoa->taskFailed(task.taskIdentifier);
+ else
+ sessionCocoa->taskServerConnectionSucceeded(task.taskIdentifier);
+ }
networkDataTask->didCompleteWithError(error, networkDataTask->networkLoadMetrics());
} else if (error) {
if (!_sessionWrapper)
@@ -872,7 +876,7 @@
ASSERT(RunLoop::isMain());
if (auto* sessionCocoa = [self sessionFromTask:dataTask])
- sessionCocoa->taskReceivedBytes(taskIdentifier);
+ sessionCocoa->taskServerConnectionSucceeded(taskIdentifier);
NegotiatedLegacyTLS negotiatedLegacyTLS = NegotiatedLegacyTLS::No;
#if HAVE(TLS_PROTOCOL_VERSION_T)
@@ -1061,7 +1065,7 @@
m_suggestedClientCertificates.set(taskID, SuggestedClientCertificate { host, port, credential });
}
-void NetworkSessionCocoa::taskReceivedBytes(NetworkDataTaskCocoa::TaskIdentifier identifier)
+void NetworkSessionCocoa::taskServerConnectionSucceeded(NetworkDataTaskCocoa::TaskIdentifier identifier)
{
if (LIKELY(m_suggestedClientCertificates.isEmpty()))
return;
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (262984 => 262985)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2020-06-12 22:38:27 UTC (rev 262984)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2020-06-12 23:32:15 UTC (rev 262985)
@@ -1472,7 +1472,7 @@
void NetworkProcessProxy::preconnectTo(PAL::SessionID sessionID, WebPageProxyIdentifier webPageProxyID, WebCore::PageIdentifier webPageID, const URL& url, const String& userAgent, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, Optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain)
{
- if (!url.isValid() || !url.protocolIsInHTTPFamily() || SecurityOrigin::isLocalHostOrLoopbackIPAddress(url.host()))
+ if (!url.isValid() || !url.protocolIsInHTTPFamily())
return;
send(Messages::NetworkProcess::PreconnectTo(sessionID, webPageProxyID, webPageID, url, userAgent, storedCredentialsPolicy, isNavigatingToAppBoundDomain), 0);
}
Modified: trunk/Tools/ChangeLog (262984 => 262985)
--- trunk/Tools/ChangeLog 2020-06-12 22:38:27 UTC (rev 262984)
+++ trunk/Tools/ChangeLog 2020-06-12 23:32:15 UTC (rev 262985)
@@ -1,3 +1,33 @@
+2020-06-12 Alex Christensen <achristen...@webkit.org>
+
+ Make API tests tolerant of our relatively new use of WebPageProxy::preconnectTo
+ https://bugs.webkit.org/show_bug.cgi?id=213144
+
+ Reviewed by Geofferey Garen.
+
+ Most changes are straightforward moving to HTTPServer, which is more tolerant of different numbers of connections except these two:
+
+ The ResourceLoadDelegate.Challenge API test was checking the output of _WKResourceLoadDelegate.didReceiveChallenge
+ by using a server trust challenge. Now that preconnecting happens, the server trust evaluation would happen with a
+ PreconnectTask, not the main resource load. The WKNavigationDelegate still gets the challenge and there is no problem
+ here, but in order to continue to test _WKResourceLoadDelegate.didReceiveChallenge I use a basic authentication challenge
+ instead of a server trust evaluation.
+
+ The WebKit.FastServerTrust API test now has two failed attempts (one from the preconnect attempt, one from the main resource load attempt),
+ but only when _strictTrustEvaluate is not available.
+
+ * TestWebKitAPI/TCPServer.cpp:
+ (TestWebKitAPI::TCPServer::TCPServer):
+ * TestWebKitAPI/TCPServer.h:
+ * TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm:
+ (TEST):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm:
+ * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
+ * TestWebKitAPI/cocoa/HTTPServer.h:
+ * TestWebKitAPI/cocoa/HTTPServer.mm:
+ (TestWebKitAPI::HTTPServer::respondWithChallengeThenOK):
+
2020-06-12 Diego Pino Garcia <dp...@igalia.com>
[buildbot] [GTK][WPE] Move WebDriver test to own bot
Modified: trunk/Tools/TestWebKitAPI/TCPServer.cpp (262984 => 262985)
--- trunk/Tools/TestWebKitAPI/TCPServer.cpp 2020-06-12 22:38:27 UTC (rev 262984)
+++ trunk/Tools/TestWebKitAPI/TCPServer.cpp 2020-06-12 23:32:15 UTC (rev 262985)
@@ -207,7 +207,7 @@
secureConnectionHandler(acceptResult > 0 ? ssl.get() : nullptr);
};
-TCPServer::TCPServer(Protocol protocol, Function<void(SSL*)>&& secureConnectionHandler, Optional<uint16_t> maxTLSVersion)
+TCPServer::TCPServer(Protocol protocol, Function<void(SSL*)>&& secureConnectionHandler, Optional<uint16_t> maxTLSVersion, size_t connections)
{
switch (protocol) {
case Protocol::HTTPS:
@@ -232,7 +232,7 @@
};
break;
}
- listenForConnections(1);
+ listenForConnections(connections);
}
#endif // HAVE(SSL)
Modified: trunk/Tools/TestWebKitAPI/TCPServer.h (262984 => 262985)
--- trunk/Tools/TestWebKitAPI/TCPServer.h 2020-06-12 22:38:27 UTC (rev 262984)
+++ trunk/Tools/TestWebKitAPI/TCPServer.h 2020-06-12 23:32:15 UTC (rev 262985)
@@ -47,7 +47,7 @@
enum class Protocol : uint8_t {
HTTPS, HTTPSProxy, HTTPSWithClientCertificateRequest
};
- TCPServer(Protocol, Function<void(SSL*)>&&, Optional<uint16_t> maxTLSVersion = WTF::nullopt);
+ TCPServer(Protocol, Function<void(SSL*)>&&, Optional<uint16_t> maxTLSVersion = WTF::nullopt, size_t connections = 1);
#endif // HAVE(SSL)
~TCPServer();
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm (262984 => 262985)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm 2020-06-12 22:38:27 UTC (rev 262984)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm 2020-06-12 23:32:15 UTC (rev 262985)
@@ -203,10 +203,12 @@
@end
+#if HAVE(NETWORK_FRAMEWORK)
+
TEST(Challenge, BasicProposedCredential)
{
using namespace TestWebKitAPI;
- TCPServer server(TCPServer::respondWithChallengeThenOK, 2);
+ HTTPServer server(HTTPServer::respondWithChallengeThenOK);
auto configuration = retainPtr([WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"BasicProposedCredentialPlugIn"]);
auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration.get()]);
auto delegate = adoptNS([ProposedCredentialDelegate new]);
@@ -216,7 +218,7 @@
NSURLProtectionSpace *protectionSpace = [[[NSURLProtectionSpace alloc] initWithHost:@"127.0.0.1" port:server.port() protocol:NSURLProtectionSpaceHTTP realm:@"testrealm" authenticationMethod:NSURLAuthenticationMethodHTTPBasic] autorelease];
[[webView configuration].processPool _clearPermanentCredentialsForProtectionSpace:protectionSpace];
- RetainPtr<NSURLRequest> request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://127.0.0.1:%d/", server.port()]]];
+ RetainPtr<NSURLRequest> request = server.request();
[webView loadRequest:request.get()];
Util::run(&navigationFinished);
navigationFinished = false;
@@ -228,6 +230,8 @@
[[webView configuration].processPool _clearPermanentCredentialsForProtectionSpace:protectionSpace];
}
+#endif // HAVE(NETWORK_FRAMEWORK)
+
#if HAVE(SSL)
static void verifyCertificateAndPublicKey(SecTrustRef trust)
{
@@ -379,7 +383,7 @@
#else
TCPServer server(TCPServer::Protocol::HTTPS, [](SSL* ssl) {
EXPECT_FALSE(ssl);
- });
+ }, WTF::nullopt, 2);
#endif
WKWebViewConfiguration *configuration = [[[WKWebViewConfiguration alloc] init] autorelease];
_WKWebsiteDataStoreConfiguration *dataStoreConfiguration = [[[_WKWebsiteDataStoreConfiguration alloc] init] autorelease];
@@ -492,7 +496,7 @@
size_t certChallengesAfterInitialFailure = countClientCertChallenges(methods);
[webView loadRequest:server.request()];
[delegate waitForDidFinishNavigation];
- EXPECT_EQ(countClientCertChallenges(methods), certChallengesAfterInitialFailure + 1);
+ EXPECT_EQ(countClientCertChallenges(methods), certChallengesAfterInitialFailure);
}
TEST(MultipleClientCertificateConnections, NonPersistentDataStore)
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm (262984 => 262985)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm 2020-06-12 22:38:27 UTC (rev 262984)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm 2020-06-12 23:32:15 UTC (rev 262985)
@@ -390,22 +390,15 @@
// FIXME: Add a test for loadedFromCache.
-#endif // HAVE(NETWORK_FRAMEWORK)
-
-#if HAVE(SSL)
-
TEST(ResourceLoadDelegate, Challenge)
{
using namespace TestWebKitAPI;
- TCPServer server(TCPServer::Protocol::HTTPS, [] (SSL* ssl) {
- EXPECT_TRUE(!!ssl); // Connection should succeed after a server trust challenge.
- // Send nothing to make the resource load fail.
- });
+ HTTPServer server(HTTPServer::respondWithChallengeThenOK);
auto navigationDelegate = adoptNS([TestNavigationDelegate new]);
[navigationDelegate setDidReceiveAuthenticationChallenge:^(WKWebView *, NSURLAuthenticationChallenge *challenge, void (^completionHandler)(NSURLSessionAuthChallengeDisposition, NSURLCredential *)) {
- EXPECT_WK_STREQ(challenge.protectionSpace.authenticationMethod, NSURLAuthenticationMethodServerTrust);
- completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
+ EXPECT_WK_STREQ(challenge.protectionSpace.authenticationMethod, NSURLAuthenticationMethodHTTPBasic);
+ completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialWithUser:@"testuser" password:@"testpassword" persistence:NSURLCredentialPersistenceNone]);
}];
__block bool receivedErrorNotification = false;
@@ -412,12 +405,11 @@
__block bool receivedChallengeNotificiation = false;
auto resourceLoadDelegate = adoptNS([TestResourceLoadDelegate new]);
[resourceLoadDelegate setDidReceiveChallenge:^(WKWebView *, _WKResourceLoadInfo *, NSURLAuthenticationChallenge *challenge) {
- EXPECT_WK_STREQ(challenge.protectionSpace.authenticationMethod, NSURLAuthenticationMethodServerTrust);
+ EXPECT_WK_STREQ(challenge.protectionSpace.authenticationMethod, NSURLAuthenticationMethodHTTPBasic);
receivedChallengeNotificiation = true;
}];
[resourceLoadDelegate setDidCompleteWithError:^(WKWebView *, _WKResourceLoadInfo *, NSError *error, NSURLResponse *) {
- EXPECT_EQ(error.code, kCFURLErrorCannotConnectToHost);
- EXPECT_WK_STREQ(error.domain, NSURLErrorDomain);
+ EXPECT_FALSE(error);
receivedErrorNotification = true;
}];
@@ -424,9 +416,9 @@
auto webView = adoptNS([WKWebView new]);
[webView setNavigationDelegate:navigationDelegate.get()];
[webView _setResourceLoadDelegate:resourceLoadDelegate.get()];
- [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://127.0.0.1:%d/", server.port()]]]];
+ [webView loadRequest:server.request()];
TestWebKitAPI::Util::run(&receivedErrorNotification);
EXPECT_TRUE(receivedChallengeNotificiation);
}
-#endif // HAVE(SSL)
+#endif // HAVE(NETWORK_FRAMEWORK)
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm (262984 => 262985)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm 2020-06-12 22:38:27 UTC (rev 262984)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm 2020-06-12 23:32:15 UTC (rev 262985)
@@ -1573,6 +1573,8 @@
waitUntilServiceWorkerProcessCount(processPool, 2);
}
+#if HAVE(NETWORK_FRAMEWORK)
+
static size_t launchServiceWorkerProcess(bool useSeparateServiceWorkerProcess, bool loadAboutBlankBeforePage)
{
[WKWebsiteDataStore _allowWebsiteDataRecordsForAllOrigins];
@@ -1589,9 +1591,9 @@
auto messageHandler = adoptNS([[SWMessageHandler alloc] init]);
[[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
- ServiceWorkerTCPServer server({
- { "text/html", mainBytes },
- { "application/_javascript_", scriptBytes },
+ TestWebKitAPI::HTTPServer server({
+ { "/", { mainBytes } },
+ { "/sw.js", { {{ "Content-Type", "application/_javascript_" }}, scriptBytes } }
});
auto *processPool = configuration.get().processPool;
@@ -1635,6 +1637,8 @@
EXPECT_EQ(2u, launchServiceWorkerProcess(useSeparateServiceWorkerProcess, firstLoadAboutBlank));
}
+#endif // HAVE(NETWORK_FRAMEWORK)
+
void waitUntilServiceWorkerProcessForegroundActivityState(WKWebView *page, bool shouldHaveActivity)
{
do {
Modified: trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.h (262984 => 262985)
--- trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.h 2020-06-12 22:38:27 UTC (rev 262984)
+++ trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.h 2020-06-12 23:32:15 UTC (rev 262985)
@@ -53,6 +53,8 @@
NSURLRequest *request(const String& path = "/"_str) const;
size_t totalRequests() const;
+ static void respondWithChallengeThenOK(Connection);
+
private:
static RetainPtr<nw_parameters_t> listenerParameters(Protocol, CertificateVerifier&&);
static void respondToRequests(Connection, RefPtr<RequestData>);
Modified: trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.mm (262984 => 262985)
--- trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.mm 2020-06-12 22:38:27 UTC (rev 262984)
+++ trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.mm 2020-06-12 23:32:15 UTC (rev 262985)
@@ -115,6 +115,26 @@
HTTPServer::~HTTPServer() = default;
+void HTTPServer::respondWithChallengeThenOK(Connection connection)
+{
+ connection.receiveHTTPRequest([connection] (Vector<char>&&) {
+ const char* challengeHeader =
+ "HTTP/1.1 401 Unauthorized\r\n"
+ "Date: Sat, 23 Mar 2019 06:29:01 GMT\r\n"
+ "Content-Length: 0\r\n"
+ "WWW-Authenticate: Basic realm=\"testrealm\"\r\n\r\n";
+ connection.send(challengeHeader, [connection] {
+ connection.receiveHTTPRequest([connection] (Vector<char>&&) {
+ connection.send(
+ "HTTP/1.1 200 OK\r\n"
+ "Content-Length: 13\r\n\r\n"
+ "Hello, World!"
+ );
+ });
+ });
+ });
+}
+
size_t HTTPServer::totalRequests() const
{
if (!m_requestData)