diff options
-rw-r--r-- | embed/ephy-web-view.c | 4 | ||||
-rw-r--r-- | tests/ephy-web-view-test.c | 73 |
2 files changed, 75 insertions, 2 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index 682a98d39..26d4b2e07 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -2501,8 +2501,8 @@ ephy_web_view_load_error_page (EphyWebView *view, #ifdef HAVE_WEBKIT2 webkit_web_view_replace_content (WEBKIT_WEB_VIEW (view), html->str, uri, 0); #else - webkit_web_view_load_string (WEBKIT_WEB_VIEW (view), - html->str, "text/html", "utf8", uri); + webkit_web_frame_load_alternate_string (webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view)), + html->str, uri, uri); #endif g_string_free (html, TRUE); } diff --git a/tests/ephy-web-view-test.c b/tests/ephy-web-view-test.c index 815dd629d..78a2eb575 100644 --- a/tests/ephy-web-view-test.c +++ b/tests/ephy-web-view-test.c @@ -315,6 +315,76 @@ test_ephy_web_view_normalize_or_autosearch () g_object_unref (g_object_ref_sink (view)); } +#ifdef HAVE_WEBKIT2 +static void +quit_main_loop_when_load_finished (WebKitWebView *view, WebKitLoadEvent load_event, GMainLoop *loop) +{ + if (load_event != WEBKIT_LOAD_FINISHED) + return; + + g_main_loop_quit (loop); + g_signal_handlers_disconnect_by_func (view, quit_main_loop_when_load_finished, NULL); +} +#else +static void +quit_main_loop_when_load_finished (WebKitWebView *view, GParamSpec *spec, GMainLoop *loop) +{ + WebKitLoadStatus status; + + status = webkit_web_view_get_load_status (view); + + if (status != WEBKIT_LOAD_FINISHED) + return; + + g_main_loop_quit (loop); + g_signal_handlers_disconnect_by_func (view, quit_main_loop_when_load_finished, loop); + +} +#endif + +static void +test_ephy_web_view_provisional_load_failure_updates_back_forward_list () +{ + GMainLoop *loop; + EphyWebView *view; + const char *bad_url; + + view = EPHY_WEB_VIEW (ephy_web_view_new ()); + loop = g_main_loop_new (NULL, FALSE); + bad_url = "http://localhost:2984375932/"; + + ephy_web_view_load_url (view, bad_url); + +#ifdef HAVE_WEBKIT2 + g_signal_connect (view, "load-changed", + G_CALLBACK (quit_main_loop_when_load_finished), loop); +#else + g_signal_connect (view, "notify::load-status", + G_CALLBACK (quit_main_loop_when_load_finished), loop); +#endif + + g_main_loop_run (loop); + g_main_loop_unref (loop); + +#ifdef HAVE_WEBKIT2 + g_assert (webkit_back_forward_list_get_current_item ( + webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view)))); + + g_assert_cmpstr (bad_url, ==, webkit_back_forward_list_item_get_uri ( + webkit_back_forward_list_get_current_item ( + webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view))))); +#else + g_assert (webkit_web_back_forward_list_get_current_item ( + webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view)))); + + g_assert_cmpstr (bad_url, ==, webkit_web_history_item_get_uri ( + webkit_web_back_forward_list_get_current_item ( + webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view))))); +#endif + + g_object_unref (g_object_ref_sink (view)); +} + int main (int argc, char *argv[]) { @@ -348,6 +418,9 @@ main (int argc, char *argv[]) g_test_add_func ("/embed/ephy-web-view/load_url", test_ephy_web_view_load_url); + g_test_add_func ("/embed/ephy-web-view/provisional_load_failure_updates_back_forward_list", + test_ephy_web_view_provisional_load_failure_updates_back_forward_list); + ret = g_test_run (); g_object_unref (server); |