Bug 212180 - [macOS] TestWebKitAPI.WebKit.HTTPReferer is a flaky failure
Summary: [macOS] TestWebKitAPI.WebKit.HTTPReferer is a flaky failure
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-05-20 17:18 PDT by Ryan Haddad
Modified: 2020-05-21 11:52 PDT (History)
5 users (show)

See Also:


Attachments
Patch (21.66 KB, patch)
2020-05-21 10:38 PDT, Alex Christensen
cdumez: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Haddad 2020-05-20 17:18:23 PDT
TestWebKitAPI.WebKit.HTTPReferer is a flaky failure on macOS bots

    TestWebKitAPI.WebKit.HTTPReferer
        
        /Volumes/Data/slave/catalina-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm:63
        Value of: strstr(request.data(), expectedHeaderField.utf8().data())
          Actual: false
        Expected: true
        

https://results.webkit.org/?suite=api-tests&test=TestWebKitAPI.WebKit.HTTPReferer
Comment 1 Radar WebKit Bug Importer 2020-05-20 17:18:44 PDT
<rdar://problem/63470619>
Comment 2 Ryan Haddad 2020-05-20 17:19:20 PDT
This test was added with https://trac.webkit.org/changeset/261402/webkit
Comment 3 Ryan Haddad 2020-05-20 17:19:29 PDT
It looks like it has been flaky since the beginning.
Comment 4 Alex Christensen 2020-05-21 10:38:48 PDT
Created attachment 399966 [details]
Patch
Comment 5 Chris Dumez 2020-05-21 10:42:09 PDT
Comment on attachment 399966 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=399966&action=review

> Tools/TestWebKitAPI/cocoa/HTTPServer.h:53
> +    NSURLRequest *request(const String& path = "/") const;

"/"_str

> Tools/TestWebKitAPI/cocoa/HTTPServer.mm:184
> +        responseBuilder.append("HTTP/1.1 ");

These things could use appendLiteral()
Comment 6 Darin Adler 2020-05-21 10:45:15 PDT
Comment on attachment 399966 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=399966&action=review

> Tools/TestWebKitAPI/cocoa/HTTPServer.h:70
> +    Connection(const Connection&) = default;
> +    Connection(Connection&&) = default;
> +    Connection& operator=(const Connection&) = default;
> +    Connection& operator=(Connection&&) = default;

I think you can just leave all of this out and it should still work the same. The compiler should generate all of this unless we tell it not to.

> Tools/TestWebKitAPI/cocoa/HTTPServer.mm:190
> +        responseBuilder.append("HTTP/1.1 ");
> +        responseBuilder.appendNumber(response.statusCode);
> +        responseBuilder.append(' ');
> +        responseBuilder.append(statusText(response.statusCode));
> +        responseBuilder.append("\r\nContent-Length: ");
> +        responseBuilder.appendNumber(response.body.length());
> +        responseBuilder.append("\r\n");

Possible drive-by improvement. Variadic append is possibly easier to read, and happens to be more efficient as well:

    responseBuilder.append("HTTP/1.1 ", response.statusCode, ' ', statusText(response.statusCode), "\r\n"
        "Content-Length: ", response.body.length(), "\r\n");

> Tools/TestWebKitAPI/cocoa/HTTPServer.mm:195
> +            responseBuilder.append(pair.key);
> +            responseBuilder.append(": ");
> +            responseBuilder.append(pair.value);
>              responseBuilder.append("\r\n");

responseBuilder.append(pair.key, ": ", pair.value, "\r\n");
Comment 7 Alex Christensen 2020-05-21 11:11:16 PDT
I like the variadic append.  I'm going to separate the lines of the HTTP header like this:

StringBuilder responseBuilder;
responseBuilder.append("HTTP/1.1 ", response.statusCode, ' ', statusText(response.statusCode), "\r\n");
responseBuilder.append("Content-Length: ", response.body.length(), "\r\n");
for (auto& pair : response.headerFields)
    responseBuilder.append(pair.key, ": ", pair.value, "\r\n");
responseBuilder.append("\r\n");
responseBuilder.append(response.body);
Comment 8 Alex Christensen 2020-05-21 11:52:18 PDT
http://trac.webkit.org/r262018