Title: [176513] trunk
Revision
176513
Author
[email protected]
Date
2014-11-24 03:18:55 -0800 (Mon, 24 Nov 2014)

Log Message

[GTK] WebKitWebView is created with the wrong web context when using webkit_web_view_new_with_related_view()
https://bugs.webkit.org/show_bug.cgi?id=139023

Reviewed by Sergio Villar Senin.

Source/WebKit2:

The WebKitWebContext is a construct only property, so it's always
set to the default value when not provided, during the
construction. When a related-view is used to create a new web view
we should ensure that the same web context is used for the new web
view, instead of the default. We should also ignore any web
context given as construct parameter if a related view is alos provided.

* UIProcess/API/gtk/WebKitWebView.cpp:
(webkitWebViewConstructed): Do not set the context to the default
one when not given during construction.
(webkitWebViewSetProperty): Only use the default web context when
not provided as construct parameter and there isn't a related view.

Tools:

Rename WebKitWebView/default-context as WebKitWebView/web-context
and check we are always using the right context for new web views.

* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp:
(testWebViewWebContext):
(beforeAll):
(testWebViewDefaultContext): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (176512 => 176513)


--- trunk/Source/WebKit2/ChangeLog	2014-11-24 07:24:01 UTC (rev 176512)
+++ trunk/Source/WebKit2/ChangeLog	2014-11-24 11:18:55 UTC (rev 176513)
@@ -1,3 +1,23 @@
+2014-11-24  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] WebKitWebView is created with the wrong web context when using webkit_web_view_new_with_related_view()
+        https://bugs.webkit.org/show_bug.cgi?id=139023
+
+        Reviewed by Sergio Villar Senin.
+
+        The WebKitWebContext is a construct only property, so it's always
+        set to the default value when not provided, during the
+        construction. When a related-view is used to create a new web view
+        we should ensure that the same web context is used for the new web
+        view, instead of the default. We should also ignore any web
+        context given as construct parameter if a related view is alos provided.
+
+        * UIProcess/API/gtk/WebKitWebView.cpp:
+        (webkitWebViewConstructed): Do not set the context to the default
+        one when not given during construction.
+        (webkitWebViewSetProperty): Only use the default web context when
+        not provided as construct parameter and there isn't a related view.
+
 2014-11-23  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Add API to override the default local storage directory

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (176512 => 176513)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp	2014-11-24 07:24:01 UTC (rev 176512)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp	2014-11-24 11:18:55 UTC (rev 176513)
@@ -564,13 +564,17 @@
 
 static void webkitWebViewConstructed(GObject* object)
 {
-    if (G_OBJECT_CLASS(webkit_web_view_parent_class)->constructed)
-        G_OBJECT_CLASS(webkit_web_view_parent_class)->constructed(object);
+    G_OBJECT_CLASS(webkit_web_view_parent_class)->constructed(object);
 
     WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
     WebKitWebViewPrivate* priv = webView->priv;
+    if (priv->relatedView)
+        priv->context = webkit_web_view_get_context(priv->relatedView);
+    else if (!priv->context)
+        priv->context = webkit_web_context_get_default();
     if (!priv->settings)
         priv->settings = adoptGRef(webkit_settings_new());
+
     webkitWebContextCreatePageForWebView(priv->context, webView, priv->userContentManager.get(), priv->relatedView);
 
     priv->loadObserver = std::make_unique<PageLoadStateObserver>(webView);
@@ -603,7 +607,7 @@
     switch (propId) {
     case PROP_WEB_CONTEXT: {
         gpointer webContext = g_value_get_object(value);
-        webView->priv->context = webContext ? WEBKIT_WEB_CONTEXT(webContext) : webkit_web_context_get_default();
+        webView->priv->context = webContext ? WEBKIT_WEB_CONTEXT(webContext) : nullptr;
         break;
     }
     case PROP_RELATED_VIEW: {

Modified: trunk/Tools/ChangeLog (176512 => 176513)


--- trunk/Tools/ChangeLog	2014-11-24 07:24:01 UTC (rev 176512)
+++ trunk/Tools/ChangeLog	2014-11-24 11:18:55 UTC (rev 176513)
@@ -1,3 +1,18 @@
+2014-11-24  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] WebKitWebView is created with the wrong web context when using webkit_web_view_new_with_related_view()
+        https://bugs.webkit.org/show_bug.cgi?id=139023
+
+        Reviewed by Sergio Villar Senin.
+
+        Rename WebKitWebView/default-context as WebKitWebView/web-context
+        and check we are always using the right context for new web views.
+
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp:
+        (testWebViewWebContext):
+        (beforeAll):
+        (testWebViewDefaultContext): Deleted.
+
 2014-11-23  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Add API to override the default local storage directory

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp (176512 => 176513)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp	2014-11-24 07:24:01 UTC (rev 176512)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp	2014-11-24 11:18:55 UTC (rev 176513)
@@ -24,13 +24,23 @@
 #include <glib/gstdio.h>
 #include <wtf/gobject/GRefPtr.h>
 
-static void testWebViewDefaultContext(WebViewTest* test, gconstpointer)
+static void testWebViewWebContext(WebViewTest* test, gconstpointer)
 {
     g_assert(webkit_web_view_get_context(test->m_webView) == test->m_webContext.get());
+    g_assert(webkit_web_context_get_default() != test->m_webContext.get());
 
     // Check that a web view created with g_object_new has the default context.
-    GRefPtr<WebKitWebView> webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW, NULL));
+    GRefPtr<WebKitWebView> webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW, nullptr));
     g_assert(webkit_web_view_get_context(webView.get()) == webkit_web_context_get_default());
+
+    // Check that a web view created with a related view has the related view context.
+    webView = WEBKIT_WEB_VIEW(webkit_web_view_new_with_related_view(test->m_webView));
+    g_assert(webkit_web_view_get_context(webView.get()) == test->m_webContext.get());
+
+    // Check that a web context given as construct parameter is ignored if a related view is also provided.
+    webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW,
+        "web-context", webkit_web_context_get_default(), "related-view", test->m_webView, nullptr));
+    g_assert(webkit_web_view_get_context(webView.get()) == test->m_webContext.get());
 }
 
 static void testWebViewCustomCharset(WebViewTest* test, gconstpointer)
@@ -573,7 +583,7 @@
 
 void beforeAll()
 {
-    WebViewTest::add("WebKitWebView", "default-context", testWebViewDefaultContext);
+    WebViewTest::add("WebKitWebView", "web-context", testWebViewWebContext);
     WebViewTest::add("WebKitWebView", "custom-charset", testWebViewCustomCharset);
     WebViewTest::add("WebKitWebView", "settings", testWebViewSettings);
     WebViewTest::add("WebKitWebView", "zoom-level", testWebViewZoomLevel);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to