diff options
| author | Steve Block <steveblock@google.com> | 2010-04-27 16:23:55 +0100 |
|---|---|---|
| committer | Steve Block <steveblock@google.com> | 2010-04-27 17:07:03 +0100 |
| commit | 692e5dbf12901edacf14812a6fae25462920af42 (patch) | |
| tree | d62802373a429e0a9dc093b6046c166b2c514285 /WebKit/gtk/tests/testdownload.c | |
| parent | e24bea4efef1c414137d36a9778aa4e142e10c7d (diff) | |
| download | external_webkit-692e5dbf12901edacf14812a6fae25462920af42.zip external_webkit-692e5dbf12901edacf14812a6fae25462920af42.tar.gz external_webkit-692e5dbf12901edacf14812a6fae25462920af42.tar.bz2 | |
Merge webkit.org at r55033 : Initial merge by git
Change-Id: I98a4af828067cc243ec3dc5e5826154dd88074b5
Diffstat (limited to 'WebKit/gtk/tests/testdownload.c')
| -rw-r--r-- | WebKit/gtk/tests/testdownload.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/WebKit/gtk/tests/testdownload.c b/WebKit/gtk/tests/testdownload.c index 05c3a8d..c7985d5 100644 --- a/WebKit/gtk/tests/testdownload.c +++ b/WebKit/gtk/tests/testdownload.c @@ -177,6 +177,52 @@ test_webkit_download_asynch(void) test_webkit_download_perform(TRUE); } +static gboolean mime_type_policy_decision_requested_cb(WebKitWebView* view, WebKitWebFrame* frame, + WebKitNetworkRequest* request, const char* mime_type, + WebKitWebPolicyDecision* decision, gpointer data) +{ + webkit_web_policy_decision_download(decision); + return TRUE; +} + +static void idle_quit_loop_cb(WebKitWebView* web_view, GParamSpec* pspec, gpointer data) +{ + if (webkit_web_view_get_load_status(web_view) == WEBKIT_LOAD_FINISHED || + webkit_web_view_get_load_status(web_view) == WEBKIT_LOAD_FAILED) + g_main_loop_quit(loop); +} + +static void +test_webkit_download_data(void) +{ + gboolean beenThere = FALSE; + WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); + g_object_ref_sink(webView); + + g_signal_connect(webView, "download-requested", + G_CALLBACK(download_requested_cb), + &beenThere); + + g_signal_connect(webView, "notify::load-status", + G_CALLBACK(idle_quit_loop_cb), + NULL); + + g_signal_connect(webView, "mime-type-policy-decision-requested", + G_CALLBACK(mime_type_policy_decision_requested_cb), + NULL); + + loop = g_main_loop_new(NULL, TRUE); + + /* We're testing for a crash, so just not crashing is a pass */ + webkit_web_view_load_uri(webView, "data:application/octect-stream,"); + g_main_loop_run(loop); + + g_assert_cmpint(beenThere, ==, TRUE); + + g_main_loop_unref(loop); + g_object_unref(webView); +} + int main(int argc, char** argv) { g_thread_init(NULL); @@ -186,6 +232,7 @@ int main(int argc, char** argv) g_test_add_func("/webkit/download/create", test_webkit_download_create); g_test_add_func("/webkit/download/synch", test_webkit_download_synch); g_test_add_func("/webkit/download/asynch", test_webkit_download_asynch); + g_test_add_func("/webkit/download/data", test_webkit_download_data); return g_test_run (); } |
