Changeset 262985 in webkit
- Timestamp:
- Jun 12, 2020, 4:32:15 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r262984 r262985 1 2020-06-12 Alex Christensen <achristensen@webkit.org> 2 3 Make API tests tolerant of our relatively new use of WebPageProxy::preconnectTo 4 https://bugs.webkit.org/show_bug.cgi?id=213144 5 6 Reviewed by Geofferey Garen. 7 8 * NetworkProcess/cocoa/NetworkSessionCocoa.h: 9 * NetworkProcess/cocoa/NetworkSessionCocoa.mm: 10 (-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]): 11 (-[WKNetworkSessionDelegate URLSession:task:didCompleteWithError:]): 12 (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): 13 (WebKit::NetworkSessionCocoa::taskServerConnectionSucceeded): 14 (WebKit::NetworkSessionCocoa::taskReceivedBytes): Deleted. 15 Fix our logic that remembers successful client certificate connections. 16 If a task completes with no error (like a preconnect task does), consider that a successful connection. 17 18 * UIProcess/Network/NetworkProcessProxy.cpp: 19 (WebKit::NetworkProcessProxy::preconnectTo): 20 Remove the check to not preconnect to loopback addresses. 21 This was making our tests different than the real internet and prevented me from landing a perfectly good test 22 in https://bugs.webkit.org/show_bug.cgi?id=213109 23 1 24 2020-06-12 Per Arne Vollan <pvollan@apple.com> 2 25 -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h
r260900 r262985 103 103 104 104 void clientCertificateSuggestedForHost(NetworkDataTaskCocoa::TaskIdentifier, NSURLCredential *, const String& host, uint16_t port); 105 void task ReceivedBytes(NetworkDataTaskCocoa::TaskIdentifier);105 void taskServerConnectionSucceeded(NetworkDataTaskCocoa::TaskIdentifier); 106 106 void taskFailed(NetworkDataTaskCocoa::TaskIdentifier); 107 107 NSURLCredential *successfulClientCertificateForHost(const String& host, uint16_t port) const; -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
r262930 r262985 533 533 534 534 if (auto* sessionCocoa = [self sessionFromTask:task]) 535 sessionCocoa->task ReceivedBytes(taskIdentifier);535 sessionCocoa->taskServerConnectionSucceeded(taskIdentifier); 536 536 537 537 bool shouldIgnoreHSTS = false; … … 731 731 732 732 if (auto* networkDataTask = [self existingTask:task]) { 733 if (auto* sessionCocoa = [self sessionFromTask:task]) 734 sessionCocoa->taskFailed(task.taskIdentifier); 733 if (auto* sessionCocoa = [self sessionFromTask:task]) { 734 if (error) 735 sessionCocoa->taskFailed(task.taskIdentifier); 736 else 737 sessionCocoa->taskServerConnectionSucceeded(task.taskIdentifier); 738 } 735 739 networkDataTask->didCompleteWithError(error, networkDataTask->networkLoadMetrics()); 736 740 } else if (error) { … … 873 877 874 878 if (auto* sessionCocoa = [self sessionFromTask:dataTask]) 875 sessionCocoa->task ReceivedBytes(taskIdentifier);879 sessionCocoa->taskServerConnectionSucceeded(taskIdentifier); 876 880 877 881 NegotiatedLegacyTLS negotiatedLegacyTLS = NegotiatedLegacyTLS::No; … … 1062 1066 } 1063 1067 1064 void NetworkSessionCocoa::task ReceivedBytes(NetworkDataTaskCocoa::TaskIdentifier identifier)1068 void NetworkSessionCocoa::taskServerConnectionSucceeded(NetworkDataTaskCocoa::TaskIdentifier identifier) 1065 1069 { 1066 1070 if (LIKELY(m_suggestedClientCertificates.isEmpty())) -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
r262487 r262985 1473 1473 void NetworkProcessProxy::preconnectTo(PAL::SessionID sessionID, WebPageProxyIdentifier webPageProxyID, WebCore::PageIdentifier webPageID, const URL& url, const String& userAgent, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, Optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain) 1474 1474 { 1475 if (!url.isValid() || !url.protocolIsInHTTPFamily() || SecurityOrigin::isLocalHostOrLoopbackIPAddress(url.host()))1475 if (!url.isValid() || !url.protocolIsInHTTPFamily()) 1476 1476 return; 1477 1477 send(Messages::NetworkProcess::PreconnectTo(sessionID, webPageProxyID, webPageID, url, userAgent, storedCredentialsPolicy, isNavigatingToAppBoundDomain), 0); -
trunk/Tools/ChangeLog
r262975 r262985 1 2020-06-12 Alex Christensen <achristensen@webkit.org> 2 3 Make API tests tolerant of our relatively new use of WebPageProxy::preconnectTo 4 https://bugs.webkit.org/show_bug.cgi?id=213144 5 6 Reviewed by Geofferey Garen. 7 8 Most changes are straightforward moving to HTTPServer, which is more tolerant of different numbers of connections except these two: 9 10 The ResourceLoadDelegate.Challenge API test was checking the output of _WKResourceLoadDelegate.didReceiveChallenge 11 by using a server trust challenge. Now that preconnecting happens, the server trust evaluation would happen with a 12 PreconnectTask, not the main resource load. The WKNavigationDelegate still gets the challenge and there is no problem 13 here, but in order to continue to test _WKResourceLoadDelegate.didReceiveChallenge I use a basic authentication challenge 14 instead of a server trust evaluation. 15 16 The WebKit.FastServerTrust API test now has two failed attempts (one from the preconnect attempt, one from the main resource load attempt), 17 but only when _strictTrustEvaluate is not available. 18 19 * TestWebKitAPI/TCPServer.cpp: 20 (TestWebKitAPI::TCPServer::TCPServer): 21 * TestWebKitAPI/TCPServer.h: 22 * TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm: 23 (TEST): 24 (TestWebKitAPI::TEST): 25 * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm: 26 * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm: 27 * TestWebKitAPI/cocoa/HTTPServer.h: 28 * TestWebKitAPI/cocoa/HTTPServer.mm: 29 (TestWebKitAPI::HTTPServer::respondWithChallengeThenOK): 30 1 31 2020-06-12 Diego Pino Garcia <dpino@igalia.com> 2 32 -
trunk/Tools/TestWebKitAPI/TCPServer.cpp
r259910 r262985 208 208 }; 209 209 210 TCPServer::TCPServer(Protocol protocol, Function<void(SSL*)>&& secureConnectionHandler, Optional<uint16_t> maxTLSVersion )210 TCPServer::TCPServer(Protocol protocol, Function<void(SSL*)>&& secureConnectionHandler, Optional<uint16_t> maxTLSVersion, size_t connections) 211 211 { 212 212 switch (protocol) { … … 233 233 break; 234 234 } 235 listenForConnections( 1);235 listenForConnections(connections); 236 236 } 237 237 #endif // HAVE(SSL) -
trunk/Tools/TestWebKitAPI/TCPServer.h
r259910 r262985 48 48 HTTPS, HTTPSProxy, HTTPSWithClientCertificateRequest 49 49 }; 50 TCPServer(Protocol, Function<void(SSL*)>&&, Optional<uint16_t> maxTLSVersion = WTF::nullopt );50 TCPServer(Protocol, Function<void(SSL*)>&&, Optional<uint16_t> maxTLSVersion = WTF::nullopt, size_t connections = 1); 51 51 #endif // HAVE(SSL) 52 52 ~TCPServer(); -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm
r260322 r262985 204 204 @end 205 205 206 #if HAVE(NETWORK_FRAMEWORK) 207 206 208 TEST(Challenge, BasicProposedCredential) 207 209 { 208 210 using namespace TestWebKitAPI; 209 TCPServer server(TCPServer::respondWithChallengeThenOK, 2);211 HTTPServer server(HTTPServer::respondWithChallengeThenOK); 210 212 auto configuration = retainPtr([WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"BasicProposedCredentialPlugIn"]); 211 213 auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration.get()]); … … 217 219 [[webView configuration].processPool _clearPermanentCredentialsForProtectionSpace:protectionSpace]; 218 220 219 RetainPtr<NSURLRequest> request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://127.0.0.1:%d/", server.port()]]];221 RetainPtr<NSURLRequest> request = server.request(); 220 222 [webView loadRequest:request.get()]; 221 223 Util::run(&navigationFinished); … … 228 230 [[webView configuration].processPool _clearPermanentCredentialsForProtectionSpace:protectionSpace]; 229 231 } 232 233 #endif // HAVE(NETWORK_FRAMEWORK) 230 234 231 235 #if HAVE(SSL) … … 380 384 TCPServer server(TCPServer::Protocol::HTTPS, [](SSL* ssl) { 381 385 EXPECT_FALSE(ssl); 382 } );386 }, WTF::nullopt, 2); 383 387 #endif 384 388 WKWebViewConfiguration *configuration = [[[WKWebViewConfiguration alloc] init] autorelease]; … … 493 497 [webView loadRequest:server.request()]; 494 498 [delegate waitForDidFinishNavigation]; 495 EXPECT_EQ(countClientCertChallenges(methods), certChallengesAfterInitialFailure + 1);499 EXPECT_EQ(countClientCertChallenges(methods), certChallengesAfterInitialFailure); 496 500 } 497 501 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm
r259307 r262985 391 391 // FIXME: Add a test for loadedFromCache. 392 392 393 #endif // HAVE(NETWORK_FRAMEWORK)394 395 #if HAVE(SSL)396 397 393 TEST(ResourceLoadDelegate, Challenge) 398 394 { 399 395 using namespace TestWebKitAPI; 400 TCPServer server(TCPServer::Protocol::HTTPS, [] (SSL* ssl) { 401 EXPECT_TRUE(!!ssl); // Connection should succeed after a server trust challenge. 402 // Send nothing to make the resource load fail. 403 }); 396 HTTPServer server(HTTPServer::respondWithChallengeThenOK); 404 397 405 398 auto navigationDelegate = adoptNS([TestNavigationDelegate new]); 406 399 [navigationDelegate setDidReceiveAuthenticationChallenge:^(WKWebView *, NSURLAuthenticationChallenge *challenge, void (^completionHandler)(NSURLSessionAuthChallengeDisposition, NSURLCredential *)) { 407 EXPECT_WK_STREQ(challenge.protectionSpace.authenticationMethod, NSURLAuthenticationMethod ServerTrust);408 completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credential ForTrust:challenge.protectionSpace.serverTrust]);400 EXPECT_WK_STREQ(challenge.protectionSpace.authenticationMethod, NSURLAuthenticationMethodHTTPBasic); 401 completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialWithUser:@"testuser" password:@"testpassword" persistence:NSURLCredentialPersistenceNone]); 409 402 }]; 410 403 … … 413 406 auto resourceLoadDelegate = adoptNS([TestResourceLoadDelegate new]); 414 407 [resourceLoadDelegate setDidReceiveChallenge:^(WKWebView *, _WKResourceLoadInfo *, NSURLAuthenticationChallenge *challenge) { 415 EXPECT_WK_STREQ(challenge.protectionSpace.authenticationMethod, NSURLAuthenticationMethod ServerTrust);408 EXPECT_WK_STREQ(challenge.protectionSpace.authenticationMethod, NSURLAuthenticationMethodHTTPBasic); 416 409 receivedChallengeNotificiation = true; 417 410 }]; 418 411 [resourceLoadDelegate setDidCompleteWithError:^(WKWebView *, _WKResourceLoadInfo *, NSError *error, NSURLResponse *) { 419 EXPECT_EQ(error.code, kCFURLErrorCannotConnectToHost); 420 EXPECT_WK_STREQ(error.domain, NSURLErrorDomain); 412 EXPECT_FALSE(error); 421 413 receivedErrorNotification = true; 422 414 }]; … … 425 417 [webView setNavigationDelegate:navigationDelegate.get()]; 426 418 [webView _setResourceLoadDelegate:resourceLoadDelegate.get()]; 427 [webView loadRequest: [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://127.0.0.1:%d/", server.port()]]]];419 [webView loadRequest:server.request()]; 428 420 TestWebKitAPI::Util::run(&receivedErrorNotification); 429 421 EXPECT_TRUE(receivedChallengeNotificiation); 430 422 } 431 423 432 #endif // HAVE( SSL)424 #endif // HAVE(NETWORK_FRAMEWORK) -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm
r262493 r262985 1574 1574 } 1575 1575 1576 #if HAVE(NETWORK_FRAMEWORK) 1577 1576 1578 static size_t launchServiceWorkerProcess(bool useSeparateServiceWorkerProcess, bool loadAboutBlankBeforePage) 1577 1579 { … … 1590 1592 [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"]; 1591 1593 1592 ServiceWorkerTCPServer server({1593 { " text/html", mainBytes},1594 { " application/javascript", scriptBytes },1594 TestWebKitAPI::HTTPServer server({ 1595 { "/", { mainBytes } }, 1596 { "/sw.js", { {{ "Content-Type", "application/javascript" }}, scriptBytes } } 1595 1597 }); 1596 1598 … … 1635 1637 EXPECT_EQ(2u, launchServiceWorkerProcess(useSeparateServiceWorkerProcess, firstLoadAboutBlank)); 1636 1638 } 1639 1640 #endif // HAVE(NETWORK_FRAMEWORK) 1637 1641 1638 1642 void waitUntilServiceWorkerProcessForegroundActivityState(WKWebView *page, bool shouldHaveActivity) -
trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.h
r262018 r262985 54 54 size_t totalRequests() const; 55 55 56 static void respondWithChallengeThenOK(Connection); 57 56 58 private: 57 59 static RetainPtr<nw_parameters_t> listenerParameters(Protocol, CertificateVerifier&&); -
trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.mm
r262018 r262985 116 116 HTTPServer::~HTTPServer() = default; 117 117 118 void HTTPServer::respondWithChallengeThenOK(Connection connection) 119 { 120 connection.receiveHTTPRequest([connection] (Vector<char>&&) { 121 const char* challengeHeader = 122 "HTTP/1.1 401 Unauthorized\r\n" 123 "Date: Sat, 23 Mar 2019 06:29:01 GMT\r\n" 124 "Content-Length: 0\r\n" 125 "WWW-Authenticate: Basic realm=\"testrealm\"\r\n\r\n"; 126 connection.send(challengeHeader, [connection] { 127 connection.receiveHTTPRequest([connection] (Vector<char>&&) { 128 connection.send( 129 "HTTP/1.1 200 OK\r\n" 130 "Content-Length: 13\r\n\r\n" 131 "Hello, World!" 132 ); 133 }); 134 }); 135 }); 136 } 137 118 138 size_t HTTPServer::totalRequests() const 119 139 {
Note:
See TracChangeset
for help on using the changeset viewer.