[GTK] Fix a crash when WebKitWebView is created without a WebContext
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 16:31:14 +0000 (16:31 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 16:31:14 +0000 (16:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=78104

Reviewed by Philippe Normand.

* UIProcess/API/gtk/WebKitWebView.cpp:
(webkitWebViewSetProperty): Make sure WebKitWebView:web-context
property is initialized to the default web context when a web
context is not passed to g_object_new().
* UIProcess/API/gtk/tests/TestWebKitWebView.cpp:
(testWebViewDefaultContext): Check that a web view created with
g_object_new has the default context.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107092 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp

index 2433032..a5f098f 100644 (file)
@@ -1,3 +1,18 @@
+2012-02-08  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Fix a crash when WebKitWebView is created without a WebContext
+        https://bugs.webkit.org/show_bug.cgi?id=78104
+
+        Reviewed by Philippe Normand.
+
+        * UIProcess/API/gtk/WebKitWebView.cpp:
+        (webkitWebViewSetProperty): Make sure WebKitWebView:web-context
+        property is initialized to the default web context when a web
+        context is not passed to g_object_new().
+        * UIProcess/API/gtk/tests/TestWebKitWebView.cpp:
+        (testWebViewDefaultContext): Check that a web view created with
+        g_object_new has the default context.
+
 2012-02-08  Michael BrĂ¼ning  <michael.bruning@nokia.com>
 
         [Qt][WK2] Compute and set cache capacities using the current CacheModel
index 567fef8..c3acccc 100644 (file)
@@ -180,9 +180,11 @@ static void webkitWebViewSetProperty(GObject* object, guint propId, const GValue
     WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
 
     switch (propId) {
-    case PROP_WEB_CONTEXT:
-        webView->priv->context = WEBKIT_WEB_CONTEXT(g_value_get_object(value));
+    case PROP_WEB_CONTEXT: {
+        gpointer webContext = g_value_get_object(value);
+        webView->priv->context = webContext ? WEBKIT_WEB_CONTEXT(webContext) : webkit_web_context_get_default();
         break;
+    }
     case PROP_ZOOM_LEVEL:
         webkit_web_view_set_zoom_level(webView, g_value_get_double(value));
         break;
index 16375ed..3d59ee9 100644 (file)
 static void testWebViewDefaultContext(WebViewTest* test, gconstpointer)
 {
     g_assert(webkit_web_view_get_context(test->m_webView) == webkit_web_context_get_default());
+
+    // 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));
+    g_assert(webkit_web_view_get_context(webView.get()) == webkit_web_context_get_default());
 }
 
 static void testWebViewCustomCharset(WebViewTest* test, gconstpointer)