Unreviewed. Fix several GTK tests in /WebKit2Gtk/TestUIClient crashing since r241988

Source/WebKit:

Show a warning message and return nullptr from WebKitWebView::create if the new web view is not related to the
given one. Also make it clear in the documentation that the new web view should be related to the given one.

* UIProcess/API/glib/WebKitWebView.cpp:
(webkit_web_view_class_init):
(webkitWebViewCreateNewPage):

Tools:

This was not caused by r241988, but revealed the existing bug. We were not creating the new WebKitWebView in
UIClientTest with the related WebKitWebView. Since r241988, the new WebPageProxy drawing area is passed to
creationParameters(), but it's nullptr because the WebPageProxy hasn't been initialized yet. When using related
views, the new WebPageProxy is already initialized because it has running processes on creation.

* TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp:
(testWebViewCreateNavigationData):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251132 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index e05e646..bb07677 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,5 +1,16 @@
 2019-10-15  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        Unreviewed. Fix several GTK tests in /WebKit2Gtk/TestUIClient crashing since r241988
+
+        Show a warning message and return nullptr from WebKitWebView::create if the new web view is not related to the
+        given one. Also make it clear in the documentation that the new web view should be related to the given one.
+
+        * UIProcess/API/glib/WebKitWebView.cpp:
+        (webkit_web_view_class_init):
+        (webkitWebViewCreateNewPage):
+
+2019-10-15  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         Unreviewed. Fix GTK test /webkit/Authentication/authentication-storage after r249962
 
         * UIProcess/API/glib/WebKitWebView.cpp:
diff --git a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp b/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
index 4278f22..c3b5c9c 100644
--- a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
+++ b/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
@@ -1353,10 +1353,8 @@
      * The #WebKitNavigationAction parameter contains information about the
      * navigation action that triggered this signal.
      *
-     * When using %WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES
-     * process model, the new #WebKitWebView should be related to
-     * @web_view to share the same web process, see webkit_web_view_new_with_related_view()
-     * for more details.
+     * The new #WebKitWebView must be related to @web_view, see
+     * webkit_web_view_new_with_related_view() for more details.
      *
      * The new #WebKitWebView should not be displayed to the user
      * until the #WebKitWebView::ready-to-show signal is emitted.
@@ -2216,7 +2214,12 @@
     WebKitWebView* newWebView;
     g_signal_emit(webView, signals[CREATE], 0, navigationAction, &newWebView);
     if (!newWebView)
-        return 0;
+        return nullptr;
+
+    if (&getPage(webView).process() != &getPage(newWebView).process()) {
+        g_warning("WebKitWebView returned by WebKitWebView::create signal was not created with the related WebKitWebView");
+        return nullptr;
+    }
 
     webkitWindowPropertiesUpdateFromWebWindowFeatures(newWebView->priv->windowProperties.get(), windowFeatures);
 
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index e656046..deb8e6a 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,5 +1,17 @@
 2019-10-15  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        Unreviewed. Fix several GTK tests in /WebKit2Gtk/TestUIClient crashing since r241988
+
+        This was not caused by r241988, but revealed the existing bug. We were not creating the new WebKitWebView in
+        UIClientTest with the related WebKitWebView. Since r241988, the new WebPageProxy drawing area is passed to
+        creationParameters(), but it's nullptr because the WebPageProxy hasn't been initialized yet. When using related
+        views, the new WebPageProxy is already initialized because it has running processes on creation.
+
+        * TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp:
+        (testWebViewCreateNavigationData):
+
+2019-10-15  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         Unreviewed. Fix GTK test /WebKit2Gtk/TestWebViewEditor
 
         It's failing since we delay the web process launch until the first load. Load about:blank in the test
diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp
index 9c4074c..eb1bd3a 100644
--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp
+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp
@@ -330,7 +330,7 @@
         g_assert_true(webView == m_webView);
         g_assert_nonnull(navigation);
 
-        auto* newWebView = Test::createWebView(webkit_web_view_get_context(webView));
+        auto* newWebView = Test::createWebView(webView);
 #if PLATFORM(GTK)
         g_object_ref_sink(newWebView);
 #endif
@@ -479,7 +479,7 @@
     test->loadHTML("<html><body onLoad=\"window.open();\"></html>");
     test->waitUntilMainLoopFinishes();
 
-    g_assert_cmpstr(webkit_uri_request_get_uri(webkit_navigation_action_get_request(test->m_navigation)), ==, "about:blank");
+    g_assert_cmpstr(webkit_uri_request_get_uri(webkit_navigation_action_get_request(test->m_navigation)), ==, "");
     g_assert_cmpuint(webkit_navigation_action_get_navigation_type(test->m_navigation), ==, WEBKIT_NAVIGATION_TYPE_OTHER);
     g_assert_cmpuint(webkit_navigation_action_get_mouse_button(test->m_navigation), ==, 0);
     g_assert_cmpuint(webkit_navigation_action_get_modifiers(test->m_navigation), ==, 0);