WebKitTestRunner: Credential cache is not cleared between tests
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Jan 2016 18:41:27 +0000 (18:41 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Jan 2016 18:41:27 +0000 (18:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153407
<rdar://problem/24280834>

Reviewed by Brady Eidson.

Source/WebKit2:

Add SPI to call NetworkStorageSession::switchToNewTestingSession() to create a new testing session.
The new testing session will have an empty credential cache.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::switchToNewTestingSession): Added.
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in: Added message SwitchToNewTestingSession().
* UIProcess/API/C/WKContext.cpp:
(WKContextResetTestingNetworkSession): Added.
* UIProcess/API/C/WKContextPrivate.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::resetTestingNetworkSession): Added.
* UIProcess/WebProcessPool.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::switchToNewTestingSession): Added.
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in: Added message SwitchToNewTestingSession().

Tools:

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetStateToConsistentValues): Reset testing network session
to clear cached credentials.

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

13 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkProcess.cpp
Source/WebKit2/NetworkProcess/NetworkProcess.h
Source/WebKit2/NetworkProcess/NetworkProcess.messages.in
Source/WebKit2/UIProcess/API/C/WKContext.cpp
Source/WebKit2/UIProcess/API/C/WKContextPrivate.h
Source/WebKit2/UIProcess/WebProcessPool.cpp
Source/WebKit2/UIProcess/WebProcessPool.h
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/WebProcess.h
Source/WebKit2/WebProcess/WebProcess.messages.in
Tools/ChangeLog
Tools/WebKitTestRunner/TestController.cpp

index 97bff53..7169a50 100644 (file)
@@ -1,3 +1,29 @@
+2016-01-25  Daniel Bates  <dabates@apple.com>
+
+        WebKitTestRunner: Credential cache is not cleared between tests
+        https://bugs.webkit.org/show_bug.cgi?id=153407
+        <rdar://problem/24280834>
+
+        Reviewed by Brady Eidson.
+
+        Add SPI to call NetworkStorageSession::switchToNewTestingSession() to create a new testing session.
+        The new testing session will have an empty credential cache.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::switchToNewTestingSession): Added.
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcess.messages.in: Added message SwitchToNewTestingSession().
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextResetTestingNetworkSession): Added.
+        * UIProcess/API/C/WKContextPrivate.h:
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::resetTestingNetworkSession): Added.
+        * UIProcess/WebProcessPool.h:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::switchToNewTestingSession): Added.
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in: Added message SwitchToNewTestingSession().
+
 2016-01-22  Ryosuke Niwa  <rniwa@webkit.org>
 
         document.createElement should be able to create a custom element
index 2fd46c3..17d8333 100644 (file)
@@ -255,6 +255,11 @@ void NetworkProcess::createNetworkConnectionToWebProcess()
 #endif
 }
 
+void NetworkProcess::switchToNewTestingSession()
+{
+    NetworkStorageSession::switchToNewTestingSession();
+}
+
 void NetworkProcess::ensurePrivateBrowsingSession(SessionID sessionID)
 {
     RemoteNetworkingContext::ensurePrivateBrowsingSession(sessionID);
index 462f9bf..8ee9bf0 100644 (file)
@@ -146,6 +146,8 @@ private:
     void deleteWebsiteData(WebCore::SessionID, uint64_t websiteDataTypes, std::chrono::system_clock::time_point modifiedSince, uint64_t callbackID);
     void deleteWebsiteDataForOrigins(WebCore::SessionID, uint64_t websiteDataTypes, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, uint64_t callbackID);
 
+    void switchToNewTestingSession();
+
     // FIXME: This should take a session ID so we can identify which disk cache to delete.
     void clearDiskCache(std::chrono::system_clock::time_point modifiedSince, std::function<void ()> completionHandler);
 
index 11fe623..01a42b2 100644 (file)
@@ -32,6 +32,8 @@ messages -> NetworkProcess LegacyReceiver {
     UserPreferredLanguagesChanged(Vector<String> languages)
 #endif
 
+    SwitchToNewTestingSession()
+
     EnsurePrivateBrowsingSession(WebCore::SessionID sessionID)
     DestroyPrivateBrowsingSession(WebCore::SessionID sessionID)
 
index 4c52057..8e57973 100644 (file)
@@ -538,6 +538,11 @@ void WKContextUseTestingNetworkSession(WKContextRef context)
     toImpl(context)->useTestingNetworkSession();
 }
 
+void WKContextResetTestingNetworkSession(WKContextRef context)
+{
+    toImpl(context)->resetTestingNetworkSession();
+}
+
 WKDictionaryRef WKContextCopyPlugInAutoStartOriginHashes(WKContextRef contextRef)
 {
     return toAPI(toImpl(contextRef)->plugInAutoStartOriginHashes().leakRef());
index 9e5a38e..455c3f0 100644 (file)
@@ -82,6 +82,9 @@ WK_EXPORT void WKContextSetUsesNetworkProcess(WKContextRef, bool);
 // Test only. Should be called before any secondary processes are started.
 WK_EXPORT void WKContextUseTestingNetworkSession(WKContextRef context);
 
+// Test only. Should be called before running a test.
+WK_EXPORT void WKContextResetTestingNetworkSession(WKContextRef context);
+
 typedef void (*WKContextInvalidMessageFunction)(WKStringRef messageName);
 WK_EXPORT void WKContextSetInvalidMessageFunction(WKContextInvalidMessageFunction invalidMessageFunction);
     
index 536063e..1c42700 100644 (file)
@@ -1073,6 +1073,18 @@ void WebProcessPool::useTestingNetworkSession()
     m_shouldUseTestingNetworkSession = true;
 }
 
+void WebProcessPool::resetTestingNetworkSession()
+{
+    ASSERT(!m_processes.isEmpty());
+    ASSERT(m_networkProcess);
+
+    if (!m_shouldUseTestingNetworkSession || !m_networkProcess || m_processes.isEmpty())
+        return;
+
+    sendToAllProcesses(Messages::WebProcess::SwitchToNewTestingSession());
+    m_networkProcess->send(Messages::NetworkProcess::SwitchToNewTestingSession(), 0);
+}
+
 void WebProcessPool::allowSpecificHTTPSCertificateForHost(const WebCertificateInfo* certificate, const String& host)
 {
     if (m_networkProcess)
index 00b9402..9f907ac 100644 (file)
@@ -239,6 +239,7 @@ public:
     void setCookieStorageDirectory(const String& dir) { m_overrideCookieStorageDirectory = dir; }
 
     void useTestingNetworkSession();
+    void resetTestingNetworkSession();
     bool isUsingTestingNetworkSession() const { return m_shouldUseTestingNetworkSession; }
 
     void allowSpecificHTTPSCertificateForHost(const WebCertificateInfo*, const String& host);
index 1280e78..322a995 100644 (file)
@@ -498,6 +498,11 @@ void WebProcess::setCacheModel(uint32_t cm)
     }
 }
 
+void WebProcess::switchToNewTestingSession()
+{
+    NetworkStorageSession::switchToNewTestingSession();
+}
+
 WebPage* WebProcess::focusedWebPage() const
 {    
     for (auto& page : m_pageMap.values()) {
index bb9c024..27e00ad 100644 (file)
@@ -210,6 +210,8 @@ private:
     void initializeWebProcess(WebProcessCreationParameters&&);
     void platformInitializeWebProcess(WebProcessCreationParameters&&);
 
+    void switchToNewTestingSession();
+
     void platformTerminate();
     void registerURLSchemeAsEmptyDocument(const String&);
     void registerURLSchemeAsSecure(const String&) const;
index dbd1693..99af8db 100644 (file)
@@ -45,6 +45,8 @@ messages -> WebProcess LegacyReceiver {
     UserPreferredLanguagesChanged(Vector<String> languages)
     FullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled)
 
+    SwitchToNewTestingSession()
+
     // Legacy private browsing session is per process. Individual pages or page groups may use the private session or the default one as appropriate.
     EnsurePrivateBrowsingSession(WebCore::SessionID sessionID)
     DestroyPrivateBrowsingSession(WebCore::SessionID sessionID)
index 2e67bed..91d5070 100644 (file)
@@ -1,3 +1,15 @@
+2016-01-25  Daniel Bates  <dabates@apple.com>
+
+        WebKitTestRunner: Credential cache is not cleared between tests
+        https://bugs.webkit.org/show_bug.cgi?id=153407
+        <rdar://problem/24280834>
+
+        Reviewed by Brady Eidson.
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetStateToConsistentValues): Reset testing network session
+        to clear cached credentials.
+
 2016-01-24  Dan Bernstein  <mitz@apple.com>
 
         Added project.xcworkspace and xcuserdata to this project’s svn:ignore.
index 1ddd0e8..8ed6e18 100644 (file)
@@ -714,6 +714,8 @@ bool TestController::resetStateToConsistentValues()
 
     WKContextSetCacheModel(TestController::singleton().context(), kWKCacheModelDocumentBrowser);
 
+    WKContextResetTestingNetworkSession(TestController::singleton().context());
+
     // FIXME: This function should also ensure that there is only one page open.
 
     // Reset the EventSender for each test.