Diff
Modified: releases/WebKitGTK/webkit-2.0/Source/WebKit2/ChangeLog (144889 => 144890)
--- releases/WebKitGTK/webkit-2.0/Source/WebKit2/ChangeLog 2013-03-06 07:53:47 UTC (rev 144889)
+++ releases/WebKitGTK/webkit-2.0/Source/WebKit2/ChangeLog 2013-03-06 07:54:56 UTC (rev 144890)
@@ -1,3 +1,46 @@
+2013-03-05 Manuel Rego Casasnovas <r...@igalia.com>
+
+ [GTK][WK2] Add WebKitWebPage::webkit_web_page_get_uri to WebKit2 GTK+ API
+ https://bugs.webkit.org/show_bug.cgi?id=111288
+
+ Reviewed by Carlos Garcia Campos.
+
+ Add new property URI to WebKitWebPage providing a method
+ webkit_web_page_get_uri to get it and the signal "notify::uri" to
+ monitor changes in the URI.
+
+ * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Include new method in
+ GTK+ doc.
+ * UIProcess/API/gtk/tests/TestLoaderClient.cpp:
+ (testWebPageURI):
+ (beforeAll):
+ (afterAll): Add test to check that WebKitWebPage URI matches with
+ WebKitWebView value. The tests is listening for changes in WebKitWebPage
+ URI via D-Bus and checks that value is the same than WebKitWebView URI.
+ It also checks that the order of the URIs in a redirection is right.
+ * UIProcess/API/gtk/tests/WebExtensionTest.cpp:
+ (uriChangedCallback):
+ (pageCreatedCallback): Add new D-Bus signal "URIChanged" connected to
+ "notify::uri" signal of WebKitWebPage.
+ * WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp:
+ (_WebKitWebPagePrivate): Add new URI attribute.
+ (webkitWebPageSetURI): Method to set the URI and emit the "notify:uri"
+ signal if it has changed.
+ (didStartProvisionalLoadForFrame): At this point it use the unreachable
+ URL from provisional document loader if any. Otherwise, it uses the URL
+ from provisional document loader.
+ (didReceiveServerRedirectForProvisionalLoadForFrame): In the case of
+ redirections it works like for didStartProvisionalLoadForFrame getting
+ the unreachable URL if any.
+ (didSameDocumentNavigationForFrame): In this case it gets the URL from
+ the document loader.
+ (webkitWebPageGetProperty): Add code related to URI property.
+ (webkit_web_page_class_init): Add bits related to URI property.
+ (webkitWebPageCreate): Implement callbacks to monitor URI changes.
+ (webkit_web_page_get_uri): Return URI attribute.
+ * WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h: Add new method
+ header.
+
2013-03-04 Carlos Garcia Campos <cgar...@igalia.com>
[GTK] Some WebKit2 GTK+ unit tests are failing in 32 bits bot
Modified: releases/WebKitGTK/webkit-2.0/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (144889 => 144890)
--- releases/WebKitGTK/webkit-2.0/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt 2013-03-06 07:53:47 UTC (rev 144889)
+++ releases/WebKitGTK/webkit-2.0/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt 2013-03-06 07:54:56 UTC (rev 144890)
@@ -954,6 +954,7 @@
<FILE>WebKitWebPage</FILE>
WebKitWebPage
webkit_web_page_get_dom_document
+webkit_web_page_get_uri
<SUBSECTION Standard>
WebKitWebPageClass
Modified: releases/WebKitGTK/webkit-2.0/Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp (144889 => 144890)
--- releases/WebKitGTK/webkit-2.0/Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp 2013-03-06 07:53:47 UTC (rev 144889)
+++ releases/WebKitGTK/webkit-2.0/Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp 2013-03-06 07:54:56 UTC (rev 144890)
@@ -22,11 +22,14 @@
#include "config.h"
#include "LoadTrackingTest.h"
+#include "WebKitTestBus.h"
#include "WebKitTestServer.h"
+#include "WebViewTest.h"
#include <gtk/gtk.h>
#include <libsoup/soup.h>
#include <wtf/text/CString.h>
+static WebKitTestBus* bus;
static WebKitTestServer* kServer;
static void testLoadingStatus(LoadTrackingTest* test, gconstpointer data)
@@ -280,6 +283,62 @@
test->waitUntilLoadFinished();
}
+class WebPageURITest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(WebPageURITest);
+
+ static void webPageURIChangedCallback(GDBusConnection*, const char*, const char*, const char*, const char*, GVariant* result, WebPageURITest* test)
+ {
+ const char* uri;
+ g_variant_get(result, "(&s)", &uri);
+ test->m_webPageURIs.append(uri);
+ }
+
+ static void webViewURIChanged(GObject*, GParamSpec*, WebPageURITest* test)
+ {
+ test->m_webViewURIs.append(webkit_web_view_get_uri(test->m_webView));
+ }
+
+ WebPageURITest()
+ {
+ GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest",
+ "/org/webkit/gtk/WebExtensionTest", "org.webkit.gtk.WebExtensionTest", m_mainLoop));
+ guint id = g_dbus_connection_signal_subscribe(
+ g_dbus_proxy_get_connection(proxy.get()),
+ 0,
+ "org.webkit.gtk.WebExtensionTest",
+ "URIChanged",
+ "/org/webkit/gtk/WebExtensionTest",
+ 0,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ reinterpret_cast<GDBusSignalCallback>(webPageURIChangedCallback),
+ this,
+ 0);
+ g_assert(id);
+
+ g_signal_connect(m_webView, "notify::uri", G_CALLBACK(webViewURIChanged), this);
+ }
+
+ Vector<CString> m_webPageURIs;
+ Vector<CString> m_webViewURIs;
+
+};
+
+static void testWebPageURI(WebPageURITest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/redirect").data());
+ test->waitUntilLoadFinished();
+
+ g_assert_cmpint(test->m_webPageURIs.size(), ==, test->m_webViewURIs.size());
+ for (size_t i = 0; i < test->m_webPageURIs.size(); ++i)
+ ASSERT_CMP_CSTRING(test->m_webPageURIs[i], ==, test->m_webViewURIs[i]);
+
+ g_assert_cmpint(test->m_webPageURIs.size(), ==, 2);
+ ASSERT_CMP_CSTRING(test->m_webPageURIs[0], ==, kServer->getURIForPath("/redirect"));
+ ASSERT_CMP_CSTRING(test->m_webPageURIs[1], ==, kServer->getURIForPath("/normal"));
+
+}
+
static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
{
static const char* responseString = "<html><body>Testing!Testing!Testing!Testing!Testing!Testing!Testing!"
@@ -318,6 +377,11 @@
void beforeAll()
{
+ webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
+ bus = new WebKitTestBus();
+ if (!bus->run())
+ return;
+
kServer = new WebKitTestServer();
kServer->run(serverCallback);
@@ -338,9 +402,11 @@
ViewURITrackingTest::add("WebKitWebView", "active-uri", testWebViewActiveURI);
ViewIsLoadingTest::add("WebKitWebView", "is-loading", testWebViewIsLoading);
+ WebPageURITest::add("WebKitWebPage", "get-uri", testWebPageURI);
}
void afterAll()
{
+ delete bus;
delete kServer;
}
Modified: releases/WebKitGTK/webkit-2.0/Source/WebKit2/UIProcess/API/gtk/tests/WebExtensionTest.cpp (144889 => 144890)
--- releases/WebKitGTK/webkit-2.0/Source/WebKit2/UIProcess/API/gtk/tests/WebExtensionTest.cpp 2013-03-06 07:53:47 UTC (rev 144889)
+++ releases/WebKitGTK/webkit-2.0/Source/WebKit2/UIProcess/API/gtk/tests/WebExtensionTest.cpp 2013-03-06 07:54:56 UTC (rev 144890)
@@ -31,6 +31,9 @@
" <arg type='s' name='title' direction='out'/>"
" </method>"
" <signal name='DocumentLoaded'/>"
+ " <signal name='URIChanged'>"
+ " <arg type='s' name='uri' direction='out'/>"
+ " </signal>"
" </interface>"
"</node>";
@@ -46,9 +49,23 @@
g_assert(ok);
}
+static void uriChangedCallback(WebKitWebPage* webPage, GParamSpec* pspec, gpointer userData)
+{
+ bool ok = g_dbus_connection_emit_signal(
+ G_DBUS_CONNECTION(userData),
+ 0,
+ "/org/webkit/gtk/WebExtensionTest",
+ "org.webkit.gtk.WebExtensionTest",
+ "URIChanged",
+ g_variant_new("(s)", webkit_web_page_get_uri(webPage)),
+ 0);
+ g_assert(ok);
+}
+
static void pageCreatedCallback(WebKitWebExtension*, WebKitWebPage* webPage, gpointer userData)
{
g_signal_connect(webPage, "document-loaded", G_CALLBACK(documentLoadedCallback), userData);
+ g_signal_connect(webPage, "notify::uri", G_CALLBACK(uriChangedCallback), userData);
}
static void methodCallCallback(GDBusConnection* connection, const char* sender, const char* objectPath, const char* interfaceName, const char* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData)
Modified: releases/WebKitGTK/webkit-2.0/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp (144889 => 144890)
--- releases/WebKitGTK/webkit-2.0/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp 2013-03-06 07:53:47 UTC (rev 144889)
+++ releases/WebKitGTK/webkit-2.0/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp 2013-03-06 07:54:56 UTC (rev 144890)
@@ -23,12 +23,17 @@
#include "ImmutableDictionary.h"
#include "InjectedBundle.h"
#include "WKBundleAPICast.h"
+#include "WKBundleFrame.h"
#include "WebFrame.h"
#include "WebKitDOMDocumentPrivate.h"
#include "WebKitPrivate.h"
#include "WebKitWebPagePrivate.h"
#include "WebProcess.h"
+#include <WebCore/Document.h>
+#include <WebCore/DocumentLoader.h>
#include <WebCore/Frame.h>
+#include <glib/gi18n-lib.h>
+#include <wtf/text/CString.h>
using namespace WebKit;
using namespace WebCore;
@@ -39,14 +44,64 @@
LAST_SIGNAL
};
+enum {
+ PROP_0,
+
+ PROP_URI
+};
+
struct _WebKitWebPagePrivate {
WebPage* webPage;
+
+ CString uri;
};
static guint signals[LAST_SIGNAL] = { 0, };
WEBKIT_DEFINE_TYPE(WebKitWebPage, webkit_web_page, G_TYPE_OBJECT)
+static CString getProvisionalURLForFrame(WebFrame* webFrame)
+{
+ DocumentLoader* documentLoader = webFrame->coreFrame()->loader()->provisionalDocumentLoader();
+ if (!documentLoader->unreachableURL().isEmpty())
+ return documentLoader->unreachableURL().string().utf8();
+
+ return documentLoader->url().string().utf8();
+}
+
+static void webkitWebPageSetURI(WebKitWebPage* webPage, const CString& uri)
+{
+ if (webPage->priv->uri == uri)
+ return;
+
+ webPage->priv->uri = uri;
+ g_object_notify(G_OBJECT(webPage), "uri");
+}
+
+static void didStartProvisionalLoadForFrame(WKBundlePageRef, WKBundleFrameRef frame, WKTypeRef*, const void *clientInfo)
+{
+ if (!WKBundleFrameIsMainFrame(frame))
+ return;
+
+ webkitWebPageSetURI(WEBKIT_WEB_PAGE(clientInfo), getProvisionalURLForFrame(toImpl(frame)));
+}
+
+static void didReceiveServerRedirectForProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo)
+{
+ if (!WKBundleFrameIsMainFrame(frame))
+ return;
+
+ webkitWebPageSetURI(WEBKIT_WEB_PAGE(clientInfo), getProvisionalURLForFrame(toImpl(frame)));
+}
+
+static void didSameDocumentNavigationForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef* userData, const void *clientInfo)
+{
+ if (!WKBundleFrameIsMainFrame(frame))
+ return;
+
+ webkitWebPageSetURI(WEBKIT_WEB_PAGE(clientInfo), toImpl(frame)->coreFrame()->document()->url().string().utf8());
+}
+
static void didFinishDocumentLoadForFrame(WKBundlePageRef, WKBundleFrameRef, WKTypeRef*, const void *clientInfo)
{
g_signal_emit(WEBKIT_WEB_PAGE(clientInfo), signals[DOCUMENT_LOADED], 0);
@@ -111,9 +166,41 @@
WebProcess::shared().injectedBundle()->postMessage(String::fromUTF8("WebPage.DidFailLoadForResource"), ImmutableDictionary::adopt(message).get());
}
+static void webkitWebPageGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)
+{
+ WebKitWebPage* webPage = WEBKIT_WEB_PAGE(object);
+
+ switch (propId) {
+ case PROP_URI:
+ g_value_set_string(value, webkit_web_page_get_uri(webPage));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+ }
+}
+
static void webkit_web_page_class_init(WebKitWebPageClass* klass)
{
+ GObjectClass* gObjectClass = G_OBJECT_CLASS(klass);
+
+ gObjectClass->get_property = webkitWebPageGetProperty;
+
/**
+ * WebKitWebPage:uri:
+ *
+ * The current active URI of the #WebKitWebPage.
+ */
+ g_object_class_install_property(
+ gObjectClass,
+ PROP_URI,
+ g_param_spec_string(
+ "uri",
+ _("URI"),
+ _("The current active URI of the web page"),
+ 0,
+ WEBKIT_PARAM_READABLE));
+
+ /**
* WebKitWebPage::document-loaded:
* @web_page: the #WebKitWebPage on which the signal is emitted
*
@@ -140,14 +227,14 @@
WKBundlePageLoaderClient loaderClient = {
kWKBundlePageResourceLoadClientCurrentVersion,
page,
- 0, // didStartProvisionalLoadForFrame
- 0, // didReceiveServerRedirectForProvisionalLoadForFrame
+ didStartProvisionalLoadForFrame,
+ didReceiveServerRedirectForProvisionalLoadForFrame,
0, // didFailProvisionalLoadWithErrorForFrame
0, // didCommitLoadForFrame
didFinishDocumentLoadForFrame,
0, // didFinishLoadForFrame,
0, // didFailLoadWithErrorForFrame
- 0, // didSameDocumentNavigationForFrame
+ didSameDocumentNavigationForFrame,
0, // didReceiveTitleForFrame
0, // didFirstLayoutForFrame
0, // didFirstVisuallyNonEmptyLayoutForFrame
@@ -210,3 +297,22 @@
return kit(coreFrame->document());
}
+
+/**
+ * webkit_web_page_get_uri:
+ * @web_page: a #WebKitWebPage
+ *
+ * Returns the current active URI of @web_page.
+ *
+ * You can monitor the active URI by connecting to the notify::uri
+ * signal of @web_page.
+ *
+ * Returns: the current active URI of @web_view or %NULL if nothing has been
+ * loaded yet.
+ */
+const gchar* webkit_web_page_get_uri(WebKitWebPage* webPage)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_PAGE(webPage), 0);
+
+ return webPage->priv->uri.data();
+}
Modified: releases/WebKitGTK/webkit-2.0/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h (144889 => 144890)
--- releases/WebKitGTK/webkit-2.0/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h 2013-03-06 07:53:47 UTC (rev 144889)
+++ releases/WebKitGTK/webkit-2.0/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h 2013-03-06 07:54:56 UTC (rev 144890)
@@ -57,6 +57,9 @@
WEBKIT_API WebKitDOMDocument *
webkit_web_page_get_dom_document (WebKitWebPage *web_page);
+WEBKIT_API const gchar *
+webkit_web_page_get_uri (WebKitWebPage *web_page);
+
G_END_DECLS
#endif