summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API/gtk/tests
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/UIProcess/API/gtk/tests')
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp10
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp48
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp15
3 files changed, 57 insertions, 16 deletions
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp
index a119e4477..acec9ece1 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp
@@ -88,6 +88,7 @@ public:
static void downloadStartedCallback(WebKitWebContext* context, WebKitDownload* download, DownloadTest* test)
{
+ g_assert(webkit_download_get_request(download));
test->started(download);
g_signal_connect(download, "notify::response", G_CALLBACK(receivedResponseCallback), test);
g_signal_connect(download, "created-destination", G_CALLBACK(createdDestinationCallback), test);
@@ -191,6 +192,10 @@ static void testDownloadLocalFile(DownloadTest* test, gconstpointer)
g_assert_cmpint(events[3], ==, DownloadTest::ReceivedData);
g_assert_cmpint(events[4], ==, DownloadTest::Finished);
+ WebKitURIRequest* request = webkit_download_get_request(download.get());
+ g_assert(request);
+ g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, sourceURI.get());
+
g_assert_cmpint(test->m_downloadSize, ==, g_file_info_get_size(sourceInfo.get()));
g_assert(webkit_download_get_destination(download.get()));
g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), ==, 1);
@@ -328,6 +333,11 @@ static void testDownloadRemoteFile(DownloadTest* test, gconstpointer)
g_assert_cmpint(events[4], ==, DownloadTest::Finished);
events.clear();
+ WebKitURIRequest* request = webkit_download_get_request(download.get());
+ g_assert(request);
+ CString requestURI = kServer->getURIForPath("/test.pdf");
+ g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, requestURI.data());
+
g_assert(webkit_download_get_destination(download.get()));
g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), ==, 1);
test->checkDestinationAndDeleteFile(download.get(), kServerSuggestedFilename);
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp
index 39841756d..7de95e0f0 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp
@@ -300,13 +300,11 @@ public:
g_main_loop_run(m_mainLoop);
}
- int waitUntilResourceLoadFinsihedAndReturnHTTPStatusResponse()
+ WebKitURIResponse* waitUntilResourceLoadFinsihedAndReturnURIResponse()
{
waitUntilResourceLoadFinsihed();
g_assert(m_resource);
- WebKitURIResponse* response = webkit_web_resource_get_response(m_resource.get());
- g_assert(response);
- return webkit_uri_response_get_status_code(response);
+ return webkit_web_resource_get_response(m_resource.get());
}
GRefPtr<WebKitWebResource> m_resource;
@@ -355,33 +353,48 @@ static void testWebResourceResponse(SingleResourceLoadTest* test, gconstpointer)
{
// No cached resource: First load.
test->loadURI(kServer->getURIForPath("/javascript.html").data());
- gint statusCode = test->waitUntilResourceLoadFinsihedAndReturnHTTPStatusResponse();
- g_assert_cmpint(statusCode, ==, SOUP_STATUS_OK);
+ WebKitURIResponse* response = test->waitUntilResourceLoadFinsihedAndReturnURIResponse();
+ g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_OK);
// No cached resource: Second load.
test->loadURI(kServer->getURIForPath("/javascript.html").data());
- statusCode = test->waitUntilResourceLoadFinsihedAndReturnHTTPStatusResponse();
- g_assert_cmpint(statusCode, ==, SOUP_STATUS_OK);
+ response = test->waitUntilResourceLoadFinsihedAndReturnURIResponse();
+ g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_OK);
// No cached resource: Reload.
webkit_web_view_reload(test->m_webView);
- statusCode = test->waitUntilResourceLoadFinsihedAndReturnHTTPStatusResponse();
- g_assert_cmpint(statusCode, ==, SOUP_STATUS_OK);
+ response = test->waitUntilResourceLoadFinsihedAndReturnURIResponse();
+ g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_OK);
// Cached resource: First load.
test->loadURI(kServer->getURIForPath("/image.html").data());
- statusCode = test->waitUntilResourceLoadFinsihedAndReturnHTTPStatusResponse();
- g_assert_cmpint(statusCode, ==, SOUP_STATUS_OK);
+ response = test->waitUntilResourceLoadFinsihedAndReturnURIResponse();
+ g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_OK);
// Cached resource: Second load.
test->loadURI(kServer->getURIForPath("/image.html").data());
- statusCode = test->waitUntilResourceLoadFinsihedAndReturnHTTPStatusResponse();
- g_assert_cmpint(statusCode, ==, SOUP_STATUS_OK);
+ response = test->waitUntilResourceLoadFinsihedAndReturnURIResponse();
+ g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_OK);
// Cached resource: Reload.
webkit_web_view_reload(test->m_webView);
- statusCode = test->waitUntilResourceLoadFinsihedAndReturnHTTPStatusResponse();
- g_assert_cmpint(statusCode, ==, SOUP_STATUS_NOT_MODIFIED);
+ response = test->waitUntilResourceLoadFinsihedAndReturnURIResponse();
+ g_assert_cmpint(webkit_uri_response_get_status_code(response), ==, SOUP_STATUS_NOT_MODIFIED);
+}
+
+static void testWebResourceMimeType(SingleResourceLoadTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/javascript.html").data());
+ WebKitURIResponse* response = test->waitUntilResourceLoadFinsihedAndReturnURIResponse();
+ g_assert_cmpstr(webkit_uri_response_get_mime_type(response), ==, "text/javascript");
+
+ test->loadURI(kServer->getURIForPath("/image.html").data());
+ response = test->waitUntilResourceLoadFinsihedAndReturnURIResponse();
+ g_assert_cmpstr(webkit_uri_response_get_mime_type(response), ==, "image/vnd.microsoft.icon");
+
+ test->loadURI(kServer->getURIForPath("/redirected-css.html").data());
+ response = test->waitUntilResourceLoadFinsihedAndReturnURIResponse();
+ g_assert_cmpstr(webkit_uri_response_get_mime_type(response), ==, "text/css");
}
class ResourceURITrackingTest: public SingleResourceLoadTest {
@@ -555,6 +568,7 @@ static void serverCallback(SoupServer* server, SoupMessage* message, const char*
addCacheHTTPHeadersToResponse(message);
} else if (g_str_equal(path, "/javascript.js")) {
soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, kJavascript, strlen(kJavascript));
+ soup_message_headers_append(message->response_headers, "Content-Type", "text/javascript");
} else if (g_str_equal(path, "/blank.ico")) {
GOwnPtr<char> filePath(g_build_filename(Test::getWebKit1TestResoucesDir().data(), path, NULL));
char* contents;
@@ -569,6 +583,7 @@ static void serverCallback(SoupServer* server, SoupMessage* message, const char*
" padding: 0px;"
"}";
soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, simpleCSS, strlen(simpleCSS));
+ soup_message_headers_append(message->response_headers, "Content-Type", "text/css");
} else if (g_str_equal(path, "/redirected.css")) {
soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
soup_message_headers_append(message->response_headers, "Location", "/simple-style.css");
@@ -585,6 +600,7 @@ void beforeAll()
ResourcesTest::add("WebKitWebView", "resources", testWebViewResources);
SingleResourceLoadTest::add("WebKitWebResource", "loading", testWebResourceLoading);
SingleResourceLoadTest::add("WebKitWebResource", "response", testWebResourceResponse);
+ SingleResourceLoadTest::add("WebKitWebResource", "mime-type", testWebResourceMimeType);
ResourceURITrackingTest::add("WebKitWebResource", "active-uri", testWebResourceActiveURI);
ResourcesTest::add("WebKitWebResource", "get-data", testWebResourceGetData);
ResourcesTest::add("WebKitWebView", "replaced-content", testWebViewResourcesReplacedContent);
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
index e4c60bebc..6ede533d4 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
@@ -706,6 +706,20 @@ static void testWebViewFullScreen(FullScreenClientTest* test, gconstpointer)
g_assert_cmpint(test->m_event, ==, FullScreenClientTest::Leave);
}
+static void testWebViewCanShowMIMEType(WebViewTest* test, gconstpointer)
+{
+ // Supported MIME types.
+ g_assert(webkit_web_view_can_show_mime_type(test->m_webView, "text/html"));
+ g_assert(webkit_web_view_can_show_mime_type(test->m_webView, "text/plain"));
+ g_assert(webkit_web_view_can_show_mime_type(test->m_webView, "image/jpeg"));
+
+ // Unsupported MIME types.
+ g_assert(!webkit_web_view_can_show_mime_type(test->m_webView, "text/vcard"));
+ g_assert(!webkit_web_view_can_show_mime_type(test->m_webView, "application/pdf"));
+ g_assert(!webkit_web_view_can_show_mime_type(test->m_webView, "application/zip"));
+ g_assert(!webkit_web_view_can_show_mime_type(test->m_webView, "application/octet-stream"));
+}
+
void beforeAll()
{
WebViewTest::add("WebKitWebView", "default-context", testWebViewDefaultContext);
@@ -720,6 +734,7 @@ void beforeAll()
WebViewTest::add("WebKitWebView", "run-javascript", testWebViewRunJavaScript);
FileChooserTest::add("WebKitWebView", "file-chooser-request", testWebViewFileChooserRequest);
FullScreenClientTest::add("WebKitWebView", "fullscreen", testWebViewFullScreen);
+ WebViewTest::add("WebKitWebView", "can-show-mime-type", testWebViewCanShowMIMEType);
}
void afterAll()