Modified: trunk/Source/WebKit2/ChangeLog (98079 => 98080)
--- trunk/Source/WebKit2/ChangeLog 2011-10-21 07:51:42 UTC (rev 98079)
+++ trunk/Source/WebKit2/ChangeLog 2011-10-21 08:09:05 UTC (rev 98080)
@@ -1,3 +1,24 @@
+2011-10-21 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [GTK] Add webkit_web_view_stop_loading() to WebKit2 GTK+ API
+ https://bugs.webkit.org/show_bug.cgi?id=69610
+
+ Reviewed by Martin Robinson.
+
+ * UIProcess/API/gtk/WebKitWebView.cpp:
+ (webkit_web_view_stop_loading):
+ * UIProcess/API/gtk/WebKitWebView.h:
+ * UIProcess/API/gtk/tests/LoadTrackingTest.cpp:
+ (provisionalLoadFailedCallback):
+ (loadFailedCallback):
+ * UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp:
+ (LoadStopTrackingTest::loadCommitted):
+ (LoadStopTrackingTest::loadFailed):
+ (LoadStopTrackingTest::loadFinished):
+ (testLoadCancelled):
+ (serverCallback):
+ (beforeAll):
+
2011-10-20 Jesus Sanchez-Palencia <jesus.palen...@openbossa.org>
[Qt][WK2] qweberror* should follow the new file and class naming rules
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (98079 => 98080)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2011-10-21 07:51:42 UTC (rev 98079)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2011-10-21 08:09:05 UTC (rev 98080)
@@ -315,6 +315,25 @@
}
/**
+ * webkit_web_view_stop_loading:
+ * @web_view: a #WebKitWebView
+ *
+ * Stops any ongoing loading operation in @web_view.
+ * This method does nothing if no content is being loaded.
+ * If there is a loading operation in progress, it will be cancelled and
+ * #WebKitWebLoaderClient::provisional-load-failed or
+ * #WebKitWebLoaderClient::load-failed will be emitted on the current
+ * #WebKitWebLoaderClient with %WEBKIT_NETWORK_ERROR_CANCELLED error.
+ * See also webkit_web_view_get_loader_client().
+ */
+void webkit_web_view_stop_loading(WebKitWebView* webView)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ WKPageStopLoading(toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))));
+}
+
+/**
* webkit_web_view_go_back:
* @web_view: a #WebKitWebView
*
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h (98079 => 98080)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h 2011-10-21 07:51:42 UTC (rev 98079)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h 2011-10-21 08:09:05 UTC (rev 98080)
@@ -94,6 +94,9 @@
const gchar *unreachable_uri);
WEBKIT_API void
+webkit_web_view_stop_loading (WebKitWebView *web_view);
+
+WEBKIT_API void
webkit_web_view_reload (WebKitWebView *web_view);
WEBKIT_API void
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp (98079 => 98080)
--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp 2011-10-21 07:51:42 UTC (rev 98079)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp 2011-10-21 08:09:05 UTC (rev 98080)
@@ -36,6 +36,7 @@
static gboolean provisionalLoadFailedCallback(WebKitWebLoaderClient* client, WebKitWebView*, const gchar* failingURI, GError* error, LoadTrackingTest* test)
{
+ g_assert(error);
test->provisionalLoadFailed(client, failingURI, error);
return TRUE;
}
@@ -54,6 +55,7 @@
static gboolean loadFailedCallback(WebKitWebLoaderClient* client, WebKitWebView*, const gchar* failingURI, GError* error, LoadTrackingTest* test)
{
+ g_assert(error);
test->loadFailed(client, failingURI, error);
return TRUE;
}
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp (98079 => 98080)
--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp 2011-10-21 07:51:42 UTC (rev 98079)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp 2011-10-21 08:09:05 UTC (rev 98080)
@@ -70,6 +70,38 @@
assertNormalLoadHappenedAndClearEvents(test->m_loadEvents);
}
+class LoadStopTrackingTest : public LoadTrackingTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(LoadStopTrackingTest);
+
+ virtual void loadCommitted(WebKitWebLoaderClient* client)
+ {
+ LoadTrackingTest::loadCommitted(client);
+ webkit_web_view_stop_loading(m_webView);
+ }
+ virtual void loadFailed(WebKitWebLoaderClient* client, const gchar* failingURI, GError* error)
+ {
+ g_assert(g_error_matches(error, WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED));
+ LoadTrackingTest::loadFailed(client, failingURI, error);
+ }
+ virtual void loadFinished(WebKitWebLoaderClient* client)
+ {
+ g_assert_not_reached();
+ }
+};
+
+static void testLoadCancelled(LoadStopTrackingTest* test, gconstpointer)
+{
+ webkit_web_view_load_uri(test->m_webView, kServer->getURIForPath("/cancelled").data());
+ test->waitUntilLoadFinished();
+
+ Vector<LoadTrackingTest::LoadEvents>& events = test->m_loadEvents;
+ g_assert_cmpint(events.size(), ==, 3);
+ g_assert_cmpint(events[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(events[1], ==, LoadTrackingTest::LoadCommitted);
+ g_assert_cmpint(events[2], ==, LoadTrackingTest::LoadFailed);
+}
+
static void testWebViewReload(LoadTrackingTest* test, gconstpointer)
{
// Check that nothing happens when there's nothing to reload.
@@ -117,6 +149,11 @@
else if (g_str_equal(path, "/redirect")) {
soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
soup_message_headers_append(message->response_headers, "Location", "/normal");
+ } else if (g_str_equal(path, "/cancelled")) {
+ soup_message_headers_set_encoding(message->response_headers, SOUP_ENCODING_CHUNKED);
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, responseString, strlen(responseString));
+ soup_server_unpause_message(server, message);
+ return;
}
soup_message_body_complete(message->response_body);
@@ -130,6 +167,7 @@
LoadTrackingTest::add("WebKitWebLoaderClient", "loading-status", testLoadingStatus);
LoadTrackingTest::add("WebKitWebLoaderClient", "loading-error", testLoadingError);
LoadTrackingTest::add("WebKitWebLoaderClient", "load-alternate-content", testLoadAlternateContent);
+ LoadStopTrackingTest::add("WebKitWebView", "stop-loading", testLoadCancelled);
LoadTrackingTest::add("WebKitWebView", "progress", testLoadProgress);
LoadTrackingTest::add("WebKitWebView", "reload", testWebViewReload);
}