Unreviewed. Fix GTK test /webkit/Authentication/authentication-storage after r249962

Source/WebKit:

* UIProcess/API/glib/WebKitWebView.cpp:
(webkitWebViewHandleAuthenticationChallenge): Do not use webkit_settings_get_enable_private_browsing().

Tools:

The test was still using the legacy private browsing API that is a no-op since r249962. This partch updates the
test to use a ephemeral WebView instead.

* TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp:
(EphemeralAuthenticationTest::setup):
(EphemeralAuthenticationTest::teardown):
(testWebViewAuthenticationEphemeral):
(testWebViewAuthenticationStorage):
(beforeAll):
* TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp:
(WebViewTest::initializeWebView):
* TestWebKitAPI/glib/WebKitGLib/WebViewTest.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251129 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index ca6230b..e05e646 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,5 +1,12 @@
 2019-10-15  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        Unreviewed. Fix GTK test /webkit/Authentication/authentication-storage after r249962
+
+        * UIProcess/API/glib/WebKitWebView.cpp:
+        (webkitWebViewHandleAuthenticationChallenge): Do not use webkit_settings_get_enable_private_browsing().
+
+2019-10-15  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         Unreviewed. Fix GTK test /webkit/WebKitSettings/webkit-settings after r249962.
 
         Legacy private browsing was removed in r249962, so webkit_settings_set_enable_private_browsing() is now no-op.
diff --git a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp b/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
index 107f4dd..4278f22 100644
--- a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
+++ b/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
@@ -2515,14 +2515,7 @@
 
 void webkitWebViewHandleAuthenticationChallenge(WebKitWebView* webView, AuthenticationChallengeProxy* authenticationChallenge)
 {
-#if PLATFORM(GTK)
-    G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-    gboolean privateBrowsingEnabled = webView->priv->isEphemeral || webkit_settings_get_enable_private_browsing(webView->priv->settings.get());
-    G_GNUC_END_IGNORE_DEPRECATIONS;
-#else
-    gboolean privateBrowsingEnabled = webView->priv->isEphemeral;
-#endif
-    webView->priv->authenticationRequest = adoptGRef(webkitAuthenticationRequestCreate(authenticationChallenge, privateBrowsingEnabled));
+    webView->priv->authenticationRequest = adoptGRef(webkitAuthenticationRequestCreate(authenticationChallenge, webView->priv->isEphemeral));
     gboolean returnValue;
     g_signal_emit(webView, signals[AUTHENTICATE], 0, webView->priv->authenticationRequest.get(), &returnValue);
 }
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index b201a6c..cad9f2b 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,5 +1,22 @@
 2019-10-15  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        Unreviewed. Fix GTK test /webkit/Authentication/authentication-storage after r249962
+
+        The test was still using the legacy private browsing API that is a no-op since r249962. This partch updates the
+        test to use a ephemeral WebView instead.
+
+        * TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp:
+        (EphemeralAuthenticationTest::setup):
+        (EphemeralAuthenticationTest::teardown):
+        (testWebViewAuthenticationEphemeral):
+        (testWebViewAuthenticationStorage):
+        (beforeAll):
+        * TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp:
+        (WebViewTest::initializeWebView):
+        * TestWebKitAPI/glib/WebKitGLib/WebViewTest.h:
+
+2019-10-15  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         Unreviewed. Fix GTK test /webkit/WebKitSettings/webkit-settings after r249962.
 
         Stop testing WebKitSettings:enable-private-browsing.
diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp
index 7c8c8b5..5e859eb 100644
--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp
+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp
@@ -78,6 +78,21 @@
     GRefPtr<WebKitAuthenticationRequest> m_authenticationRequest;
 };
 
+class EphemeralAuthenticationTest : public AuthenticationTest {
+public:
+    MAKE_GLIB_TEST_FIXTURE_WITH_SETUP_TEARDOWN(EphemeralAuthenticationTest, setup, teardown);
+
+    static void setup()
+    {
+        WebViewTest::shouldCreateEphemeralWebView = true;
+    }
+
+    static void teardown()
+    {
+        WebViewTest::shouldCreateEphemeralWebView = false;
+    }
+};
+
 int AuthenticationTest::authenticationRetries = 0;
 bool AuthenticationTest::authenticationCancelledReceived = false;
 
@@ -184,30 +199,23 @@
     g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, authExpectedFailureTitle);
 }
 
-// FIXME: Find a way to not use the private browsing setting and enable for WPE.
-#if PLATFORM(GTK)
-static void testWebViewAuthenticationStorage(AuthenticationTest* test, gconstpointer)
+static void testWebViewAuthenticationEphemeral(EphemeralAuthenticationTest* test, gconstpointer)
 {
-    // Enable private browsing before authentication request to test that credentials can't be saved.
-    G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-    webkit_settings_set_enable_private_browsing(webkit_web_view_get_settings(test->m_webView), TRUE);
-    G_GNUC_END_IGNORE_DEPRECATIONS;
     test->loadURI(kServer->getURIForPath("/auth-test.html").data());
-    WebKitAuthenticationRequest* request = test->waitForAuthenticationRequest();
+    auto* request = test->waitForAuthenticationRequest();
     g_assert_null(webkit_authentication_request_get_proposed_credential(request));
     g_assert_false(webkit_authentication_request_can_save_credentials(request));
+}
 
+#if USE(LIBSECRET)
+static void testWebViewAuthenticationStorage(AuthenticationTest* test, gconstpointer)
+{
     // If WebKit has been compiled with libsecret, and private browsing is disabled
     // then check that credentials can be saved.
-#if USE(LIBSECRET)
-    G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-    webkit_settings_set_enable_private_browsing(webkit_web_view_get_settings(test->m_webView), FALSE);
-    G_GNUC_END_IGNORE_DEPRECATIONS;
     test->loadURI(kServer->getURIForPath("/auth-test.html").data());
-    request = test->waitForAuthenticationRequest();
+    auto* request = test->waitForAuthenticationRequest();
     g_assert_null(webkit_authentication_request_get_proposed_credential(request));
     g_assert_true(webkit_authentication_request_can_save_credentials(request));
-#endif
 }
 #endif
 
@@ -420,7 +428,8 @@
     AuthenticationTest::add("Authentication", "authentication-success", testWebViewAuthenticationSuccess);
     AuthenticationTest::add("Authentication", "authentication-failure", testWebViewAuthenticationFailure);
     AuthenticationTest::add("Authentication", "authentication-no-credential", testWebViewAuthenticationNoCredential);
-#if PLATFORM(GTK)
+    EphemeralAuthenticationTest::add("Authentication", "authentication-ephemeral", testWebViewAuthenticationEphemeral);
+#if USE(LIBSECRET)
     AuthenticationTest::add("Authentication", "authentication-storage", testWebViewAuthenticationStorage);
 #endif
     AuthenticationTest::add("Authentication", "authentication-empty-realm", testWebViewAuthenticationEmptyRealm);
diff --git a/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp b/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp
index d53658d..8e3f348 100644
--- a/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp
+++ b/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp
@@ -24,6 +24,7 @@
 #include <JavaScriptCore/JSRetainPtr.h>
 
 bool WebViewTest::shouldInitializeWebViewInConstructor = true;
+bool WebViewTest::shouldCreateEphemeralWebView = false;
 
 WebViewTest::WebViewTest()
     : m_userContentManager(adoptGRef(webkit_user_content_manager_new()))
@@ -56,6 +57,7 @@
 #endif
         "web-context", m_webContext.get(),
         "user-content-manager", m_userContentManager.get(),
+        "is-ephemeral", shouldCreateEphemeralWebView,
         nullptr));
     platformInitializeWebView();
     assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_webView));
diff --git a/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.h b/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.h
index 394af3b..c773355 100644
--- a/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.h
+++ b/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.h
@@ -30,6 +30,7 @@
     virtual ~WebViewTest();
 
     static bool shouldInitializeWebViewInConstructor;
+    static bool shouldCreateEphemeralWebView;
     void initializeWebView();
 
     void platformInitializeWebView();