aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--embed/ephy-web-view.c32
-rw-r--r--tests/ephy-web-view-test.c49
2 files changed, 80 insertions, 1 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 26d4b2e07..f27226555 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -80,6 +80,7 @@ struct _EphyWebViewPrivate {
guint is_loading : 1;
#endif
guint load_failed : 1;
+ guint history_frozen : 1;
char *address;
char *typed_address;
@@ -2073,6 +2074,24 @@ ephy_web_view_location_changed (EphyWebView *view,
g_object_thaw_notify (object);
}
+static void
+ephy_web_view_freeze_history (EphyWebView *view)
+{
+ view->priv->history_frozen = TRUE;
+}
+
+static void
+ephy_web_view_thaw_history (EphyWebView *view)
+{
+ view->priv->history_frozen = FALSE;
+}
+
+static gboolean
+ephy_web_view_is_history_frozen (EphyWebView *view)
+{
+ return view->priv->history_frozen;
+}
+
#ifdef HAVE_WEBKIT2
static void
load_changed_cb (WebKitWebView *web_view,
@@ -2287,7 +2306,8 @@ load_status_cb (WebKitWebView *web_view,
restore_zoom_level (view, uri);
/* History. */
- if (!ephy_web_view_is_loading_homepage (view)) {
+ if (!ephy_web_view_is_loading_homepage (view) &&
+ !ephy_web_view_is_history_frozen (view)) {
char *history_uri = NULL;
/* TODO: move the normalization down to the history service? */
@@ -2302,6 +2322,8 @@ load_status_cb (WebKitWebView *web_view,
g_free (history_uri);
}
+
+ ephy_web_view_thaw_history (view);
break;
}
case WEBKIT_LOAD_FINISHED: {
@@ -2501,6 +2523,14 @@ 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
+ /* Make our history backend ignore the next page load, since it will be an error page.
+ *
+ * FIXME: at this point error pages in WebKit2 do not trigger load
+ * events, so this is only needed for WebKit1. This might (probably
+ * will?) change soon, so keep an eye on WebKit2 and change this
+ * accordingly.
+ */
+ ephy_web_view_freeze_history (view);
webkit_web_frame_load_alternate_string (webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view)),
html->str, uri, uri);
#endif
diff --git a/tests/ephy-web-view-test.c b/tests/ephy-web-view-test.c
index 78a2eb575..bc41ffff6 100644
--- a/tests/ephy-web-view-test.c
+++ b/tests/ephy-web-view-test.c
@@ -27,6 +27,7 @@
#include "ephy-embed-prefs.h"
#include "ephy-embed-private.h"
#include "ephy-file-helpers.h"
+#include "ephy-history-service.h"
#include "ephy-private.h"
#include "ephy-shell.h"
#include "ephy-web-view.h"
@@ -385,6 +386,51 @@ test_ephy_web_view_provisional_load_failure_updates_back_forward_list ()
g_object_unref (g_object_ref_sink (view));
}
+static gboolean
+visit_url_cb (EphyHistoryService *service,
+ const char *url,
+ EphyHistoryPageVisit visit_type,
+ gpointer user_data)
+{
+ /* We are only loading an error page, this code should never be
+ * reached. */
+ g_assert_not_reached ();
+
+ return FALSE;
+}
+
+static void
+test_ephy_web_view_error_pages_not_stored_in_history ()
+{
+ GMainLoop *loop;
+ EphyWebView *view;
+ const char *bad_url;
+ EphyHistoryService *history_service;
+
+ view = EPHY_WEB_VIEW (ephy_web_view_new ());
+ loop = g_main_loop_new (NULL, FALSE);
+ bad_url = "http://localhost:2984375932/";
+
+ history_service = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service (embed_shell));
+ g_assert (history_service);
+ g_signal_connect (history_service, "visit-url",
+ G_CALLBACK (visit_url_cb), NULL);
+
+ 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);
+
+ g_object_unref (g_object_ref_sink (view));
+}
+
int
main (int argc, char *argv[])
{
@@ -421,6 +467,9 @@ main (int argc, char *argv[])
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);
+ g_test_add_func ("/embed/ephy-web-view/error-pages-not-stored-in-history",
+ test_ephy_web_view_error_pages_not_stored_in_history);
+
ret = g_test_run ();
g_object_unref (server);