Bug 126119 - [GTK] Test /webkit2/WebKitWebResource/mime-type fails when run after /webkit2/WebKitWebView/resources
Summary: [GTK] Test /webkit2/WebKitWebResource/mime-type fails when run after /webkit2...
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Keywords: Gtk, Soup
Depends on:
Reported: 2013-12-21 06:26 PST by Carlos Garcia Campos
Modified: 2013-12-21 06:37 PST (History)
5 users (show)

See Also:

Patch (3.00 KB, patch)
2013-12-21 06:31 PST, Carlos Garcia Campos
mrobinson: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2013-12-21 06:26:12 PST
It works in the bots because /webkit2/WebKitWebView/resources is skipped.

TEST: Programs/WebKit2APITests/TestResources... (pid=29650)
  /webkit2/WebKitWebView/resources:                                    OK
  /webkit2/WebKitWebView/history-cache:                                OK
  /webkit2/WebKitWebResource/loading:                                  OK
  /webkit2/WebKitWebResource/response:                                 OK
  /webkit2/WebKitWebResource/mime-type:                                **
ERROR:../../Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp:420:void testWebResourceMimeType(SingleResourceLoadTest*, gconstpointer): assertion failed (webkit_uri_response_get_mime_type(response) == "image/vnd.microsoft.icon"): ("" == "image/vnd.microsoft.icon")
GTester: last random seed: R02Sbe744525dd8684ce8d2abbd37b41d1fe

The problem is that when the blank.ico resource is loaded from the disk cache, the mime type is null, because the soup cache doesn't cache sniffed mime types. This doesn't happen when a resource is loaded form the memory cache, because the ResourceResponse is cached, not only the headers. I think the disk cache should also cache the sniffed content type, but that needs to be done in soup. For now we can workaround the issue in the unit test by making sure that resources that can be cached, also include the Content-Type header, this way the mime type won't be sniffed and it will be cached as a HTTP header in the disk cache.
Comment 1 Carlos Garcia Campos 2013-12-21 06:31:19 PST
Created attachment 219849 [details]
Comment 2 WebKit Commit Bot 2013-12-21 06:32:29 PST
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 3 Martin Robinson 2013-12-21 06:33:28 PST
Comment on attachment 219849 [details]

You are doing an awesome job fixing the unit tests as always!
Comment 4 Carlos Garcia Campos 2013-12-21 06:35:29 PST
(In reply to comment #3)
> (From update of attachment 219849 [details])
> You are doing an awesome job fixing the unit tests as always!

Thanks! I want to make sure unit tests are in a good shape so that we can use them to work on network process.
Comment 5 Carlos Garcia Campos 2013-12-21 06:37:40 PST
Committed r160965: <http://trac.webkit.org/changeset/160965>