Title: [181446] trunk
Revision
181446
Author
[email protected]
Date
2015-03-12 11:38:11 -0700 (Thu, 12 Mar 2015)

Log Message

testRunner.setAlwaysAcceptCookies does not work with NetworkProcess
https://bugs.webkit.org/show_bug.cgi?id=138687

Source/WebKit2:

Reviewed by Carlos Garcia Campos.

* UIProcess/WebCookieManagerProxy.cpp:
(WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy): Don't change system-wide
cookie accept policy when in testing mode. Also, update the policy in WebProcesses too,
as we still do some networking there.

* UIProcess/WebProcessPool.h:
* WebProcess/InjectedBundle/API/c/WKBundle.cpp:
(WKBundleSetAlwaysAcceptCookies): Deleted.
* WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::setAlwaysAcceptCookies): Deleted.
* WebProcess/InjectedBundle/InjectedBundle.h:
Remove WKBundleSetAlwaysAcceptCookies SPI, as WKTR now uses an API in UI process.

Tools:

Reviewed by Carlos Garcia Campos.

Always change cookie policy from UI process, as changing it from WebProcess doesn't
affect other processes.

The implementation is imperfect, because the change happens asynchronously, but I
don't expect it to be a problem in practice.

* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::beginTesting):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setAlwaysAcceptCookies):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::invoke):
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

Unreviewed (only code changes were reviewed).


* platform/gtk/TestExpectations:
* platform/mac-wk2/TestExpectations:
Unskip tests that used to be affected.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (181445 => 181446)


--- trunk/LayoutTests/ChangeLog	2015-03-12 17:46:30 UTC (rev 181445)
+++ trunk/LayoutTests/ChangeLog	2015-03-12 18:38:11 UTC (rev 181446)
@@ -1,3 +1,14 @@
+2015-03-12  Alexey Proskuryakov  <[email protected]>
+
+        testRunner.setAlwaysAcceptCookies does not work with NetworkProcess
+        https://bugs.webkit.org/show_bug.cgi?id=138687
+
+        Unreviewed (only code changes were reviewed).
+
+        * platform/gtk/TestExpectations:
+        * platform/mac-wk2/TestExpectations:
+        Unskip tests that used to be affected.
+
 2015-03-12  Simon Fraser  <[email protected]>
 
         Clean up after JoePeck.

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (181445 => 181446)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2015-03-12 17:46:30 UTC (rev 181445)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2015-03-12 18:38:11 UTC (rev 181446)
@@ -1557,9 +1557,6 @@
 webkit.org/b/139357 fast/dom/call-a-constructor-as-a-function.html [ Failure ]
 webkit.org/b/139357 js/dom/constructor-length.html [ Failure ]
 
-# testRunner.setAlwaysAcceptCookies does not work with NetworkProcess
-webkit.org/b/138687 http/tests/xmlhttprequest/cross-origin-cookie-storage.html [ Skip ]
-
 # PingLoader is still in WebProcess. As a result, this test fails and also fails to delete its cookie, breaking many other cookie tests.
 webkit.org/b/138688 http/tests/navigation/ping-cookie.html [ Skip ]
 

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (181445 => 181446)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2015-03-12 17:46:30 UTC (rev 181445)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2015-03-12 18:38:11 UTC (rev 181446)
@@ -468,10 +468,6 @@
 storage/domstorage/sessionstorage/private-browsing-affects-storage.html [ Skip ]
 storage/websql/private-browsing-noread-nowrite.html [ Skip ]
 
-# testRunner.setAlwaysAcceptCookies does not work with NetworkProcess
-webkit.org/b/138687 http/tests/cookies/third-party-cookie-relaxing.html [ Skip ]
-webkit.org/b/138687 http/tests/xmlhttprequest/cross-origin-cookie-storage.html [ Skip ]
-
 # FIXME: Needs bugzilla (<rdar://problem/12829991>)
 # PPT: PingLoader is still in WebProcess. As a result, this test fails and also fails to delete its cookie, breaking many other cookie tests.
 webkit.org/b/138688 http/tests/navigation/ping-cookie.html [ Skip ]

Modified: trunk/Source/WebKit2/ChangeLog (181445 => 181446)


--- trunk/Source/WebKit2/ChangeLog	2015-03-12 17:46:30 UTC (rev 181445)
+++ trunk/Source/WebKit2/ChangeLog	2015-03-12 18:38:11 UTC (rev 181446)
@@ -1,3 +1,24 @@
+2015-03-12  Alexey Proskuryakov  <[email protected]>
+
+        testRunner.setAlwaysAcceptCookies does not work with NetworkProcess
+        https://bugs.webkit.org/show_bug.cgi?id=138687
+
+        Reviewed by Carlos Garcia Campos.
+
+        * UIProcess/WebCookieManagerProxy.cpp:
+        (WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy): Don't change system-wide
+        cookie accept policy when in testing mode. Also, update the policy in WebProcesses too,
+        as we still do some networking there.
+
+        * UIProcess/WebProcessPool.h:
+        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
+        (WKBundleSetAlwaysAcceptCookies): Deleted.
+        * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
+        * WebProcess/InjectedBundle/InjectedBundle.cpp:
+        (WebKit::InjectedBundle::setAlwaysAcceptCookies): Deleted.
+        * WebProcess/InjectedBundle/InjectedBundle.h:
+        Remove WKBundleSetAlwaysAcceptCookies SPI, as WKTR now uses an API in UI process.
+
 2015-03-12  Anders Carlsson  <[email protected]>
 
         WKErrorDomain should be declared nonnull

Modified: trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp (181445 => 181446)


--- trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp	2015-03-12 17:46:30 UTC (rev 181445)
+++ trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp	2015-03-12 18:38:11 UTC (rev 181446)
@@ -152,13 +152,21 @@
 void WebCookieManagerProxy::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
 {
 #if PLATFORM(COCOA)
-    persistHTTPCookieAcceptPolicy(policy);
+    if (!processPool()->isUsingTestingNetworkSession())
+        persistHTTPCookieAcceptPolicy(policy);
 #endif
 #if USE(SOUP)
     processPool()->setInitialHTTPCookieAcceptPolicy(policy);
 #endif
 
-    processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy));
+    // The policy is not sent to newly created processes (only Soup does that via setInitialHTTPCookieAcceptPolicy()). This is not a serious problem, because:
+    // - When testing, we only have one WebProcess and one NetworkProcess, and WebKitTestRunner never restarts them;
+    // - When not testing, Cocoa has the policy persisted, and thus new processes use it (even for ephemeral sessions).
+    processPool()->sendToAllProcesses(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy));
+#if ENABLE(NETWORK_PROCESS)
+    if (processPool()->usesNetworkProcess())
+        processPool()->sendToNetworkingProcess(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy));
+#endif
 }
 
 void WebCookieManagerProxy::getHTTPCookieAcceptPolicy(std::function<void (HTTPCookieAcceptPolicy, CallbackBase::Error)> callbackFunction)

Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.h (181445 => 181446)


--- trunk/Source/WebKit2/UIProcess/WebProcessPool.h	2015-03-12 17:46:30 UTC (rev 181445)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.h	2015-03-12 18:38:11 UTC (rev 181446)
@@ -246,6 +246,7 @@
     void setCookieStorageDirectory(const String& dir) { m_overrideCookieStorageDirectory = dir; }
 
     void useTestingNetworkSession();
+    bool isUsingTestingNetworkSession() const { return m_shouldUseTestingNetworkSession; }
 
     void allowSpecificHTTPSCertificateForHost(const WebCertificateInfo*, const String& host);
 

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp (181445 => 181446)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp	2015-03-12 17:46:30 UTC (rev 181445)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp	2015-03-12 18:38:11 UTC (rev 181446)
@@ -83,11 +83,6 @@
     return toImpl(bundleRef)->_javascript_ObjectsCount();
 }
 
-void WKBundleSetAlwaysAcceptCookies(WKBundleRef bundleRef, bool accept)
-{
-    toImpl(bundleRef)->setAlwaysAcceptCookies(accept);
-}
-
 void WKBundleAddUserScript(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, WKBundleScriptWorldRef scriptWorldRef, WKStringRef sourceRef, WKURLRef urlRef, WKArrayRef whitelistRef, WKArrayRef blacklistRef, _WKUserScriptInjectionTime injectionTimeRef, WKUserContentInjectedFrames injectedFramesRef)
 {
     toImpl(bundleRef)->addUserScript(toImpl(pageGroupRef), toImpl(scriptWorldRef), toWTFString(sourceRef), toWTFString(urlRef), toImpl(whitelistRef), toImpl(blacklistRef), toUserScriptInjectionTime(injectionTimeRef), toUserContentInjectedFrames(injectedFramesRef));

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h (181445 => 181446)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h	2015-03-12 17:46:30 UTC (rev 181445)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h	2015-03-12 18:38:11 UTC (rev 181446)
@@ -40,8 +40,7 @@
 extern "C" {
 #endif
 
-// TestRunner only SPI
-WK_EXPORT void WKBundleSetAlwaysAcceptCookies(WKBundleRef bundle, bool);
+// TestRunner only SPIs.
 // Will make WebProcess ignore this preference until a preferences change notification, only for WebKitTestRunner use.
 WK_EXPORT void WKBundleOverrideBoolPreferenceForTestRunner(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKStringRef preference, bool enabled);
 WK_EXPORT void WKBundleSetAllowUniversalAccessFromFileURLs(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp (181445 => 181446)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp	2015-03-12 17:46:30 UTC (rev 181445)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp	2015-03-12 18:38:11 UTC (rev 181446)
@@ -136,11 +136,6 @@
     return WebProcess::singleton().webConnectionToUIProcess();
 }
 
-void InjectedBundle::setAlwaysAcceptCookies(bool accept)
-{
-    WebProcess::singleton().supplement<WebCookieManager>()->setHTTPCookieAcceptPolicy(accept ? HTTPCookieAcceptPolicyAlways : HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain);
-}
-
 void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* pageGroup, const String& preference, bool enabled)
 {
     const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h (181445 => 181446)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h	2015-03-12 17:46:30 UTC (rev 181445)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h	2015-03-12 18:38:11 UTC (rev 181446)
@@ -97,7 +97,6 @@
     WebConnection* webConnectionToUIProcess() const;
 
     // TestRunner only SPI
-    void setAlwaysAcceptCookies(bool);
     void overrideBoolPreferenceForTestRunner(WebPageGroupProxy*, const String& preference, bool enabled);
     void overrideXSSAuditorEnabledForTestRunner(WebPageGroupProxy* pageGroup, bool enabled);
     void setAllowUniversalAccessFromFileURLs(WebPageGroupProxy*, bool);

Modified: trunk/Tools/ChangeLog (181445 => 181446)


--- trunk/Tools/ChangeLog	2015-03-12 17:46:30 UTC (rev 181445)
+++ trunk/Tools/ChangeLog	2015-03-12 18:38:11 UTC (rev 181446)
@@ -1,3 +1,24 @@
+2015-03-12  Alexey Proskuryakov  <[email protected]>
+
+        testRunner.setAlwaysAcceptCookies does not work with NetworkProcess
+        https://bugs.webkit.org/show_bug.cgi?id=138687
+
+        Reviewed by Carlos Garcia Campos.
+
+        Always change cookie policy from UI process, as changing it from WebProcess doesn't
+        affect other processes.
+
+        The implementation is imperfect, because the change happens asynchronously, but I
+        don't expect it to be a problem in practice.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::beginTesting):
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setAlwaysAcceptCookies):
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::invoke):
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+
 2015-03-12  Csaba Osztrogonác  <[email protected]>
 
         [EFL] Enable building EFL 1.13 with NEON support

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (181445 => 181446)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2015-03-12 17:46:30 UTC (rev 181445)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2015-03-12 18:38:11 UTC (rev 181446)
@@ -249,7 +249,6 @@
     WKBundleSetAllowFileAccessFromFileURLs(m_bundle, m_pageGroup, true);
     WKBundleSetPluginsEnabled(m_bundle, m_pageGroup, true);
     WKBundleSetPopupBlockingEnabled(m_bundle, m_pageGroup, false);
-    WKBundleSetAlwaysAcceptCookies(m_bundle, false); // FIXME: Do this from UI process, so that Networking process gets the preference, too.
     WKBundleSetSerialLoadingEnabled(m_bundle, false);
 
     WKBundleRemoveAllUserContent(m_bundle, m_pageGroup);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (181445 => 181446)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2015-03-12 17:46:30 UTC (rev 181445)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2015-03-12 18:38:11 UTC (rev 181446)
@@ -601,7 +601,11 @@
 
 void TestRunner::setAlwaysAcceptCookies(bool accept)
 {
-    WKBundleSetAlwaysAcceptCookies(InjectedBundle::singleton().bundle(), accept);
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetAlwaysAcceptCookies"));
+
+    WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(accept));
+
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), 0);
 }
 
 double TestRunner::preciseTime()

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (181445 => 181446)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2015-03-12 17:46:30 UTC (rev 181445)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2015-03-12 18:38:11 UTC (rev 181446)
@@ -31,6 +31,7 @@
 #include "StringFunctions.h"
 #include "TestController.h"
 #include <WebKit/WKContextPrivate.h>
+#include <WebKit/WKCookieManager.h>
 #include <WebKit/WKData.h>
 #include <WebKit/WKDictionary.h>
 #include <WebKit/WKInspector.h>
@@ -151,6 +152,8 @@
 
     TestController::singleton().setShouldLogHistoryClientCallbacks(shouldLogHistoryClientCallbacks());
 
+    WKCookieManagerSetHTTPCookieAcceptPolicy(WKContextGetCookieManager(TestController::singleton().context()), kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain);
+
     // FIXME: We should clear out visited links here.
 
     WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("BeginTest"));
@@ -642,6 +645,15 @@
 #endif
         return result;
     }
+
+    if (WKStringIsEqualToUTF8CString(messageName, "SetAlwaysAcceptCookies")) {
+        WKBooleanRef accept = static_cast<WKBooleanRef>(messageBody);
+        WKHTTPCookieAcceptPolicy policy = WKBooleanGetValue(accept) ? kWKHTTPCookieAcceptPolicyAlways : kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
+        // FIXME: This updates the policy in WebProcess and in NetworkProcess asynchronously, which might break some tests' expectations.
+        WKCookieManagerSetHTTPCookieAcceptPolicy(WKContextGetCookieManager(TestController::singleton().context()), policy);
+        return 0;
+    }
+
     ASSERT_NOT_REACHED();
     return 0;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to