Skip to content
Permalink
Browse files
[ iOS15 ] TestWebKitAPI.WebKit.HTTPSProxy is a flaky, but frequent, t…
…imeout

https://bugs.webkit.org/show_bug.cgi?id=231396

Patch by Alex Christensen <achristensen@webkit.org> on 2021-10-18
Reviewed by Chris Dumez.

Something was happening that was very timing dependent that was causing this test to time out.
I think it was because the proxy framer was receiving an incomplete HTTP request.
To fix this, I look at the bytes received and if it wasn't a complete HTTP request, wait for the rest of the message.
I was unable to reproduce the timeout after this change and only rarely reproduced the timeout without this change.

* TestWebKitAPI/Tests/WebKitCocoa/Proxy.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/cocoa/HTTPServer.mm:
(TestWebKitAPI::proxyDefinition):

Canonical link: https://commits.webkit.org/243180@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284409 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Alex Christensen authored and webkit-commit-queue committed Oct 18, 2021
1 parent f0caedf commit e9605dcd9df779992f3561d9821e322bbe8960cc
Showing 3 changed files with 23 additions and 12 deletions.
@@ -1,3 +1,20 @@
2021-10-18 Alex Christensen <achristensen@webkit.org>

[ iOS15 ] TestWebKitAPI.WebKit.HTTPSProxy is a flaky, but frequent, timeout
https://bugs.webkit.org/show_bug.cgi?id=231396

Reviewed by Chris Dumez.

Something was happening that was very timing dependent that was causing this test to time out.
I think it was because the proxy framer was receiving an incomplete HTTP request.
To fix this, I look at the bytes received and if it wasn't a complete HTTP request, wait for the rest of the message.
I was unable to reproduce the timeout after this change and only rarely reproduced the timeout without this change.

* TestWebKitAPI/Tests/WebKitCocoa/Proxy.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/cocoa/HTTPServer.mm:
(TestWebKitAPI::proxyDefinition):

2021-10-18 Chris Dumez <cdumez@apple.com>

Add a callback to know when the service worker loads via -[WKWebView _loadServiceWorker:]
@@ -39,8 +39,6 @@
#import <wtf/RetainPtr.h>
#import <wtf/text/StringConcatenateNumbers.h>

#if HAVE(SSL)

@interface ProxyDelegate : NSObject <WKNavigationDelegate, WKUIDelegate>
- (NSString *)waitForAlert;
@end
@@ -75,8 +73,6 @@ - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAut

namespace TestWebKitAPI {

// FIXME: Re-enable this test once webkit.org/b/231396 is resolved.
#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 150000
TEST(WebKit, HTTPSProxy)
{
HTTPServer server(HTTPServer::respondWithOK, HTTPServer::Protocol::HttpsProxy);
@@ -94,7 +90,6 @@ - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAut
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://example.com/"]]];
EXPECT_WK_STREQ([delegate waitForAlert], "success!");
}
#endif

TEST(WebKit, SOCKS5)
{
@@ -242,12 +237,6 @@ HTTPServer server([&] (const Connection& connection) {
TestWebKitAPI::Util::run(&receivedValidClientHello);
}

} // namespace TestWebKitAPI

#endif // HAVE(SSL)

namespace TestWebKitAPI {

TEST(WebKit, RelaxThirdPartyCookieBlocking)
{
__block bool setDefaultCookieAcceptPolicy = false;
@@ -56,9 +56,13 @@
{
return adoptNS(nw_framer_create_definition("HttpsProxy", NW_FRAMER_CREATE_FLAGS_DEFAULT, [protocol] (nw_framer_t framer) -> nw_framer_start_result_t {
__block bool askedForCredentials = false;
__block Vector<char> requestBuffer;
nw_framer_set_input_handler(framer, ^size_t(nw_framer_t framer) {
__block RetainPtr<nw_framer_t> retainedFramer = framer;
nw_framer_parse_input(framer, 1, std::numeric_limits<uint32_t>::max(), nullptr, ^size_t(uint8_t* buffer, size_t bufferLength, bool) {
requestBuffer.append(reinterpret_cast<const char*>(buffer), bufferLength);
if (!strnstr(requestBuffer.data(), "\r\n\r\n", requestBuffer.size()))
return bufferLength;
if (protocol == HTTPServer::Protocol::HttpsProxyWithAuthentication) {
if (!std::exchange(askedForCredentials, true)) {
const char* challengeResponse =
@@ -68,9 +72,10 @@
"\r\n";
auto response = adoptNS(dispatch_data_create(challengeResponse, strlen(challengeResponse), nullptr, nullptr));
nw_framer_write_output_data(retainedFramer.get(), response.get());
requestBuffer = { };
return bufferLength;
}
EXPECT_TRUE(strnstr(reinterpret_cast<const char*>(buffer), "Proxy-Authorization: Basic dGVzdHVzZXI6dGVzdHBhc3N3b3Jk", bufferLength));
EXPECT_TRUE(strnstr(requestBuffer.data(), "Proxy-Authorization: Basic dGVzdHVzZXI6dGVzdHBhc3N3b3Jk", requestBuffer.size()));
}
const char* negotiationResponse = ""
"HTTP/1.1 200 Connection Established\r\n"

0 comments on commit e9605dc

Please sign in to comment.